Hi group,
I am tring to migrate from version 1.3.24 to 1.4.23 of SqlAlchemy, using PostgreSQL 10.
I found that the following code example works with 1.3, but triggers a traceback with 1.4.
import sqlalchemy
session = ...
metadata = sqlalchemy.MetaData()
s_items = sqlalchemy.Sequence('s_items', start=1, increment=1, metadata=metadata)
t_items = sqlalchemy.Table('t_items', metadata,
sqlalchemy.Column('id', sqlalchemy.Integer, s_items, primary_key = True),
)
metadata.drop_all(bind=session.bind)
metadata.create_all(bind=session.bind)
class Item(object):
pass
sqlalchemy.orm.mapper(Item, t_items)
item1 = Item()
item2 = Item()
session.add_all([item1, item2])
session.flush()
This code, with 1.4 only, triggers the following traceback:
Traceback (most recent call last):
File "C:\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1672, in _execute_context
dialect, self, conn, execution_options, *args, **kw
File "C:\Python36\lib\site-packages\sqlalchemy\engine\default.py", line 999, in _init_compiled
self._process_executemany_defaults()
File "C:\Python36\lib\site-packages\sqlalchemy\engine\default.py", line 1838, in _process_executemany_defaults
if c.default and c.default.is_scalar:
AttributeError: 'Sequence' object has no attribute 'is_scalar'
The only way I found to work around this with version 1.4, is to call flush after each single add:
item1 = Item()
session.add(item1)
session.flush()
item2 = Item()
session.add(item2)
session.flush()
But this seems weird, to me.
Am I doing anything wrong?
Thank you very much for any suggestion.
Francesca Leon