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

Function literal_column

lib/sqlalchemy/sql/elements.py:195–230  ·  view source on GitHub ↗

r"""Produce a :class:`.ColumnClause` object that has the :paramref:`_expression.column.is_literal` flag set to True. :func:`_expression.literal_column` is similar to :func:`_expression.column`, except that it is more often used as a "standalone" column expression that renders ex

(
    text: str, type_: Optional[_TypeEngineArgument[_T]] = None
)

Source from the content-addressed store, hash-verified

193
194
195def literal_column(
196 text: str, type_: Optional[_TypeEngineArgument[_T]] = None
197) -> ColumnClause[_T]:
198 r"""Produce a :class:`.ColumnClause` object that has the
199 :paramref:`_expression.column.is_literal` flag set to True.
200
201 :func:`_expression.literal_column` is similar to
202 :func:`_expression.column`, except that
203 it is more often used as a "standalone" column expression that renders
204 exactly as stated; while :func:`_expression.column`
205 stores a string name that
206 will be assumed to be part of a table and may be quoted as such,
207 :func:`_expression.literal_column` can be that,
208 or any other arbitrary column-oriented
209 expression.
210
211 :param text: the text of the expression; can be any SQL expression.
212 Quoting rules will not be applied. To specify a column-name expression
213 which should be subject to quoting rules, use the :func:`column`
214 function.
215
216 :param type\_: an optional :class:`~sqlalchemy.types.TypeEngine`
217 object which will
218 provide result-set translation and additional expression semantics for
219 this column. If left as ``None`` the type will be :class:`.NullType`.
220
221 .. seealso::
222
223 :func:`_expression.column`
224
225 :func:`_expression.text`
226
227 :ref:`tutorial_select_arbitrary_text`
228
229 """
230 return ColumnClause(text, type_=type_, is_literal=True)
231
232
233class CompilerElement(Visitable):

Calls 1

ColumnClauseClass · 0.85