Modify

Ticket #945 (closed defect: fixed)

Opened 19 months ago

Last modified 19 months ago

Oracle migration problems using Boolean field with Default Value

Reported by: goodrich@… Owned by: andrew
Priority: major Milestone:
Component: migrations Version: mercurial
Keywords: oracle boolean default Cc:

Description

FATAL ERROR - The following SQL query failed: CREATE TABLE "CAMPUSFORMS_APPROVEDPRODUCT" ( "ID" NUMBER(11) NOT NULL PRIMARY KEY, "NAME" NVARCHAR2(400) DEFAULT NULL , "MANUFACTURE R" NVARCHAR2(100) DEFAULT NULL , "RESTRICTED" NUMBER(1) CHECK ("RESTRICTED" IN (0,1)) DEFAULT False NOT NULL );

It looks like there is issue with the placement of the CHECK() clause. It should come before both DEFAULT and NOT NULL.

The value of False is not valid as well (a separate issue).

I think similar tickets have been submitted but this one reflects the code from the tip as of now.

Here's the migration script the causes the error:

# Adding model 'ApprovedProduct?'
db.create_table('campusforms_approvedproduct', (

('id', self.gf('django.db.models.fields.AutoField?')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField?')(max_length=400)),
('manufacturer', self.gf('django.db.models.fields.CharField?')(max_length=100)),
('restricted', self.gf('django.db.models.fields.BooleanField?')(default=False)),

))
db.send_create_signal('campusforms', ApprovedProduct?)

Attachments

fix_bools.diff (729 bytes) - added by Sam Hartsfield <samh.public@…> 19 months ago.
Hack-ish patch for boolean values

Change History

comment:1 Changed 19 months ago by goodrich@…

I'm sorry - I meant to say the CHECK() should come AFTER not before. Also, ignore the '?' in the bottom code - I'm not sure how that got in there.

comment:2 Changed 19 months ago by Sam Hartsfield <samh.public@…>

I bisected to try to find when the the boolean field defaults changed from 0/1 to "True"/"False". If I did it correctly, it looks like it's 8e5a21d8dd6b - "fixed migration for custom fieldtypes with default values". I think this may be the cause of the placement issue as well.

Changed 19 months ago by Sam Hartsfield <samh.public@…>

Hack-ish patch for boolean values

comment:3 Changed 19 months ago by Sam Hartsfield <samh.public@…>

I attached a patch, but it seems like a hack. This is the first time I've looked at the South code, so maybe there's a better way to do it; feedback would be appreciated.

comment:4 Changed 19 months ago by andrew

The entire Oracle module is pretty much a hack, and it's not terribly well-maintained (since I can't do it) - if the patch works for you, and you don't think there's any major downsides, I'll apply it.

comment:5 Changed 19 months ago by Sam Hartsfield <samh.public@…>

Fair enough. It's pretty targeted, so I don't think it's likely to affect anything unexpected.

comment:6 Changed 19 months ago by andrew

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in [dca268e628a4].

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.