MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / in_

Method in_

lib/sqlalchemy/sql/operators.py:1044–1138  ·  lib/sqlalchemy/sql/operators.py::ColumnOperators.in_

Implement the ``in`` operator. In a column context, produces the clause ``column IN <other>``. The given parameter ``other`` may be: * A list of literal values, e.g.:: stmt.where(column.in_([1, 2, 3])) In this calling form, the list of ite

(self, other: Any)

Source from the content-addressed store, hash-verified

1042 return self.operate(bitwise_rshift_op, other)
1043
1044 def in_(self, other: Any) -> ColumnOperators:
1045 class="st">"""Implement the ``in`` operator.
1046
1047 In a column context, produces the clause ``column IN <other>``.
1048
1049 The given parameter ``other`` may be:
1050
1051 * A list of literal values,
1052 e.g.::
1053
1054 stmt.where(column.in_([1, 2, 3]))
1055
1056 In this calling form, the list of items is converted to a set of
1057 bound parameters the same length as the list given:
1058
1059 .. sourcecode:: sql
1060
1061 WHERE COL IN (?, ?, ?)
1062
1063 * A list of tuples may be provided if the comparison is against a
1064 :func:`.tuple_` containing multiple expressions::
1065
1066 from sqlalchemy import tuple_
1067
1068 stmt.where(tuple_(col1, col2).in_([(1, 10), (2, 20), (3, 30)]))
1069
1070 * An empty list,
1071 e.g.::
1072
1073 stmt.where(column.in_([]))
1074
1075 In this calling form, the expression renders an class="st">"empty set"
1076 expression. These expressions are tailored to individual backends
1077 and are generally trying to get an empty SELECT statement as a
1078 subquery. Such as on SQLite, the expression is:
1079
1080 .. sourcecode:: sql
1081
1082 WHERE col IN (SELECT 1 FROM (SELECT 1) WHERE 1!=1)
1083
1084 .. versionchanged:: 1.4 empty IN expressions now use an
1085 execution-time generated SELECT subquery in all cases.
1086
1087 * A bound parameter, e.g. :func:`.bindparam`, may be used if it
1088 includes the :paramref:`.bindparam.expanding` flag::
1089
1090 stmt.where(column.in_(bindparam(class="st">"value", expanding=True)))
1091
1092 In this calling form, the expression renders a special non-SQL
1093 placeholder expression that looks like:
1094
1095 .. sourcecode:: sql
1096
1097 WHERE COL IN ([EXPANDING_value])
1098
1099 This placeholder expression is intercepted at statement execution
1100 time to be converted into the variable number of bound parameter
1101 form illustrated earlier. If the statement were executed as::

Callers 15

_table_options_queryMethod · 0.45
_columns_queryMethod · 0.45
_table_oids_queryMethod · 0.45
_constraint_queryMethod · 0.45
_foreing_key_queryMethod · 0.45
_index_queryMethod · 0.45
_comment_queryMethod · 0.45
_get_synonymsMethod · 0.45
_all_objects_queryMethod · 0.45
_table_options_queryMethod · 0.45
_column_queryMethod · 0.45

Calls 1

operateMethod · 0.95