Thanks for the quick reply.
If I modify the name of the sequence in the test, it reproduces what I have
experienced.
When I check the details on the sequence in postgres, there is no table owner
or column specified by the sequence 'test_user_id_seq'.. and I would expect to
see both tables `a` and `b`.
class IdMixin(object):
id = Column(Integer, Sequence('test_user_id_seq', start=10000),
primary_key=True)
I will write a complete self contained test, that anyone can run. But wanted to
give my immediate feedback.
Thanks so much,
Mat
On Jun 26, 2013, at 6:37 PM, Michael Bayer <[email protected]> wrote:
>
> On Jun 26, 2013, at 12:02 PM, Mat Mathews <[email protected]> wrote:
>
>> I would like to do something like this:
>>
>> class User(object):
>> id = Column(Integer, Sequence('user_id_seq', start=10000),
>> primary_key=True)
>>
>> This does work, and emits the CREATE SEQUENCE, but does not set the owned
>> table or the column to user.id
>
> I'm not able to reproduce, even assigning the same sequence name to two
> different tables simultaneously produces the correct result. Can you modify
> the test below to illustrate your issue?
>
> from sqlalchemy import *
> from sqlalchemy.orm import *
> from sqlalchemy.ext.declarative import declarative_base, declared_attr
>
> Base = declarative_base()
>
> class IdMixin(object):
> id = Column(Integer, Sequence('user_id_seq', start=10000),
> primary_key=True)
>
> class A(IdMixin, Base):
> __tablename__ = 'a'
>
> class B(IdMixin, Base):
> __tablename__ = 'b'
>
> e = create_engine("postgresql://scott:tiger@localhost/test", echo=True)
> Base.metadata.drop_all(e)
> Base.metadata.create_all(e)
>
> sess = Session(e)
>
> a1 = A()
> sess.add(a1)
>
> b1 = B()
> sess.add(b1)
> sess.commit()
>
> assert a1.id == 10000
> assert b1.id == 10001
>
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.