On 04/20/2016 07:35 AM, Piotr Dobrogost wrote:
Having this code

class Base(object):
     @declared_attr
     def __tablename__(cls):
     return '{0}s'.format(camel_case_to_name(cls.__name__))


class Model(Base):
     id = Column(Integer, Sequence(???, optional=True), primary_key=True)


is there a way to use name of Model's table inside declaration of "id"
column?

you can put "id" in declared_attr, should work:

class Model(Base):
    @declared_attr
    def id(cls):
        return Column(Integer, Sequence(cls.__tablename__ + "id_seq"), ...)


The other way would be to name the Sequence after the fact using the after_parent_attach event. This is how the naming convention system works which currently does not include Sequences but perhaps it should.





Regards,
Piotr Dobrogost

--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to