Yes, I do want to exclude it all together. But we are creating the
database from a createall() call. So if leave it out of the SA schema
definition, it will also disappear in the CREATE TABLE statements.
Is there any way, whatsoever, to included them in the SA-generated
CREATE TABLE DDL without having them in the SA-generated INSERTs/UPDATEs?
Op 21/12/2010 15:59, Michael Bayer schreef:
On Dec 21, 2010, at 8:36 AM, tim wrote:
Hi,
I have some meta-data columns in my schema. How can I make sure they
are not part of the SELECT, INSERT and UPDATE statements SQLAlchemy is
doing in the background?
I tried:
Column('lastUpdate', DateTime, DefaultClause('CURRENT_TIMESTAMP'),
nullable=False), # for Nebula's Syncer
along with
mapper(Location, locations, version_id_col=locations.c.STAMP,
exclude_properties=['lastUpdate'], properties = {
'site': relation(Site, backref='locations'),
})
But the lastUpdate column still turns up in the SQL it is executing,
and what's worse, without using it's default value!
Would anyone please help me out?
If the column has an existing server-side default on it, you'd want to specify
server_default=FetchedValue() :
http://www.sqlalchemy.org/docs/core/schema.html#triggered-columns
If you want to "exclude" the column from being used in your application in any way,
simply don't place it in the Table definition. If you're using reflection, you could use the
"include_columns" list on Table to specify which columns you want.
"exclude_properties" in the ORM prevents those columns from being mapped, but
doesn't prevent the core table level functionality from dealing with this column so
that's why you need to ensure the Table metadata is correct.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.