sqlalchemy-cratedb 0.38.0.dev0__py3-none-any.whl → 0.40.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,7 +22,7 @@
22
22
  from .compat.api13 import monkeypatch_add_exec_driver_sql
23
23
  from .dialect import dialect
24
24
  from .predicate import match
25
- from .sa_version import SA_1_4, SA_2_0, SA_VERSION
25
+ from .sa_version import SA_1_4, SA_VERSION
26
26
  from .support import insert_bulk
27
27
  from .type.array import ObjectArray
28
28
  from .type.geo import Geopoint, Geoshape
@@ -34,7 +34,8 @@ if SA_VERSION < SA_1_4:
34
34
  import warnings
35
35
 
36
36
  # SQLAlchemy 1.3 is effectively EOL.
37
- SA13_DEPRECATION_WARNING = textwrap.dedent("""
37
+ SA13_DEPRECATION_WARNING = textwrap.dedent(
38
+ """
38
39
  WARNING: SQLAlchemy 1.3 is effectively EOL.
39
40
 
40
41
  SQLAlchemy 1.3 is EOL since 2023-01-27.
@@ -43,8 +44,9 @@ if SA_VERSION < SA_1_4:
43
44
 
44
45
  - https://docs.sqlalchemy.org/en/14/changelog/migration_14.html
45
46
  - https://docs.sqlalchemy.org/en/20/changelog/migration_20.html
46
- """.lstrip("\n"))
47
- warnings.warn(message=SA13_DEPRECATION_WARNING, category=DeprecationWarning)
47
+ """.lstrip("\n")
48
+ )
49
+ warnings.warn(message=SA13_DEPRECATION_WARNING, category=DeprecationWarning, stacklevel=2)
48
50
 
49
51
  # SQLAlchemy 1.3 does not have the `exec_driver_sql` method, so add it.
50
52
  monkeypatch_add_exec_driver_sql()
@@ -59,4 +61,5 @@ __all__ = [
59
61
  ObjectType,
60
62
  match,
61
63
  knn_match,
64
+ insert_bulk,
62
65
  ]
@@ -40,7 +40,6 @@ from sqlalchemy.sql import Select
40
40
  from sqlalchemy.sql import select as original_select
41
41
  from sqlalchemy.util import immutabledict
42
42
 
43
-
44
43
  # `_distill_params_20` copied from SA14's `sqlalchemy.engine.{base,util}`.
45
44
  _no_tuple = ()
46
45
  _no_kw = immutabledict()
@@ -52,9 +51,7 @@ def _distill_params_20(params):
52
51
  elif isinstance(params, list):
53
52
  # collections_abc.MutableSequence): # avoid abc.__instancecheck__
54
53
  if params and not isinstance(params[0], (collections_abc.Mapping, tuple)):
55
- raise exc.ArgumentError(
56
- "List argument must consist only of tuples or dictionaries"
57
- )
54
+ raise exc.ArgumentError("List argument must consist only of tuples or dictionaries")
58
55
 
59
56
  return (params,), _no_kw
