• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ERXMigrationTable.newColumn does not set default value
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ERXMigrationTable.newColumn does not set default value


  • Subject: Re: ERXMigrationTable.newColumn does not set default value
  • From: Helmut Schottmüller <email@hidden>
  • Date: Thu, 10 Apr 2008 12:17:40 +0200

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      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

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

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: ERXMigrationTable.newColumn does not set default value
      • From: Mike Schrag <email@hidden>
References: 
 >ERXMigrationTable.newColumn does not set default value (From: Helmut Schottmüller <email@hidden>)
 >Re: ERXMigrationTable.newColumn does not set default value (From: Mike Schrag <email@hidden>)
 >Re: ERXMigrationTable.newColumn does not set default value (From: Helmut Schottmüller <email@hidden>)
 >Re: ERXMigrationTable.newColumn does not set default value (From: Anjo Krank <email@hidden>)
 >Re: ERXMigrationTable.newColumn does not set default value (From: Mike Schrag <email@hidden>)

  • Prev by Date: Wonder AJAX Fileupload problem.
  • Next by Date: Re: ERXMigrationTable.newColumn does not set default value
  • Previous by thread: Re: ERXMigrationTable.newColumn does not set default value
  • Next by thread: Re: ERXMigrationTable.newColumn does not set default value
  • Index(es):
    • Date
    • Thread