ClauseElement defaults should pre-execute for primary key columns

Issue #1335 resolved
Mike Bayer repo owner created an issue
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)

  1. Mike Bayer reporter

    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.

  2. Log in to comment