ClauseElement defaults should pre-execute for primary key columns
Issue #1335
resolved
from sqlalchemy import *
e = create_engine('sqlite://', echo=True)
m = MetaData(e)
t1 = Table('t1', m, Column('id', String, primary_key=True, default=func.now()))
m.create_all()
r = t1.insert().execute()
print r.last_inserted_ids()
should return the date from func.now(), not "1".
Comments (3)
-
reporter -
reporter this got fixed in 0.6 despite this ticket being forgotten.
-
reporter - removed milestone
Removing milestone: 0.6.0 (automated comment)
- Log in to comment
the attached patch cuts down significantly on the number of isinstance() calls within
_get_colparams()
and simplifies the logic, also allowing the above test to pass. this should be committed after thorough testing. more tests should be added to test/sql/defaults.py using the SQL capture fixtures to keep track of when SQL elements are pre-executed vs. inline executed, since the patch does change the behavior.