MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _scan_cols

Function _scan_cols

lib/sqlalchemy/sql/crud.py:706–899  ·  view source on GitHub ↗
(
    compiler,
    stmt,
    compile_state,
    parameters,
    _getattr_col_key,
    _column_as_key,
    _col_bind_name,
    check_columns,
    values,
    toplevel,
    kw,
)

Source from the content-addressed store, hash-verified

704
705
706def _scan_cols(
707 compiler,
708 stmt,
709 compile_state,
710 parameters,
711 _getattr_col_key,
712 _column_as_key,
713 _col_bind_name,
714 check_columns,
715 values,
716 toplevel,
717 kw,
718):
719 (
720 need_pks,
721 implicit_returning,
722 implicit_return_defaults,
723 postfetch_lastrowid,
724 use_insertmanyvalues,
725 use_sentinel_columns,
726 ) = _get_returning_modifiers(compiler, stmt, compile_state, toplevel)
727
728 assert compile_state.isupdate or compile_state.isinsert
729
730 if compile_state._maintain_values_ordering:
731 parameter_ordering = [
732 _column_as_key(key) for key in compile_state._dict_parameters
733 ]
734 ordered_keys = set(parameter_ordering)
735 cols = [
736 stmt.table.c[key]
737 for key in parameter_ordering
738 if isinstance(key, str) and key in stmt.table.c
739 ] + [c for c in stmt.table.c if c.key not in ordered_keys]
740
741 else:
742 cols = stmt.table.columns
743
744 isinsert = _compile_state_isinsert(compile_state)
745 if isinsert and not compile_state._has_multi_parameters:
746 # new rules for #7998. fetch lastrowid or implicit returning
747 # for autoincrement column even if parameter is NULL, for DBs that
748 # override NULL param for primary key (sqlite, mysql/mariadb)
749 autoincrement_col = stmt.table._autoincrement_column
750 insert_null_pk_still_autoincrements = (
751 compiler.dialect.insert_null_pk_still_autoincrements
752 )
753 else:
754 autoincrement_col = insert_null_pk_still_autoincrements = None
755
756 if stmt._supplemental_returning:
757 supplemental_returning = set(stmt._supplemental_returning)
758 else:
759 supplemental_returning = set()
760
761 compiler_implicit_returning = compiler.implicit_returning
762
763 # TODO - see TODO(return_defaults_columns) below

Callers 1

_get_crud_paramsFunction · 0.85

Calls 12

_get_returning_modifiersFunction · 0.85
_column_as_keyFunction · 0.85
_getattr_col_keyFunction · 0.85
_append_param_parameterFunction · 0.85
_append_param_updateFunction · 0.85
appendMethod · 0.45
differenceMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected