On Jan 26, 2006, at 8:01 PM, Nicholas Wieland wrote:

Serial in fact is a an int(4) type with a default to nextval (table_column_seq):

Test=# \d Test
                                   Table "public.test"
 Column |            Type             |                     Modifiers
--------+----------------------------- +---------------------------------------------------
 id     | integer                     | not null default
nextval('test_id_seq'::regclass)

You can fetch this information with

Test=#  select column_default from information_schema.columns where
column_name='id';

          column_default
----------------------------------
 nextval('test_id_seq'::regclass)
(1 row)

IMHO using default is the best option

OK, if i did some thing to parse out the "default" from that, it wouldnt be "SERIAL", it would just be a default object with the value sitting inside of it (also what is ::regclass, does that have to be filtered out ?). Also, when you go to INSERT a row, SA is giong to explicitly run all the defaults as separate queries beforehand, as opposed to letting the database run them automatically, since thats what a "default" does. the explicit behavior is needed for at least the primary key columns, as they are often needed right after INSERT (and with rowids turned off, postgres/psycopg gives you no way of getting at a recently inserted row otherwise). it could be modified for non-primary-key columns to not run the default explicitly beforehand....any opinions ?



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to