MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _append_param_parameter

Function _append_param_parameter

lib/sqlalchemy/sql/crud.py:869–983  ·  view source on GitHub ↗
(
    compiler,
    stmt,
    compile_state,
    c,
    col_key,
    parameters,
    _col_bind_name,
    implicit_returning,
    implicit_return_defaults,
    postfetch_lastrowid,
    values,
    autoincrement_col,
    insert_null_pk_still_autoincrements,
    kw,
)

Source from the content-addressed store, hash-verified

867
868
869def _append_param_parameter(
870 compiler,
871 stmt,
872 compile_state,
873 c,
874 col_key,
875 parameters,
876 _col_bind_name,
877 implicit_returning,
878 implicit_return_defaults,
879 postfetch_lastrowid,
880 values,
881 autoincrement_col,
882 insert_null_pk_still_autoincrements,
883 kw,
884):
885 value = parameters.pop(col_key)
886
887 has_visiting_cte = kw.get("visiting_cte") is not None
888 col_value = compiler.preparer.format_column(
889 c, use_table=compile_state.include_table_with_column_exprs
890 )
891
892 accumulated_bind_names: Set[str] = set()
893
894 if coercions._is_literal(value):
895 if (
896 insert_null_pk_still_autoincrements
897 and c.primary_key
898 and c is autoincrement_col
899 ):
900 # support use case for #7998, fetch autoincrement cols
901 # even if value was given.
902
903 if postfetch_lastrowid:
904 compiler.postfetch_lastrowid = True
905 elif implicit_returning:
906 compiler.implicit_returning.append(c)
907
908 value = _create_bind_param(
909 compiler,
910 c,
911 value,
912 required=value is REQUIRED,
913 name=(
914 _col_bind_name(c)
915 if not _compile_state_isinsert(compile_state)
916 or not compile_state._has_multi_parameters
917 else "%s_m0" % _col_bind_name(c)
918 ),
919 accumulate_bind_names=accumulated_bind_names,
920 force_anonymous=has_visiting_cte,
921 **kw,
922 )
923 elif value._is_bind_parameter:
924 if (
925 insert_null_pk_still_autoincrements
926 and value.value is None

Callers 1

_scan_colsFunction · 0.85

Calls 9

_create_bind_paramFunction · 0.85
_col_bind_nameFunction · 0.85
format_columnMethod · 0.80
popMethod · 0.45
getMethod · 0.45
appendMethod · 0.45
processMethod · 0.45
self_groupMethod · 0.45

Tested by

no test coverage detected