Skip to content

Commit bd516fc

Browse files
authored
Merge pull request #274 fix keep_in_cache flag alg
2 parents 71a97cd + 5089efc commit bd516fc

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

ydb/_tx_ctx_impl.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def _construct_tx_settings(tx_state):
109109
def execute_request_factory(session_state, tx_state, query, parameters, commit_tx, settings):
110110
data_query, query_id = session_state.lookup(query)
111111
parameters_types = {}
112-
keep_in_cache = False
112+
113113
if query_id is not None:
114114
query_pb = _apis.ydb_table.Query(id=query_id)
115115
parameters_types = data_query.parameters_types
@@ -119,20 +119,26 @@ def execute_request_factory(session_state, tx_state, query, parameters, commit_t
119119
yql_text = data_query.yql_text
120120
parameters_types = data_query.parameters_types
121121
elif isinstance(query, types.DataQuery):
122-
if settings is not None and hasattr(settings, "keep_in_cache"):
123-
keep_in_cache = settings.keep_in_cache
124-
else:
125-
# that is an instance of a data query and we don't know query id for id.
126-
# so let's prepare it to keep in cache
127-
keep_in_cache = True
128122
yql_text = query.yql_text
129123
parameters_types = query.parameters_types
130124
else:
131125
yql_text = query
132126
query_pb = _apis.ydb_table.Query(yql_text=yql_text)
133127
request = _apis.ydb_table.ExecuteDataQueryRequest(parameters=convert.parameters_to_pb(parameters_types, parameters))
128+
129+
if query_id is not None:
130+
# SDK not send query text and nothing save to cache
131+
keep_in_cache = False
132+
elif settings is not None and hasattr(settings, "keep_in_cache"):
133+
keep_in_cache = settings.keep_in_cache
134+
elif parameters:
135+
keep_in_cache = True
136+
else:
137+
keep_in_cache = False
138+
134139
if keep_in_cache:
135140
request.query_cache_policy.keep_in_cache = True
141+
136142
request.query.MergeFrom(query_pb)
137143
tx_control = _apis.ydb_table.TransactionControl()
138144
tx_control.commit_tx = commit_tx

0 commit comments

Comments
 (0)