warp wrote:
>
> Hello,
>
> I wanted to use a custom type as an auto-increment / primary key in
> one of my
> tables. The type is made like this:
>
> class BoxId (sqlalchemy.types.TypeDecorator):
> impl = sqlalchemy.types.Integer
>
> Using it in a table like this:
>
> box = Table ('box', metadata,
> Column ('id', BoxId, primary_key=True),
> Column ('catalog', Unicode(64)),
> )
>
> But having the table defined like that raises an exception when trying
> to insert
> values. I'm using postgres and it looks like
> sqlalchemy.databases.postgres.PGDefaultRunner.get_column_default ()
> deals
> with auto-increments and is specifically looking for an
> sqlalchemy.types.Integer.
> I expected sqlalchemy would treat a type created the way I did above
> more or less
> like an integer, because of the impl attribute.
>
> Is this a bug in either sqlalchemy or specifically the postgres part?
> Or is this just
> not supposed to work like this? (I'm fairly new to sqlalchemy :)
>
> Thank you for any help you can give me.
the "Integer" detection should probably detect the "Integer" ness of the
column, but for now you can just define the sequence explicitly:
Column('mycolumn', MyType, Sequence('mycolumn_id_seq'), primary_key=True)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---