MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _append_param_insert_hasdefault

Function _append_param_insert_hasdefault

lib/sqlalchemy/sql/crud.py:1187–1239  ·  view source on GitHub ↗
(
    compiler, stmt, c, implicit_return_defaults, values, kw
)

Source from the content-addressed store, hash-verified

1185
1186
1187def _append_param_insert_hasdefault(
1188 compiler, stmt, c, implicit_return_defaults, values, kw
1189):
1190 if c.default.is_sequence:
1191 if compiler.dialect.supports_sequences and (
1192 not c.default.optional or not compiler.dialect.sequences_optional
1193 ):
1194 accumulated_bind_names: Set[str] = set()
1195 values.append(
1196 (
1197 c,
1198 compiler.preparer.format_column(c),
1199 compiler.process(
1200 c.default,
1201 accumulate_bind_names=accumulated_bind_names,
1202 **kw,
1203 ),
1204 accumulated_bind_names,
1205 )
1206 )
1207 if implicit_return_defaults and c in implicit_return_defaults:
1208 compiler.implicit_returning.append(c)
1209 elif not c.primary_key:
1210 compiler.postfetch.append(c)
1211 elif c.default.is_clause_element:
1212 accumulated_bind_names = set()
1213 values.append(
1214 (
1215 c,
1216 compiler.preparer.format_column(c),
1217 compiler.process(
1218 c.default.arg.self_group(),
1219 accumulate_bind_names=accumulated_bind_names,
1220 **kw,
1221 ),
1222 accumulated_bind_names,
1223 )
1224 )
1225
1226 if implicit_return_defaults and c in implicit_return_defaults:
1227 compiler.implicit_returning.append(c)
1228 elif not c.primary_key:
1229 # don't add primary key column to postfetch
1230 compiler.postfetch.append(c)
1231 else:
1232 values.append(
1233 (
1234 c,
1235 compiler.preparer.format_column(c),
1236 _create_insert_prefetch_bind_param(compiler, c, **kw),
1237 (c.key,),
1238 )
1239 )
1240
1241
1242def _append_param_insert_select_hasdefault(

Callers 1

_scan_colsFunction · 0.85

Calls 5

format_columnMethod · 0.80
appendMethod · 0.45
processMethod · 0.45
self_groupMethod · 0.45

Tested by

no test coverage detected