Hi Mike,

I totally go straight with that.
I simply need the default value to allow the migration to add a "null = false" field into a table with existing datasets. After the successful migration I run an update that fills the new field with real data.

I already tried to add this feature to the PostgresqlPlugIn but either I am too stupid or I am too much of a WO(nder) rookie. I looked at the FrontbasePlugin and found the method addCreateClauseForAttribute where the "DEFAULT" stuff seems to be done. So I tried to extended the same method in the PostgresqlExpression class. But this method isn't called during the migration. So I dug deeper and debugged the migration process. The statment is built by a call of EOSchemaSynchronizationFactory._columnCreationClauseForAttribute method which calls - in my case

PostgresqlExpression.columnTypeStringForAttribute
PostgresqlExpression.allowsNullClauseForConstraint

so something like "attributename text NOT NULL" will be created.
But there is no call to a method which gives me the chance to add the default text to the statement.

Do I have to change the JDBCInfo.plist to tell _columnCreationClauseForAttribute what should be called? I already tried this. I thought the "createParams" key might do something like that but It didn't do anything.

Can you tell me what I'm missing here?

I hope that inhaling all the sessions at the WOWODC will bring me to a new and more experienced level... :-)

Best regards,
Helmut

Am 10.04.2008 um 06:09 schrieb Mike Schrag:
Using DB defaults may *not* be a good idea if you don't also have them in EOF code. EOF will save and then have a different value in mem as in the DB.
The intent (though I don't know if it's clear in the API) of setting defaults is ONLY for use in migrations so that you can add a not- null column and set a default value for existing rows to prevent it from failing with a constraint violation. They should ONLY be used on not-null columns that are also marked allows null = false in your model so EOF will fail before it hits the DB, or you will suffer the fate that Anjo describes.

ms

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/helmut.schottmueller%40mac.com

This email sent to [EMAIL PROTECTED]

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to