changeset 1871 addresses postgres' generic association of INTEGER with SERIAL in the case of conflicting with SMALLINT. as far as autoincrementing behavior being optional, i have added ticket #303 since there have already been some other issues recently (regarding ms-sql) with a need for this feature.
also note that SA does not assume a primary key column is autoincrementing in the general case. while it tries to create columns with autoincrementing behavior (which for databases such as sqlite and mysql is usually implicit), if a row to be inserted already contains a primary key value, then SA will not attempt to use any kind of identity-generating feature of the database (either sending no value in for autoincrement behavior, or by calling a sequence/column default explicitly). so this issue is limited strictly to DDL generation. as far as supporting legacy databases and unusual/custom database schema features in general, SA does not aim to be a complete DDL generation solution; the table creation/reflection capabilities are convenience features only, and we arent ever going to get into the myriad of custom keywords and extensions used in schema creation...a real DDL is a lot more appropriate for that (also for a legacy database, why would you be generating new DDL anyway, but thats besides the point). however as we are still in our first year of release and are still only in the 0.2 series, i wouldnt construe the lack of a particular feature as an implicit statement of SA's opposition to such a feature....if you read through the mailing list and the trac tickets youll see that most proposed features (such as the one you propose here) get implemented. On Sep 18, 2006, at 5:32 PM, Joe wrote: > Hi, > > I believe SQLAlchemy's behavior when creating primary_key integer > columns is incorrect, at least against PostgreSQL, but before > opening a > ticket I'd like to hear what others think about it. > > If you define a column as Integer or SmallInteger (Smallinteger) and > primary_key=True, SA assumes it requires an associated SQL sequence, > i.e., a SERIAL (or auto-increment) datatype. In fact, in the latter > case, it overrides the SmallInteger specification and creates an > Integer > column because (at least in PG) SERIAL implies INTEGER. > > I have at least two tables in an existing database that have SMALLINT > primary keys and the values are *not* sequential (one of them is a > calendar year and not all years are logged in the table, the other has > arbitrary codes). I also have a table that is one-to-one with the > principal table (which does have a SERIAL key), but for operational > reasons (it keeps track of activity against the other) it's kept > separate from it, so it's INTEGER primary key does not have an > associated sequence (except by derivation). > > I don't think my examples are unique. I'm pretty sure there are many > systems where identifiers are assigned non-sequentially, e.g., bank > account numbers with check digits. Granted that these will tend to be > legacy systems, but I thought SA was supposed to cater to those. > > Joe > > > ---------------------------------------------------------------------- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys -- and earn > cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Sqlalchemy-users mailing list > Sqlalchemy-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users