MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / literal_column

Function literal_column

lib/sqlalchemy/sql/elements.py:202–237  ·  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

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

Calls 1

ColumnClauseClass · 0.85