summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-05-28 19:28:35 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-05-28 19:28:35 +0000
commit056bad48e2bc948a08621ab841fd882cb6934262 (patch)
tree2635059b149309c2ad7a648bfce13fd5844d8dc8 /lib/sqlalchemy/dialects
parentc07979e8d44a30fdf0ea73bc587aa05a52e9955a (diff)
parent77f1b7d236dba6b1c859bb428ef32d118ec372e6 (diff)
downloadsqlalchemy-056bad48e2bc948a08621ab841fd882cb6934262.tar.gz
Merge "callcount reductions and refinement for cached queries"
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py11
-rw-r--r--lib/sqlalchemy/dialects/oracle/cx_oracle.py44
-rw-r--r--lib/sqlalchemy/dialects/postgresql/psycopg2.py6
3 files changed, 23 insertions, 38 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index 3345d555f..5e0704597 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -1529,8 +1529,7 @@ class MSExecutionContext(default.DefaultExecutionContext):
elif (
self.isinsert or self.isupdate or self.isdelete
) and self.compiled.returning:
- fbcr = _cursor.FullyBufferedCursorFetchStrategy
- self._result_strategy = fbcr.create_from_buffer(
+ self.cursor_fetch_strategy = _cursor.FullyBufferedCursorFetchStrategy( # noqa
self.cursor, self.cursor.description, self.cursor.fetchall()
)
@@ -1571,14 +1570,6 @@ class MSExecutionContext(default.DefaultExecutionContext):
except Exception:
pass
- def get_result_cursor_strategy(self, result):
- if self._result_strategy:
- return self._result_strategy
- else:
- return super(MSExecutionContext, self).get_result_cursor_strategy(
- result
- )
-
class MSSQLCompiler(compiler.SQLCompiler):
returning_precedes_values = True
diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
index c61a1cc0a..4aae059dd 100644
--- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py
+++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
@@ -696,6 +696,27 @@ class OracleExecutionContext_cx_oracle(OracleExecutionContext):
self._generate_cursor_outputtype_handler()
+ def post_exec(self):
+ if self.compiled and self.out_parameters and self.compiled.returning:
+ # create a fake cursor result from the out parameters. unlike
+ # get_out_parameter_values(), the result-row handlers here will be
+ # applied at the Result level
+ returning_params = [
+ self.dialect._returningval(self.out_parameters["ret_%d" % i])
+ for i in range(len(self.out_parameters))
+ ]
+
+ fetch_strategy = _cursor.FullyBufferedCursorFetchStrategy(
+ self.cursor,
+ [
+ (getattr(col, "name", col.anon_label), None)
+ for col in self.compiled.returning
+ ],
+ initial_buffer=[tuple(returning_params)],
+ )
+
+ self.cursor_fetch_strategy = fetch_strategy
+
def create_cursor(self):
c = self._dbapi_connection.cursor()
if self.dialect.arraysize:
@@ -714,29 +735,6 @@ class OracleExecutionContext_cx_oracle(OracleExecutionContext):
for name in out_param_names
]
- def get_result_cursor_strategy(self, result):
- if self.compiled and self.out_parameters and self.compiled.returning:
- # create a fake cursor result from the out parameters. unlike
- # get_out_parameter_values(), the result-row handlers here will be
- # applied at the Result level
- returning_params = [
- self.dialect._returningval(self.out_parameters["ret_%d" % i])
- for i in range(len(self.out_parameters))
- ]
-
- return _cursor.FullyBufferedCursorFetchStrategy(
- result.cursor,
- [
- (getattr(col, "name", col.anon_label), None)
- for col in result.context.compiled.returning
- ],
- initial_buffer=[tuple(returning_params)],
- )
- else:
- return super(
- OracleExecutionContext_cx_oracle, self
- ).get_result_cursor_strategy(result)
-
class OracleDialect_cx_oracle(OracleDialect):
execution_ctx_cls = OracleExecutionContext_cx_oracle
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
index 9585dd467..a9408bcb0 100644
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
@@ -592,13 +592,9 @@ class PGExecutionContext_psycopg2(PGExecutionContext):
ident = "c_%s_%s" % (hex(id(self))[2:], hex(_server_side_id())[2:])
return self._dbapi_connection.cursor(ident)
- def get_result_cursor_strategy(self, result):
+ def post_exec(self):
self._log_notices(self.cursor)
- return super(PGExecutionContext, self).get_result_cursor_strategy(
- result
- )
-
def _log_notices(self, cursor):
# check also that notices is an iterable, after it's already
# established that we will be iterating through it. This is to get