60
57
  elif isinstance(
@@ -74,8 +71,7 @@ def exec_driver_sql(self, statement, parameters=None, execution_options=None):
74
71
  """
75
72
  if execution_options is not None:
76
73
  raise ValueError(
77
- "SA13 backward-compatibility: "
78
- "`exec_driver_sql` does not support `execution_options`"
74
+ "SA13 backward-compatibility: " "`exec_driver_sql` does not support `execution_options`"
79
75
  )
80
76
  args_10style, kwargs_10style = _distill_params_20(parameters)
81
77
  return self.execute(statement, *args_10style, **kwargs_10style)
@@ -106,12 +102,11 @@ def select_sa14(*columns, **kw) -> Select:
106
102
  Derived from https://github.com/sqlalchemy/alembic/blob/b1fad6b6/alembic/util/sqla_compat.py#L557-L558
107
103
 
108
104
  sqlalchemy.exc.ArgumentError: columns argument to select() must be a Python list or other iterable
109
- """
105
+ """ # noqa: E501
110
106
  if isinstance(columns, tuple) and isinstance(columns[0], list):
111
107
  if "whereclause" in kw:
112
108
  raise ValueError(
113
- "SA13 backward-compatibility: "
114
- "`whereclause` is both in kwargs and columns tuple"
109
+ "SA13 backward-compatibility: " "`whereclause` is both in kwargs and columns tuple"
115
110
  )
116
111
  columns, whereclause = columns
117
112
  kw["whereclause"] = whereclause
@@ -153,4 +148,5 @@ def connectionfairy_driver_connection_sa14(self):
153
148
 
154
149
  def monkeypatch_add_connectionfairy_driver_connection():
155
150
  import sqlalchemy.pool.base
151
+
156
152
  sqlalchemy.pool.base._ConnectionFairy.driver_connection = connectionfairy_driver_connection_sa14
@@ -21,18 +21,21 @@
21
21
 
22
22
  import sqlalchemy as sa
23
23
  from sqlalchemy.dialects.postgresql.base import PGCompiler
24
- from sqlalchemy.sql.crud import (REQUIRED, _create_bind_param,
25
- _extend_values_for_multiparams,
26
- _get_multitable_params,
27
- _get_stmt_parameters_params,
28
- _key_getters_for_crud_column, _scan_cols,
29
- _scan_insert_from_select_cols)
24
+ from sqlalchemy.sql.crud import (
25
+ REQUIRED,
26
+ _create_bind_param,
27
+ _extend_values_for_multiparams,
28
+ _get_multitable_params,
29
+ _get_stmt_parameters_params,
30
+ _key_getters_for_crud_column,
31
+ _scan_cols,
32
+ _scan_insert_from_select_cols,
33
+ )
30
34
 
31
35
  from sqlalchemy_cratedb.compiler import CrateCompiler
32
36
 
33
37
 
34
38
  class CrateCompilerSA10(CrateCompiler):
35
-
36
39
  def returning_clause(self, stmt, returning_cols):
37
40
  """
38
41
  Generate RETURNING clause, PostgreSQL-compatible.
@@ -46,70 +49,58 @@ class CrateCompilerSA10(CrateCompiler):
46
49
  """
47
50
 
48
51
  # [10] CrateDB patch.
49
- if not update_stmt.parameters and \
50
- not hasattr(update_stmt, '_crate_specific'):
52
+ if not update_stmt.parameters and not hasattr(update_stmt, "_crate_specific"):
51
53
  return super().visit_update(update_stmt, **kw)
52
54
 
53
55
  self.isupdate = True
54
56
 
55
57
  extra_froms = update_stmt._extra_froms
56
58
 
57
- text = 'UPDATE '
59
+ text = "UPDATE "
58
60
 
59
61
  if update_stmt._prefixes:
60
- text += self._generate_prefixes(update_stmt,
61
- update_stmt._prefixes, **kw)
62
+ text += self._generate_prefixes(update_stmt, update_stmt._prefixes, **kw)
62
63
 
63
- table_text = self.update_tables_clause(update_stmt, update_stmt.table,
64
- extra_froms, **kw)
64
+ table_text = self.update_tables_clause(update_stmt, update_stmt.table, extra_froms, **kw)
65
65
 
66
66
  dialect_hints = None
67
67
  if update_stmt._hints:
68
- dialect_hints, table_text = self._setup_crud_hints(
69
- update_stmt, table_text
70
- )
68
+ dialect_hints, table_text = self._setup_crud_hints(update_stmt, table_text)
71
69
 
72
70
  # [10] CrateDB patch.
73
71
  crud_params = _get_crud_params(self, update_stmt, **kw)
74
72
 
75
73
  text += table_text
76
74
 
77
- text += ' SET '
75
+ text += " SET "
78
76
 
79
77
  # [10] CrateDB patch begin.
80
- include_table = \
81
- extra_froms and self.render_table_with_column_in_update_from
78
+ include_table = extra_froms and self.render_table_with_column_in_update_from
82
79
 
83
80
  set_clauses = []
84
81
 
85
82
  for k, v in crud_params:
86
- clause = k._compiler_dispatch(self,
87
- include_table=include_table) + \
88
- ' = ' + v
83
+ clause = k._compiler_dispatch(self, include_table=include_table) + " = " + v
89
84
  set_clauses.append(clause)
90
85
 
91
86
  for k, v in update_stmt.parameters.items():
92
- if isinstance(k, str) and '[' in k:
87
+ if isinstance(k, str) and "[" in k:
93
88
  bindparam = sa.sql.bindparam(k, v)
94
- set_clauses.append(k + ' = ' + self.process(bindparam))
89
+ set_clauses.append(k + " = " + self.process(bindparam))
95
90
 
96
- text += ', '.join(set_clauses)
91
+ text += ", ".join(set_clauses)
97
92
  # [10] CrateDB patch end.
98
93
 
99
94
  if self.returning or update_stmt._returning:
100
95
  if not self.returning:
101
96
  self.returning = update_stmt._returning
102
97
  if self.returning_precedes_values:
103
- text += " " + self.returning_clause(
104
- update_stmt, self.returning)
98
+ text += " " + self.returning_clause(update_stmt, self.returning)
105
99
 
106
100
  if extra_froms:
107
101
  extra_from_text = self.update_from_clause(
108
- update_stmt,
109
- update_stmt.table,
110
- extra_froms,
111
- dialect_hints,
112
- **kw)
102
+ update_stmt, update_stmt.table, extra_froms, dialect_hints, **kw
103
+ )
113
104
  if extra_from_text:
114
105
  text += " " + extra_from_text
115
106
 
@@ -123,8 +114,7 @@ class CrateCompilerSA10(CrateCompiler):
123
114
  text += " " + limit_clause
124
115
 
125
116
  if self.returning and not self.returning_precedes_values:
126
- text += " " + self.returning_clause(
127
- update_stmt, self.returning)
117
+ text += " " + self.returning_clause(update_stmt, self.returning)
128
118
 
129
119
  return text
130
120
 
@@ -149,8 +139,7 @@ def _get_crud_params(compiler, stmt, **kw):
149
139
  # compiled params - return binds for all columns
150
140
  if compiler.column_keys is None and stmt.parameters is None:
151
141
  return [
152
- (c, _create_bind_param(compiler, c, None, required=True))
153
- for c in stmt.table.columns
142
+ (c, _create_bind_param(compiler, c, None, required=True)) for c in stmt.table.columns
154
143
  ]
155
144
 
156
145
  if stmt._has_multi_parameters:
@@ -22,18 +22,21 @@
22
22
  import sqlalchemy as sa
23
23
  from sqlalchemy.dialects.postgresql.base import PGCompiler
24
24
  from sqlalchemy.sql import selectable
25
- from sqlalchemy.sql.crud import (REQUIRED, _create_bind_param,
26
- _extend_values_for_multiparams,
27
- _get_stmt_parameter_tuples_params,
28
- _get_update_multitable_params,
29
- _key_getters_for_crud_column, _scan_cols,
30
- _scan_insert_from_select_cols)
25
+ from sqlalchemy.sql.crud import (
26
+ REQUIRED,
27
+ _create_bind_param,
28
+ _extend_values_for_multiparams,
29
+ _get_stmt_parameter_tuples_params,
30
+ _get_update_multitable_params,
31
+ _key_getters_for_crud_column,
32
+ _scan_cols,
33
+ _scan_insert_from_select_cols,
34
+ )
31
35
 
32
36
  from sqlalchemy_cratedb.compiler import CrateCompiler
33
37
 
34
38
 
35
39
  class CrateCompilerSA14(CrateCompiler):
36
-
37
40
  def returning_clause(self, stmt, returning_cols):
38
41
  """
39
42
  Generate RETURNING clause, PostgreSQL-compatible.
@@ -41,15 +44,11 @@ class CrateCompilerSA14(CrateCompiler):
41
44
  return PGCompiler.returning_clause(self, stmt, returning_cols)
42
45
 
43
46
  def visit_update(self, update_stmt, **kw):
44
-
45
- compile_state = update_stmt._compile_state_factory(
46
- update_stmt, self, **kw
47
- )
47
+ compile_state = update_stmt._compile_state_factory(update_stmt, self, **kw)
48
48
  update_stmt = compile_state.statement
49
49
 
50
50
  # [14] CrateDB patch.
51
- if not compile_state._dict_parameters and \
52
- not hasattr(update_stmt, '_crate_specific'):
51
+ if not compile_state._dict_parameters and not hasattr(update_stmt, "_crate_specific"):
53
52
  return super().visit_update(update_stmt, **kw)
54
53
 
55
54
  toplevel = not self.stack
@@ -64,9 +63,7 @@ class CrateCompilerSA14(CrateCompiler):
64
63
  if is_multitable:
65
64
  # main table might be a JOIN
66
65
  main_froms = set(selectable._from_objects(update_stmt.table))
67
- render_extra_froms = [
68
- f for f in extra_froms if f not in main_froms
69
- ]
66
+ render_extra_froms = [f for f in extra_froms if f not in main_froms]
70
67
  correlate_froms = main_froms.union(extra_froms)
71
68
  else:
72
69
  render_extra_froms = []
@@ -83,23 +80,17 @@ class CrateCompilerSA14(CrateCompiler):
83
80
  text = "UPDATE "
84
81
 
85
82
  if update_stmt._prefixes:
86
- text += self._generate_prefixes(
87
- update_stmt, update_stmt._prefixes, **kw
88
- )
83
+ text += self._generate_prefixes(update_stmt, update_stmt._prefixes, **kw)
89
84
 
90
85
  table_text = self.update_tables_clause(
91
86
  update_stmt, update_stmt.table, render_extra_froms, **kw
92
87
  )
93
88
 
94
89
  # [14] CrateDB patch.
95
- crud_params = _get_crud_params(
96
- self, update_stmt, compile_state, **kw
97
- )
90
+ crud_params = _get_crud_params(self, update_stmt, compile_state, **kw)
98
91
 
99
92
  if update_stmt._hints:
100
- dialect_hints, table_text = self._setup_crud_hints(
101
- update_stmt, table_text
102
- )
93
+ dialect_hints, table_text = self._setup_crud_hints(update_stmt, table_text)
103
94
  else:
104
95
  dialect_hints = None
105
96
 
@@ -112,23 +103,22 @@ class CrateCompilerSA14(CrateCompiler):
112
103
  text += " SET "
113
104
 
114
105
  # [14] CrateDB patch begin.
115
- include_table = \
116
- extra_froms and self.render_table_with_column_in_update_from
106
+ include_table = extra_froms and self.render_table_with_column_in_update_from
117
107
 
118
108
  set_clauses = []
119
109
 
120
- for c, expr, value in crud_params:
110
+ for c, expr, value in crud_params: # noqa: B007
121
111
  key = c._compiler_dispatch(self, include_table=include_table)
122
- clause = key + ' = ' + value
112
+ clause = key + " = " + value
123
113
  set_clauses.append(clause)
124
114
 
125
115
  for k, v in compile_state._dict_parameters.items():
126
- if isinstance(k, str) and '[' in k:
116
+ if isinstance(k, str) and "[" in k:
127
117
  bindparam = sa.sql.bindparam(k, v)
128
- clause = k + ' = ' + self.process(bindparam)
118
+ clause = k + " = " + self.process(bindparam)
129
119
  set_clauses.append(clause)
130
120
 
131
- text += ', '.join(set_clauses)
121
+ text += ", ".join(set_clauses)
132
122
  # [14] CrateDB patch end.
133
123
 
134
124
  if self.returning or update_stmt._returning:
@@ -139,19 +129,13 @@ class CrateCompilerSA14(CrateCompiler):
139
129
 
140
130
  if extra_froms:
141
131
  extra_from_text = self.update_from_clause(
142
- update_stmt,
143
- update_stmt.table,
144
- render_extra_froms,
145
- dialect_hints,
146
- **kw
132
+ update_stmt, update_stmt.table, render_extra_froms, dialect_hints, **kw
147
133
  )
148
134
  if extra_from_text:
149
135
  text += " " + extra_from_text
150
136
 
151
137
  if update_stmt._where_criteria:
152
- t = self._generate_delimited_and_list(
153
- update_stmt._where_criteria, **kw
154
- )
138
+ t = self._generate_delimited_and_list(update_stmt._where_criteria, **kw)
155
139
  if t:
156
140
  text += " WHERE " + t
157
141
 
@@ -159,9 +143,7 @@ class CrateCompilerSA14(CrateCompiler):
159
143
  if limit_clause:
160
144
  text += " " + limit_clause
161
145
 
162
- if (
163
- self.returning or update_stmt._returning
164
- ) and not self.returning_precedes_values:
146
+ if (self.returning or update_stmt._returning) and not self.returning_precedes_values:
165
147
  text += " " + self.returning_clause(
166
148
  update_stmt, self.returning or update_stmt._returning
167
149
  )
@@ -232,14 +214,10 @@ def _get_crud_params(compiler, stmt, compile_state, **kw):
232
214
  parameters = {}
233
215
  elif stmt_parameter_tuples:
234
216
  parameters = dict(
235
- (_column_as_key(key), REQUIRED)
236
- for key in compiler.column_keys
237
- if key not in spd
217
+ (_column_as_key(key), REQUIRED) for key in compiler.column_keys if key not in spd
238
218
  )
239
219
  else:
240
- parameters = dict(
241
- (_column_as_key(key), REQUIRED) for key in compiler.column_keys
242
- )
220
+ parameters = dict((_column_as_key(key), REQUIRED) for key in compiler.column_keys)
243
221
 
244
222
  # create a list of column assignment clauses as tuples
245
223
  values = []
@@ -340,9 +318,9 @@ def _get_crud_params(compiler, stmt, compile_state, **kw):
340
318
  kw,
341
319
  )
