On 21.10.11 20:09, Michael Bayer wrote: > Because not every DB supports this (such as MySQL), we have not yet > implemented the feature of named column level constraints across the board > yet. We'd have to either implement it only for those DBs which support it, > or add exceptions to those which don't. The main job is a. figure out which > backends support it, and b. write some tests. > > Here's a patch: > > http://www.sqlalchemy.org/trac/ticket/2305 > > Table-level CHECK constraints do support generation of the "name" in all > cases, however. >
Thanks a lot, the patch works like charm > On Oct 21, 2011, at 7:10 PM, Mariano Mara wrote: > > > Hi all, > > the subject pretty much explains it all. Here's a complete example of the > > issue. Any tips will be appreciate. > > > > Regards, > > Mariano > > > > Python 2.7.2 (default, Oct 14 2011, 23:34:02) > > [GCC 4.5.2] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > >>>> import sqlalchemy > >>>> sqlalchemy.__version__ > > '0.7.3' > >>>> from sqlalchemy import Table, Column, Integer, create_engine, MetaData, > >>>> CheckConstraint > >>>> from sqlalchemy.orm import sessionmaker > >>>> session = sessionmaker() > >>>> Session = session() > >>>> engine = create_engine('postgresql://usr:passws@localhost/base', > >>>> echo=True) > >>>> Session.configure(bind=engine) > >>>> md = MetaData() > >>>> md.bind = engine > >>>> t = Table("test_ck", md, Column("id", Integer, primary_key=True), > > ... Column("id2", Integer, CheckConstraint("id2 between 1 and 10", > > name="my_constraint"))) > >>>> md.create_all(engine) > > 2011-10-21 19:53:45,523 INFO sqlalchemy.engine.base.Engine select version() > > 2011-10-21 19:53:45,523 INFO sqlalchemy.engine.base.Engine {} > > 2011-10-21 19:53:45,708 INFO sqlalchemy.engine.base.Engine select > > current_schema() > > 2011-10-21 19:53:45,709 INFO sqlalchemy.engine.base.Engine {} > > 2011-10-21 19:53:45,804 INFO sqlalchemy.engine.base.Engine select relname > > from pg_class c join pg_namespace n on n.oid=c.relnamespace where > > n.nspname=current_schema() and relname=%(name)s > > 2011-10-21 19:53:45,804 INFO sqlalchemy.engine.base.Engine {'name': > > u'test_ck'} > > 2011-10-21 19:53:46,168 INFO sqlalchemy.engine.base.Engine > > CREATE TABLE test_ck ( > > id SERIAL NOT NULL, > > id2 INTEGER CHECK (id2 between 1 and 10), > > PRIMARY KEY (id) > > ) > > > > > > 2011-10-21 19:53:46,168 INFO sqlalchemy.engine.base.Engine {} > > 2011-10-21 19:53:47,116 INFO sqlalchemy.engine.base.Engine COMMIT > >>>> > > > > -- > > You received this message because you are subscribed to the Google Groups > > "sqlalchemy" group. > > To post to this group, send email to sqlalchemy@googlegroups.com. > > To unsubscribe from this group, send email to > > sqlalchemy+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/sqlalchemy?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalchemy@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.