I'm fairly new to SQLAlchemy so I want to double-check this before filing
what I think is a bug against SQLAlchemy 0.7.
Consider a plain, declarative-mapped object:
class Table(Base):
__tablename__ = 'table'
id = Column(Integer, primary_key=True, nullable=False)
Now consider code to retrieve this item:
function test_identity_map():
db=Session() # scoped_session(sessionmaker(...))
for x in range(5):
print "%d: %s" % (x, db.query(Table).get(1))
If I create a MSSQL engine with a connection string prefix of
'mssql+pyodbc://', set 'echo' to True, populate the table with a single item
with an id of '1' and call the test function, five separate SQL statements
are echoed to the console. However, if I repeat the process using the SQLite
in-memory engine ('sqlite:///:memory:'), only one SQL statement is echoed to
the console.
I believe the mssql/pyodbc engine is not caching the item in the identity
map. Could it be that the behaviour of 'echo=True' when supplied to
create_engine differs between engine types, such that SQL is always echoed
for the mssql engine, and the item is retrieved from the identity map anyway
(I haven't checked whether the calls are actually emitted to the database,
but the timing information leads me to believe they are)? Or could there be
some other configuration setting I've overlooked? Could it be that I'm using
FreeTDS on linux for the ODBC layer? Stores/retrievals otherwise work just
fine. I've looked through the dialect code and can't find anything that
might affect this. Am I missing something? I'm going to dig into the session
identity map code now to see what I can find, but I'd appreciate it if
anyone already knows where I'm going wrong.
Many thanks,
Simon.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/lPYhk2PpHgAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.