diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-12-21 10:16:31 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-12-21 13:41:25 -0500 |
commit | f472405e598ad3088308db8bfef2879a57b26025 (patch) | |
tree | fe650b30a2f04a8432a5cfba71231105edf95ca4 /lib/sqlalchemy/dialects | |
parent | d5bb919aa6d5b9961f85987dfaa58d5999910d15 (diff) | |
download | sqlalchemy-f472405e598ad3088308db8bfef2879a57b26025.tar.gz |
Don't select lastrowid for inline=True
- Fixed bug where SQL Server dialects would attempt to select the
last row identity for an INSERT from SELECT, failing in the case when
the SELECT has no rows. For such a statement,
the inline flag is set to True indicating no last primary key
should be fetched.
Change-Id: Ic40d56d9eadadc3024a4d71245f9eed4c420024a
Fixes: #3876
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r-- | lib/sqlalchemy/dialects/mssql/base.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 19558a2d6..1a1f7f06d 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -1022,7 +1022,8 @@ class MSExecutionContext(default.DefaultExecutionContext): else: self._enable_identity_insert = False - self._select_lastrowid = insert_has_sequence and \ + self._select_lastrowid = not self.compiled.inline and \ + insert_has_sequence and \ not self.compiled.returning and \ not self._enable_identity_insert and \ not self.executemany |