- changed milestone to 1.2
get eager_defaults to use RETURNING for ad-hoc SQL, not just column defaults
Issue #3401
new
this might take some rearrangement of persistence logic to work out, but this should work:
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
value = Column(Integer) #, server_default=FetchedValue())
__mapper_args__ = {'eager_defaults': True}
e = create_engine("postgresql://scott:tiger@localhost/test", echo=True)
Base.metadata.create_all(e)
s = Session(e)
a1 = A(value=literal_column("1 + 1"))
s.add(a1)
s.flush()
# does a fetch, unless the server_default above is set.
print a1.value
also eager_defaults should have a section in the mapper docs describing it beyond just the docstring, now that returning makes it useful.
Comments (2)
-
reporter -
reporter - changed milestone to 1.4
- marked as enhancement
nice to have but not critical
- Log in to comment