342
320
  elif (
343
- not values
344
- and compiler.for_executemany # noqa: W503
345
- and compiler.dialect.supports_default_metavalue # noqa: W503
321
+ not values
322
+ and compiler.for_executemany # noqa: W503
323
+ and compiler.dialect.supports_default_metavalue # noqa: W503
346
324
  ):
347
325
  # convert an "INSERT DEFAULT VALUES"
348
326
  # into INSERT (firstcol) VALUES (DEFAULT) which can be turned
@@ -19,6 +19,8 @@
19
19
  # with Crate these terms will supersede the license and you may use the
20
20
  # software solely pursuant to the terms of the relevant commercial agreement.
21
21
 
22
+ # ruff: noqa: S101 Use of `assert` detected
23
+
22
24
  from typing import Any, Dict, List, MutableMapping, Optional, Tuple, Union
23
25
 
24
26
  import sqlalchemy as sa
@@ -26,14 +28,20 @@ from sqlalchemy import ColumnClause, ValuesBase, cast, exc
26
28
  from sqlalchemy.sql import dml
27
29
  from sqlalchemy.sql.base import _from_objects
28
30
  from sqlalchemy.sql.compiler import SQLCompiler
29
- from sqlalchemy.sql.crud import (REQUIRED, _as_dml_column, _create_bind_param,
30
- _CrudParamElement, _CrudParams,
31
- _extend_values_for_multiparams,
32
- _get_stmt_parameter_tuples_params,
33
- _get_update_multitable_params,
34
- _key_getters_for_crud_column, _scan_cols,
35
- _scan_insert_from_select_cols,
36
- _setup_delete_return_defaults)
31
+ from sqlalchemy.sql.crud import (
32
+ REQUIRED,
33
+ _as_dml_column,
34
+ _create_bind_param,
35
+ _CrudParamElement,
36
+ _CrudParams,
37
+ _extend_values_for_multiparams,
38
+ _get_stmt_parameter_tuples_params,
39
+ _get_update_multitable_params,
40
+ _key_getters_for_crud_column,
41
+ _scan_cols,
42
+ _scan_insert_from_select_cols,
43
+ _setup_delete_return_defaults,
44
+ )
37
45
  from sqlalchemy.sql.dml import DMLState, _DMLColumnElement
