diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2022-06-01 16:13:36 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-06-01 16:13:36 +0000 |
commit | 7b6fb299bb6b47dfeb22a5650b95af7fa0b35ec2 (patch) | |
tree | 84d683a496c9951838adb4efc09687f7c55b05af /lib/sqlalchemy/sql/elements.py | |
parent | 79dbe94bb4ccd75888d57f388195a3ba4fa6117e (diff) | |
parent | 349a7c5e0e2aeeac98fad789b0043a4bdfeed837 (diff) | |
download | sqlalchemy-7b6fb299bb6b47dfeb22a5650b95af7fa0b35ec2.tar.gz |
Merge "add backend agnostic UUID datatype" into main
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 61c5379d8..ce08a0a10 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -122,7 +122,9 @@ _NMT = TypeVar("_NMT", bound="_NUMBER") def literal( - value: Any, type_: Optional[_TypeEngineArgument[_T]] = None + value: Any, + type_: Optional[_TypeEngineArgument[_T]] = None, + literal_execute: bool = False, ) -> BindParameter[_T]: r"""Return a literal clause, bound to a bind parameter. @@ -136,13 +138,24 @@ def literal( :class:`BindParameter` with a bound value. :param value: the value to be bound. Can be any Python object supported by - the underlying DB-API, or is translatable via the given type argument. + the underlying DB-API, or is translatable via the given type argument. - :param type\_: an optional :class:`~sqlalchemy.types.TypeEngine` which - will provide bind-parameter translation for this literal. + :param type\_: an optional :class:`~sqlalchemy.types.TypeEngine` which will + provide bind-parameter translation for this literal. + + :param literal_execute: optional bool, when True, the SQL engine will + attempt to render the bound value directly in the SQL statement at + execution time rather than providing as a parameter value. + + .. versionadded:: 2.0 """ - return coercions.expect(roles.LiteralValueRole, value, type_=type_) + return coercions.expect( + roles.LiteralValueRole, + value, + type_=type_, + literal_execute=literal_execute, + ) def literal_column( |