kvesteri / sqlalchemy-defaults

Smart SQLAlchemy defaults for lazy guys, like me.
Other
16 stars 7 forks source link

AttributeError: 'Sequence' object has no attribute 'arg' #5

Closed mkai closed 10 years ago

mkai commented 10 years ago

Hi, thanks for the library! I just started integrating it and had the above error with the Oracle dialect after passing in a Sequence object for default.

However, I need to pass in a sequence to simulate an auto-incrementing ID:

id = Column(Integer, default=Sequence('id_seq'), primary_key=True)

This fix solves the problem by explicity checking if column.default is aColumnDefault instance.

What do you think?

kvesteri commented 10 years ago

Are you using sequences in a right way? Looking at SA documentation http://docs.sqlalchemy.org/en/rel_0_9/dialects/oracle.html, I only see sequences used as positional column parameters:

t = Table('mytable', metadata,
      Column('id', Integer, Sequence('id_seq'), primary_key=True),
      autoload=True
)
mkai commented 10 years ago

You're right, I made a mistake specifying the Sequence using the default keyword argument. If I specify it positionally, however:

id = Column(Integer, Sequence('id_seq'), primary_key=True)

... the AttributeError still occurs.