38
46
  from sqlalchemy.sql.dml import isinsert as _compile_state_isinsert
39
47
 
@@ -41,16 +49,12 @@ from sqlalchemy_cratedb.compiler import CrateCompiler
41
49
 
42
50
 
43
51
  class CrateCompilerSA20(CrateCompiler):
44
-
45
52
  def visit_update(self, update_stmt, **kw):
46
- compile_state = update_stmt._compile_state_factory(
47
- update_stmt, self, **kw
48
- )
53
+ compile_state = update_stmt._compile_state_factory(update_stmt, self, **kw)
49
54
  update_stmt = compile_state.statement
50
55
 
51
56
  # [20] CrateDB patch.
52
- if not compile_state._dict_parameters and \
53
- not hasattr(update_stmt, '_crate_specific'):
57
+ if not compile_state._dict_parameters and not hasattr(update_stmt, "_crate_specific"):
54
58
  return super().visit_update(update_stmt, **kw)
55
59
 
56
60
  toplevel = not self.stack
@@ -67,9 +71,7 @@ class CrateCompilerSA20(CrateCompiler):
67
71
  if is_multitable:
68
72
  # main table might be a JOIN
69
73
  main_froms = set(_from_objects(update_stmt.table))
70
- render_extra_froms = [
71
- f for f in extra_froms if f not in main_froms
72
- ]
74
+ render_extra_froms = [f for f in extra_froms if f not in main_froms]
73
75
  correlate_froms = main_froms.union(extra_froms)
