Login | Register
My pages Projects Community openCollabNet

Discussions > users > [propel] Using Creole to generate xml schema from db.

propel
Discussion topic

Hide all messages in topic

All messages in topic

Re: [propel] Using Creole to generate xml schema from db.

Reply

Author hlellelid
Full name Hans Lellelid
Date 2004-03-31 07:52:15 PST
Message Hi -

>> This does nothing when generating the mysql code when in fact it could
>> generate:
>> CONSTRAINT `fk_zone` FOREIGN KEY (`zone`) REFERENCES `soa` (`id`) ON
>> DELETE CASCADE ON UPDATE CASCADE,
>> CONSTRAINT `fk_aid` FOREIGN KEY (`aid`) REFERENCES `accounts` (`id`)
>> ON DELETE CASCADE ON UPDATE CASCADE
>
> I'm sorry to reply to myself:
>
> It adds:
> FOREIGN KEY (aid) REFERENCES accounts (id),
> FOREIGN KEY (zone) REFERENCES soa (id),
>
> but does not honor the onDelete attribute.

Yes, that's correct. I didn't know that MySQL InnoDB tables supported the
onDelete. This is a function of me porting the template from Torque
(which didn't add this for MySQL). If we can add this w/o creating errors
for the MyISAM tables (i.e. if they just ignore the extra stuff), then we
definitely should.

Currently, ON DELETE CASCADE is emulated for MySQL.

Hans

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
For additional commands, e-mail: users-help at propel dot tigris dot org

Re: [propel] Using Creole to generate xml schema from db.

Reply

Author hlellelid
Full name Hans Lellelid
Date 2004-03-31 07:50:26 PST
Message Hi -

> On Mar 31, 2004, at 9:16 AM, Hans Lellelid wrote:
>> Yes, if you update from CVS (both Creole and Propel, actually) it
>> should
>> now work for you -- or at *least* provide some better error messages
>> if it
>> doesn't.
>
> It is working in the sense that it is generating the schema.sql and
> having no errors.

Ok, good. :)

>> I just ran a test on a database using MySQL. While running this test I
>> discovered some other issues w/ the MySQL metadata support: for
>> example,
>> ENUM(...) columns were not being recognized. Also, there was a
>> compilation error related to accessibility of a variable in
>> MySQLDatabaseInfo class. Both of these issues have been fixed in CVS.
>>
>
> This is what happens to my enum type:
> <column name="type" type="CHAR"/>
> The original is:
> `type`
> enum('A','AAAA','CNA​ME','HINFO','MX','NS​','PTR','RP','SRV','​TXT','URL')
> default NULL,

Yeah, there is not good support for ENUM, since it's MySQL-specific. The
best solution for this, I think, would be to use one of the new Validator
classes. It's not quite the same, but should allow you to easily force
the values to be one of those.

> A couple other notes...when modifying the schema.xml I added:
>
> <foreign-key foreignTable="accounts" onDelete="cascade">
> <reference local="aid" foreign="id"/>
> </foreign-key>
> <foreign-key foreignTable="soa" onDelete="cascade">
> <reference local="zone" foreign="id"/>
> </foreign-key>
>
> This does nothing when generating the mysql code when in fact it could
> generate:
> CONSTRAINT `fk_zone` FOREIGN KEY (`zone`) REFERENCES `soa` (`id`) ON
> DELETE CASCADE ON UPDATE CASCADE,
> CONSTRAINT `fk_aid` FOREIGN KEY (`aid`) REFERENCES `accounts` (`id`)
> ON DELETE CASCADE ON UPDATE CASCADE
>
> Although that is mysql4.0+ specific I think.

That's good to know ... I wonder if this would generate problems w/ 3.x or
if it would just be ignored. I'm actually fine w/ requiring 4.0+ since
we're building for PHP5 ... i.e. anyone running PHP5 will probably be
using a new MySQL. Of course this will only apply to the InnoDB tables,
so the emulation will still need to be supported if using MyISAM tables.
As long as it doesn't cause a MySQL error when using MyISAM tables, we
should definitely add this, though.

