From 08c46eea924d23a234bf3feea1a928eb8ae8a00a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 17 Apr 2020 10:55:08 -0400 Subject: ORM executemany returning Build on #5401 to allow the ORM to take advanage of executemany INSERT + RETURNING. Implemented the feature updated tests to support INSERT DEFAULT VALUES, needed to come up with a new syntax for compiler INSERT INTO table (anycol) VALUES (DEFAULT) which can then be iterated out for executemany. Added graceful degrade to plain executemany for PostgreSQL <= 8.2 Renamed EXECUTEMANY_DEFAULT to EXECUTEMANY_PLAIN Fix issue where unicode identifiers or parameter names wouldn't work with execute_values() under Py2K, because we have to encode the statement and therefore have to encode the insert_single_values_expr too. Correct issue from #5401 to support executemany + return_defaults for a PK that is explicitly pre-generated, meaning we aren't actually getting RETURNING but need to return it from compiled_parameters. Fixes: #5263 Change-Id: Id68e5c158c4f9ebc33b61c06a448907921c2a657 --- lib/sqlalchemy/testing/assertsql.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/sqlalchemy/testing/assertsql.py') diff --git a/lib/sqlalchemy/testing/assertsql.py b/lib/sqlalchemy/testing/assertsql.py index ef324635e..caf61a806 100644 --- a/lib/sqlalchemy/testing/assertsql.py +++ b/lib/sqlalchemy/testing/assertsql.py @@ -325,6 +325,14 @@ class EachOf(AssertRule): super(EachOf, self).no_more_statements() +class Conditional(EachOf): + def __init__(self, condition, rules, else_rules): + if condition: + super(Conditional, self).__init__(*rules) + else: + super(Conditional, self).__init__(*else_rules) + + class Or(AllOf): def process_statement(self, execute_observed): for rule in self.rules: -- cgit v1.2.1