74
76
  else:
75
77
  render_extra_froms = []
@@ -86,23 +88,17 @@ class CrateCompilerSA20(CrateCompiler):
86
88
  text = "UPDATE "
87
89
 
88
90
  if update_stmt._prefixes:
89
- text += self._generate_prefixes(
90
- update_stmt, update_stmt._prefixes, **kw
91
- )
91
+ text += self._generate_prefixes(update_stmt, update_stmt._prefixes, **kw)
92
92
 
93
93
  table_text = self.update_tables_clause(
94
94
  update_stmt, update_stmt.table, render_extra_froms, **kw
95
95
  )
96
96
  # [20] CrateDB patch.
97
- crud_params_struct = _get_crud_params(
98
- self, update_stmt, compile_state, toplevel, **kw
99
- )
97
+ crud_params_struct = _get_crud_params(self, update_stmt, compile_state, toplevel, **kw)
100
98
  crud_params = crud_params_struct.single_params
101
99
 
102
100
  if update_stmt._hints:
103
- dialect_hints, table_text = self._setup_crud_hints(
104
- update_stmt, table_text
105
- )
101
+ dialect_hints, table_text = self._setup_crud_hints(update_stmt, table_text)
106
102
  else:
107
103
  dialect_hints = None
108
104
 
@@ -114,23 +110,22 @@ class CrateCompilerSA20(CrateCompiler):
114
110
  text += " SET "