> Other things seem to be working so far. :)

Good, good :) & please let us know about any of these little things that
need to be fixed. We're working to make this stable & usable and need all
the feedback we can get.

Thanks,
Hans

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
For additional commands, e-mail: users-help at propel dot tigris dot org

Re: [propel] Using Creole to generate xml schema from db.

Reply

Author davidu
Full name David A. Ulevitch
Date 2004-03-31 07:45:02 PST
Message On Mar 31, 2004, at 9:43 AM, David A. Ulevitch wrote:
> <foreign-key foreignTable="accounts" onDelete="cascade">
> <reference local="aid" foreign="id"/>
> </foreign-key>
> <foreign-key foreignTable="soa" onDelete="cascade">
> <reference local="zone" foreign="id"/>
> </foreign-key>
>
> This does nothing when generating the mysql code when in fact it could
> generate:
> CONSTRAINT `fk_zone` FOREIGN KEY (`zone`) REFERENCES `soa` (`id`) ON
> DELETE CASCADE ON UPDATE CASCADE,
> CONSTRAINT `fk_aid` FOREIGN KEY (`aid`) REFERENCES `accounts` (`id`)
> ON DELETE CASCADE ON UPDATE CASCADE

I'm sorry to reply to myself:

It adds:
     FOREIGN KEY (aid) REFERENCES accounts (id),
     FOREIGN KEY (zone) REFERENCES soa (id),

but does not honor the onDelete attribute.

-davidu


--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
For additional commands, e-mail: users-help at propel dot tigris dot org

Re: [propel] Using Creole to generate xml schema from db.

Reply

Author davidu
Full name David A. Ulevitch
Date 2004-03-31 07:43:09 PST
Message On Mar 31, 2004, at 9:16 AM, Hans Lellelid wrote:
> Yes, if you update from CVS (both Creole and Propel, actually) it
> should
> now work for you -- or at *least* provide some better error messages
> if it
> doesn't.

It is working in the sense that it is generating the schema.sql and
having no errors.

> I just ran a test on a database using MySQL. While running this test I
> discovered some other issues w/ the MySQL metadata support: for
> example,
> ENUM(...) columns were not being recognized. Also, there was a
> compilation error related to accessibility of a variable in
> MySQLDatabaseInfo class. Both of these issues have been fixed in CVS.
>

This is what happens to my enum type:
<column name="type" type="CHAR"/>
The original is:
`type`
enum('A','AAAA','CNA​ME','HINFO','MX','NS​','PTR','RP','SRV','​TXT','URL')
default NULL,

> Thanks for trying this out. Sorry that this functionality is a little
> more "fringe" in terms of functionality and reliability. Hopefully now
> it'll all work, but let me know if not.

Not a problem.

A couple other notes...when modifying the schema.xml I added:

     <foreign-key foreignTable="accounts" onDelete="cascade">
         <reference local="aid" foreign="id"/>
     </foreign-key>
     <foreign-key foreignTable="soa" onDelete="cascade">
         <reference local="zone" foreign="id"/>
     </foreign-key>

This does nothing when generating the mysql code when in fact it could
generate:
   CONSTRAINT `fk_zone` FOREIGN KEY (`zone`) REFERENCES `soa` (`id`) ON
DELETE CASCADE ON UPDATE CASCADE,
   CONSTRAINT `fk_aid` FOREIGN KEY (`aid`) REFERENCES `accounts` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE

Although that is mysql4.0+ specific I think.

Other things seem to be working so far. :)

thanks,
davidu

ps: I am now on users@propel -- no more need to CC me. :)


--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
For additional commands, e-mail: users-help at propel dot tigris dot org

Re: [propel] Using Creole to generate xml schema from db.

Reply

Author hlellelid
Full name Hans Lellelid
Date 2004-03-31 07:16:05 PST
Message Hi there,

Ok I think I've identified & fixed the problems. I've added some inline
comments to demonstrate what the problem was I'll summarize what changed
at the end.

