Does this assert always pass or not? In other words, does SQLAlchemy save the order (in generating INSERT queries) when adding new objects to session?
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm.session import sessionmaker
from sqlalchemy.engine import create_engine
from sqlalchemy.types import Integer
from sqlalchemy.schema import Column
engine = create_engine('sqlite://')
Base = declarative_base(engine)
Session = sessionmaker(bind=engine)
session = Session()
class Entity(Base):
__tablename__ = 'entity'
id = Column(Integer(), primary_key=True)
Entity.__table__.create(checkfirst=True)
first = Entity()
session.add(first)
second = Entity()
session.add(second)
session.commit()
assert second.id > first.id
print(first.id, second.id)
None, in production I'm using postgresql, sqlite is for testing.