- changed status to resolved
failing insert from select when sequence present
Issue #3877
resolved
from sqlalchemy import *
m = MetaData()
t1 = Table(
't', m,
Column('id', Integer, Sequence('id_seq'), primary_key=True),
Column('data', String)
)
t2 = Table(
't2', m,
Column('id', Integer),
Column('data', String)
)
stmt = t1.insert().from_select(('data', ), select([t1.c.data]))
from sqlalchemy.dialects import postgresql
print stmt.compile(dialect=postgresql.dialect())
#!
sqlalchemy.exc.InvalidRequestError: This Sequence cannot be used directly as a column expression. Use func.next_value(sequence) to produce a 'next value' function that's usable as a column element.
Comments (1)
-
reporter - Log in to comment
Call nextval() on sequence when doing INSERT from SELECT
Fixed bug where an INSERT from SELECT where the source table contains an autoincrementing Sequence would fail to compile correctly.
Change-Id: I41eb9f65789a4007712ae61ed5fa23a9839a5128 Fixes:
#3877→ <<cset d5bb919aa6d5>>