> I think I have my build.properties setup correctly (as per the example)
> and I'm running:

Yes, from what I can tell your build properties are fine. I did make a
change to the default.properties file to add a default (empty) value for
username/password so that you can specify these in the db URL. (This is
how it works for other db phing tasks, so this is more consistent now.)

>
> propel > creole:
> [echo] +-------------------​--------------------​--------+
> [echo] | |
> [echo] | Generating XML from Creole connection ! |
> [echo] | |
> [echo] +-------------------​--------------------​--------+
> [propel-creole-transform] Propel - CreoleToXMLSchema starting
> [propel-creole-transform] Your DB settings are:
> [propel-creole-transform] driver : (default)
> [propel-creole-transform] URL :
> mysql://everybox:***​*******@localhost/ev​erybox
> [propel-creole-transform] user : ${databaseUser}

Here was the first sign of problems. the propel.database.user variable
was (I assume) commented out of your build.properties. As mentioned, I've
fixed this so that it will default to '' (and empty users/passwords will
be ignored by the creole transform task, meaning that the user/pass in
your URL will be used)

> [propel-creole-transform] Object id #421

This was the sign of the next problem. w/ RC1, PHP5 broke backwards
compatibility w/ the other betas by removing the ability to have the
__toString() method called whenever an explicit string case was performed.
 This was an extremely difficult change to fix & this is one of the
examples we missed. That Object id #421 is an Exception object. I've
fixed this in the creole transform task so that it is logged as an error
and the proper message is displayed.

> But I get no generated xml schema file anywhere in the ./build area or
> in ./schema

Yes, if you update from CVS (both Creole and Propel, actually) it should
now work for you -- or at *least* provide some better error messages if it
doesn't.

I just ran a test on a database using MySQL. While running this test I
discovered some other issues w/ the MySQL metadata support: for example,
ENUM(...) columns were not being recognized. Also, there was a
compilation error related to accessibility of a variable in
MySQLDatabaseInfo class. Both of these issues have been fixed in CVS.

Thanks for trying this out. Sorry that this functionality is a little
more "fringe" in terms of functionality and reliability. Hopefully now
it'll all work, but let me know if not.

Thanks-
Hans

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
For additional commands, e-mail: users-help at propel dot tigris dot org

[propel] Using Creole to generate xml schema from db.

Reply

Author davidu
Full name David A. Ulevitch
Date 2004-03-31 06:02:42 PST
Message I think I have my build.properties setup correctly (as per the example)
and I'm running:

davidu@fiona:/var/op​t/php5/lib/propel$ phing -f build-propel.xml creole
Buildfile: /var/opt/php5/lib/pr​opel/build-propel.xm​l

propel > creole:
      [echo] +-------------------​--------------------​--------+
      [echo] | |
      [echo] | Generating XML from Creole connection ! |
      [echo] | |
      [echo] +-------------------​--------------------​--------+
[propel-creole-transform] Propel - CreoleToXMLSchema starting
[propel-creole-transform] Your DB settings are:
[propel-creole-transform] driver : (default)
[propel-creole-transform] URL :
mysql://everybox:***​*******@localhost/ev​erybox
[propel-creole-transform] user : ${databaseUser}
[propel-creole-transform] Object id #421
[propel-creole-transform] Propel - CreoleToXMLSchema finished

BUILD SUCCESSFUL

Total time: 0.2966 seconds
davidu@fiona:/var/op​t/php5/lib/propel$

But I get no generated xml schema file anywhere in the ./build area or
in ./schema

my build.properties looks like this:
propel.database.url = mysql://everybox:***​*****@localhost/ever​ybox
#propel.database.dbname = everybox
#propel.database.user = everybox
#propel.database.password = ********
propel.database.schema = everybox-schema.xml


Is this not supposed to work? My database has many tables and I'd
rather generate the skeleton and fix it than write it all out from
hand.

thanks,
davidu

ps: please cc' me as I am not subscribed.


--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
For additional commands, e-mail: users-help at propel dot tigris dot org
Messages per page: