]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
PEP8 changes created automatically by autopep8 tool
authorYuval Dinari <>
Tue, 16 Jul 2019 08:16:40 +0000 (11:16 +0300)
committerYuval Dinari <>
Tue, 16 Jul 2019 08:16:40 +0000 (11:16 +0300)
Fixes: #4623
lib/sqlalchemy/dialects/postgresql/psycopg2.py
lib/sqlalchemy/sql/compiler.py
test/dialect/postgresql/test_dialect.py

index b2d09694caa75a1f4ae6ffc0e576865672702c55..904995593e65941c244d14dd3d26b6671c9234ba 100644 (file)
@@ -562,17 +562,33 @@ class PGCompiler_psycopg2(PGCompiler):
         self.multiple_rows = inline
         self.execute_values_insert_template = None
         self.execute_values_page_size = 2000
-        super(PGCompiler_psycopg2, PGCompiler_psycopg2).__init__(self, dialect, statement, column_keys, inline, **kwargs)
-
-    # Override SQLCompiler.generate_values_placeholders_str- enable use of psycopg2 execute_values()
-    def generate_values_placeholders_str(self, crud_params, returning_clause_exists):
+        super(
+            PGCompiler_psycopg2,
+            PGCompiler_psycopg2).__init__(
+            self,
+            dialect,
+            statement,
+            column_keys,
+            inline,
+            **kwargs)
+
+    # Override SQLCompiler.generate_values_placeholders_str - enable use of
+    # psycopg2 execute_values()
+    def generate_values_placeholders_str(
+            self, crud_params, returning_clause_exists):
         # Currently not using psycopg2.execute_values() when there's a returning clause; need to add support
         # for receiving multiple return values from insert query
         if self.multiple_rows and not returning_clause_exists and self.dialect.psycopg2_batch_mode == 'execute_values':
-            self.execute_values_insert_template = "(" + ", ".join([c[1] for c in crud_params]) + ")"
+            self.execute_values_insert_template = "(" + \
+                ", ".join([c[1] for c in crud_params]) + ")"
             return " VALUES %s"
         else:
-            return super(PGCompiler_psycopg2, PGCompiler_psycopg2).generate_values_placeholders_str(self, crud_params, returning_clause_exists)
+            return super(
+                PGCompiler_psycopg2,
+                PGCompiler_psycopg2).generate_values_placeholders_str(
+                self,
+                crud_params,
+                returning_clause_exists)
 
 
 class PGIdentifierPreparer_psycopg2(PGIdentifierPreparer):
@@ -789,7 +805,11 @@ class PGDialect_psycopg2(PGDialect):
     def do_executemany(self, cursor, statement, parameters, context=None):
         if self.psycopg2_batch_mode == 'execute_values' and context and context.compiled.execute_values_insert_template:
             self._psycopg2_extras().execute_values(
-                cursor, statement, parameters, template=context.compiled.execute_values_insert_template, page_size=context.compiled.execute_values_page_size)
+                cursor,
+                statement,
+                parameters,
+                template=context.compiled.execute_values_insert_template,
+                page_size=context.compiled.execute_values_page_size)
         # Support True for backward compatibility
         elif self.psycopg2_batch_mode in ('execute_batch', True):
             self._psycopg2_extras().execute_batch(cursor, statement, parameters)
index 7515ef1d79f52b24a2f49d33545c5238cb1810f8..473a839f8bd51cb8a424710ea811ca7d04a8a82d 100644 (file)
@@ -2499,7 +2499,8 @@ class SQLCompiler(Compiled):
                 )
             )
         else:
-            text += self.generate_values_placeholders_str(crud_params, returning_clause is not None)
+            text += self.generate_values_placeholders_str(
+                crud_params, returning_clause is not None)
 
         if insert_stmt._post_values_clause is not None:
             post_values_clause = self.process(
@@ -2518,7 +2519,8 @@ class SQLCompiler(Compiled):
 
         return text
 
-    def generate_values_placeholders_str(self, crud_params, returning_clause_exists):
+    def generate_values_placeholders_str(
+            self, crud_params, returning_clause_exists):
         """
         Generate the VALUES place holder string
         Should be overridden in classes that need a different implementation than the default
index 7682213c71f1dab02fd773ae922d4a181071dd0a..13f1c0e54ff76ecfc41d6a467097f8946b44f8a0 100644 (file)
@@ -242,7 +242,8 @@ class ExecuteValuesInsertsTest(fixtures.TablesTest):
 
     def setup(self):
         super(ExecuteValuesInsertsTest, self).setup()
-        self.engine = engines.testing_engine(options={"use_batch_mode": "execute_values"})
+        self.engine = engines.testing_engine(
+            options={"use_batch_mode": "execute_values"})
 
     def teardown(self):
         self.engine.dispose()
@@ -295,7 +296,8 @@ class ExecuteValuesInsertsTest(fixtures.TablesTest):
     def test_correct_arguments(self):
         def execute_values(cur, sql, argslist, template=None, page_size=100):
             assert sql == "INSERT INTO data (x, y) VALUES %s"
-            assert argslist == ({'x': 'x1', 'y': 'y1'}, {'x': 'x2', 'y': 'y2'}, {'x': 'x3', 'y': 'y3'})
+            assert argslist == ({'x': 'x1', 'y': 'y1'}, {
+                                'x': 'x2', 'y': 'y2'}, {'x': 'x3', 'y': 'y3'})
             assert template == "(%(x)s, %(y)s)"
             assert page_size == 2000