115
111
 
116
112
  # [20] CrateDB patch begin.
117
- include_table = extra_froms and \
118
- self.render_table_with_column_in_update_from
113
+ include_table = extra_froms and self.render_table_with_column_in_update_from
119
114
 
120
115
  set_clauses = []
121
116
 
122
- for c, expr, value, _ in crud_params:
117
+ for c, expr, value, _ in crud_params: # noqa: B007
123
118
  key = c._compiler_dispatch(self, include_table=include_table)
124
- clause = key + ' = ' + value
119
+ clause = key + " = " + value
125
120
  set_clauses.append(clause)
126
121
 
127
122
  for k, v in compile_state._dict_parameters.items():
128
- if isinstance(k, str) and '[' in k:
123
+ if isinstance(k, str) and "[" in k:
129
124
  bindparam = sa.sql.bindparam(k, v)
130
- clause = k + ' = ' + self.process(bindparam)
125
+ clause = k + " = " + self.process(bindparam)
131
126
  set_clauses.append(clause)
132
127
 
133
- text += ', '.join(set_clauses)
128
+ text += ", ".join(set_clauses)
134
129
  # [20] CrateDB patch end.
135
130
 
136
131
  if self.implicit_returning or update_stmt._returning:
@@ -153,9 +148,7 @@ class CrateCompilerSA20(CrateCompiler):
153
148
  text += " " + extra_from_text
