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

Class Query

lib/sqlalchemy/orm/query.py:159–3370  ·  view source on GitHub ↗

ORM-level SQL construction object. .. legacy:: The ORM :class:`.Query` object is a legacy construct as of SQLAlchemy 2.0. See the notes at the top of :ref:`query_api_toplevel` for an overview, including links to migration documentation. :class:`_query.Query` objects

Source from the content-addressed store, hash-verified

157@inspection._self_inspects
158@log.class_logger
159class Query(
160 _SelectFromElements,
161 SupportsCloneAnnotations,
162 HasPrefixes,
163 HasSuffixes,
164 HasHints,
165 EventTarget,
166 log.Identified,
167 Generative,
168 Executable,
169 Generic[_T],
170):
171 """ORM-level SQL construction object.
172
173 .. legacy:: The ORM :class:`.Query` object is a legacy construct
174 as of SQLAlchemy 2.0. See the notes at the top of
175 :ref:`query_api_toplevel` for an overview, including links to migration
176 documentation.
177
178 :class:`_query.Query` objects are normally initially generated using the
179 :meth:`~.Session.query` method of :class:`.Session`, and in
180 less common cases by instantiating the :class:`_query.Query` directly and
181 associating with a :class:`.Session` using the
182 :meth:`_query.Query.with_session`
183 method.
184
185 """
186
187 # elements that are in Core and can be cached in the same way
188 _where_criteria: Tuple[ColumnElement[Any], ...] = ()
189 _having_criteria: Tuple[ColumnElement[Any], ...] = ()
190
191 _order_by_clauses: Tuple[ColumnElement[Any], ...] = ()
192 _group_by_clauses: Tuple[ColumnElement[Any], ...] = ()
193 _limit_clause: Optional[ColumnElement[Any]] = None
194 _offset_clause: Optional[ColumnElement[Any]] = None
195
196 _distinct: bool = False
197 _distinct_on: Tuple[ColumnElement[Any], ...] = ()
198
199 _for_update_arg: Optional[ForUpdateArg] = None
200 _correlate: Tuple[FromClause, ...] = ()
201 _auto_correlate: bool = True
202 _from_obj: Tuple[FromClause, ...] = ()
203 _setup_joins: Tuple[_SetupJoinsElement, ...] = ()
204
205 _label_style: SelectLabelStyle = SelectLabelStyle.LABEL_STYLE_LEGACY_ORM
206
207 _memoized_select_entities = ()
208
209 _compile_options: Union[Type[CacheableOptions], CacheableOptions] = (
210 ORMCompileState.default_compile_options
211 )
212
213 _with_options: Tuple[ExecutableOption, ...]
214 load_options = QueryContext.default_load_options + {
215 "_legacy_uniquing": True
216 }

Callers 4

test_to_query_argsMethod · 0.90
queryMethod · 0.90
__call__Method · 0.90

Calls

no outgoing calls

Tested by 4

test_to_query_argsMethod · 0.72
queryMethod · 0.72
__call__Method · 0.72