G'night everyone.

I'm defining a table like this:

db.define_table("BillHourType", SQLField("hourtype", db.HourType),
                                SQLField("billtype", db.BillableType),
                                SQLField("startdate", type='date',
                                         required=True, notnull=True,
                                         requires=IS_DATE()),
                                SQLField("enddate", type='date'))
and I'm hitting the following error:


DatabaseError: ORA-00972: identifier is too long

so I took a look in sql.log where I found this:

CREATE TABLE BillHourType(
        id NUMBER PRIMARY KEY,
        hourtype NUMBER, CONSTRAINT BillHourType_hourtype__constraint
FOREIGN KEY (hourtype) REFERENCES HourType(id) ON DELETE CASCADE,
        billtype NUMBER, CONSTRAINT BillHourType_billtype__constraint
FOREIGN KEY (billtype) REFERENCES BillableType(id) ON DELETE CASCADE,
        startdate DATE NOT NULL,
        enddate DATE
);

If I'm right objects names in oracle cannot be larger than 30 characters and
the constraint name (BillHourType_hourtype__constraint) is 33 characters
long. Actually if I change the table name to something shorter, the error
disappears, that's why I think that's exactly the problem.
I think this should be a quite common error in web2py applications using
Oracle. As a fix, I would suggest to drop the "constraint" part of the name
or abbreviate it (e.g. I always use "ck") and maybe use just one underscore
between the column and the last word.
Of course, I offer myself to take a look and provide a patch if that's ok
(although I'm worry to introduce a change that might affect all db drivers).
Just let me know if you're interest.

Mariano.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to