On Dec 18, 2010, at 2:45 PM, Lenza McElrath wrote: > I am writing a system where I want my DB primary keys to be represented in > the system by a type other than an integer. I have run into several issues > with this: > > 1) I tried using a TypeDecorator, but SQLAlchemy does not like this. Seems > like the main problem is the auto_increment is not set on the column when > creating the table, but I think I ran into other issues even after making the > table by hand. This issue was discussed here: > http://groups.google.com/group/sqlalchemy/browse_thread/thread/4b13261da8c4c932/d0b84b4c14a6645e. > However, specifying a Sequence does not solve the problem for me (I'm using > MySQL).
Its using isinstance(type, Integer) so in this case possibly adding Integer as a mixin, though the isinstance() check should probably be changed to use _type_affinity. ticket #2005 is added. Targeted at 0.7 for starters, would need further research to ensure its backwards compatible for 0.6.6. > > So, I resorted to using a straight Type, and have a couple of other problems: > > 2) After session.flush() the ID is an integer, not the type returned from my > result processor. After a query the types are correct. ResultProxy doesn't check for result processors when using cursor.lastrowid. Ticket #2006 is added. This one stays at 0.7 as we have been refactoring the default dialect to optimize things like this. > > 3) When doing queries, filters on the ID are not passed through the bind > process, so they return no results. This broke after 0.6beta1. Don't have time to check this right now. ticket #2007 is added to create a single test case. Bugs in expression coercion are of highest priority so this is targeted at 0.6.6 - though the usage of Integer instead of TypeDecorator is probably the cause here. Direct subclassing of the built in types is not the usual way to do things. > > I have created a test case the illustrates all of these issues here: > http://pastebin.com/CnAmptck for now I'd recommend using class-level descriptors to proxy the integer "ID" value to a string on the Python side. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.