As an addition to the previous mail: I am going full circles here.

If I add:
```
    def get_insert_default(self, column):
        if (column.primary_key and column is 
column.table._autoincrement_column and
                column.default is None or
                (isinstance(column.default, schema.Sequence) and 
column.default.optional)):
                    return 0
        return super().get_insert_default(column)
```
it properly puts 0 into the inserts (so far so good, though I am not sure 
why it thinks it needs to insert the column at all).

If I then set `postfetch_lastrowid` to True it properly runs 
`get_lastrowid` after the insert and the SERIAL case is fine. But by 
setting `postfetch_lastrowid` to True it also stops generting sequence 
values for primary keys with explicit sequences and instead inlines them 
into the columns as `table_seq.NEXTVAL`, which is okay for the insert part, 
but now I have no way of getting the value :/

So to summarize:

for SERIAL I need:
 * Insert the column with 0 or not at all
 * run `get_lastrowid` by settings `postfetch_lastrowid` to True or 
manually from `post_exec`

for Sequences I need:
 * Prefetch the sequence value with a separate statement so SA knows the 
value and insert that value into the insert

And those two options should both be able to work at the same time without 
conflicting :D

Cheers,
Florian

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to