summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2023-04-27 00:13:00 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2023-04-27 00:13:00 +0000
commit11535752b94acb41ff684cf8d9c745038addc447 (patch)
treefec970fe35228d33c45280ad558ed9bc251b5208 /lib/sqlalchemy/sql
parentc89c2b3d9a18bd0eb4c8ace50ef875101c9f4b70 (diff)
parent8ec396873c9bbfcc4416e55b5f9d8653554a1df0 (diff)
downloadsqlalchemy-11535752b94acb41ff684cf8d9c745038addc447.tar.gz
Merge "support parameters in all ORM insert modes" into main
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/elements.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index ff47ec79d..2e32da754 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -502,6 +502,28 @@ class ClauseElement(
connection, distilled_params, execution_options
).scalar()
+ def _get_embedded_bindparams(self) -> Sequence[BindParameter[Any]]:
+ """Return the list of :class:`.BindParameter` objects embedded in the
+ object.
+
+ This accomplishes the same purpose as ``visitors.traverse()`` or
+ similar would provide, however by making use of the cache key
+ it takes advantage of memoization of the key to result in fewer
+ net method calls, assuming the statement is also going to be
+ executed.
+
+ """
+
+ key = self._generate_cache_key()
+ if key is None:
+ bindparams: List[BindParameter[Any]] = []
+
+ traverse(self, {}, {"bindparam": bindparams.append})
+ return bindparams
+
+ else:
+ return key.bindparams
+
def unique_params(
self,
__optionaldict: Optional[Dict[str, Any]] = None,