154
149
 
155
150
  if update_stmt._where_criteria:
156
- t = self._generate_delimited_and_list(
157
- update_stmt._where_criteria, **kw
158
- )
151
+ t = self._generate_delimited_and_list(update_stmt._where_criteria, **kw)
159
152
  if t:
160
153
  text += " WHERE " + t
161
154
 
@@ -275,15 +268,10 @@ def _get_crud_params(
275
268
  [],
276
269
  )
277
270
 
278
- stmt_parameter_tuples: Optional[
279
- List[Tuple[Union[str, ColumnClause[Any]], Any]]
280
- ]
271
+ stmt_parameter_tuples: Optional[List[Tuple[Union[str, ColumnClause[Any]], Any]]]
281
272
  spd: Optional[MutableMapping[_DMLColumnElement, Any]]
282
273
 
283
- if (
284
- _compile_state_isinsert(compile_state)
285
- and compile_state._has_multi_parameters
286
- ):
274
+ if _compile_state_isinsert(compile_state) and compile_state._has_multi_parameters:
287
275
  mp = compile_state._multi_parameters
288
276
  assert mp is not None
289
277
  spd = mp[0]
@@ -304,14 +292,10 @@ def _get_crud_params(
304
292
  elif stmt_parameter_tuples:
305
293
  assert spd is not None
306
294
  parameters = {
307
- _column_as_key(key): REQUIRED
308
- for key in compiler.column_keys
309
- if key not in spd
295
+ _column_as_key(key): REQUIRED for key in compiler.column_keys if key not in spd
310
296
  }
311
297
  else:
312
- parameters = {
313
- _column_as_key(key): REQUIRED for key in compiler.column_keys
314
- }
298
+ parameters = {_column_as_key(key): REQUIRED for key in compiler.column_keys}
315
299
 
316
300
  # create a list of column assignment clauses as tuples
317
301
  values: List[_CrudParamElement] = []
@@ -408,10 +392,7 @@ def _get_crud_params(
408
392
  )
409
393
  """
410
394
 
411
- if (
412
- _compile_state_isinsert(compile_state)
413
- and compile_state._has_multi_parameters
414
- ):
395
+ if _compile_state_isinsert(compile_state) and compile_state._has_multi_parameters:
415
396
  # is a multiparams, is not an insert from a select
416
397
  assert not stmt._select_names
417
398
  multi_extended_values = _extend_values_for_multiparams(
@@ -426,11 +407,7 @@ def _get_crud_params(
426
407
  kw,
427
408
  )
428
409
  return _CrudParams(values, multi_extended_values)
429
- elif (
430
- not values
431
- and compiler.for_executemany
432
- and compiler.dialect.supports_default_metavalue
433
- ):
410
+ elif not values and compiler.for_executemany and compiler.dialect.supports_default_metavalue:
434
411
  # convert an "INSERT DEFAULT VALUES"
435
412
  # into INSERT (firstcol) VALUES (DEFAULT) which can be turned
436
413
  # into an in-place multi values. This supports