From cfd24c89486c3468b2753374608d0b2e44433ded Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 22 Dec 2022 13:09:52 +0100 Subject: [PATCH] Tests: Fix `PGCompiler` SQL renderer anomaly on limit clauses 4532ef79 started using the `PGCompiler` for generating limit clauses, to be more compatible with CrateDB on edge cases. Apparently, the SQL renderer of `PGCompiler` was slightly changed with SQLAlchemy 1.4, which removes a redundant space character between table name and limit clause. This slipped through because CI did not test on SA13 appropriately at the time the change was added. --- src/crate/client/sqlalchemy/tests/compiler_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/crate/client/sqlalchemy/tests/compiler_test.py b/src/crate/client/sqlalchemy/tests/compiler_test.py index 62157d57..c49e14b3 100644 --- a/src/crate/client/sqlalchemy/tests/compiler_test.py +++ b/src/crate/client/sqlalchemy/tests/compiler_test.py @@ -26,6 +26,7 @@ import sqlalchemy as sa from sqlalchemy.sql import update, text +from crate.client.sqlalchemy.sa_version import SA_VERSION, SA_1_4 from crate.client.sqlalchemy.types import Craty @@ -77,7 +78,10 @@ def test_select_with_offset(self): self.metadata.bind = self.crate_engine selectable = self.mytable.select().offset(5) statement = str(selectable.compile()) - self.assertEqual(statement, "SELECT mytable.name, mytable.data \nFROM mytable\n LIMIT ALL OFFSET ?") + if SA_VERSION >= SA_1_4: + self.assertEqual(statement, "SELECT mytable.name, mytable.data \nFROM mytable\n LIMIT ALL OFFSET ?") + else: + self.assertEqual(statement, "SELECT mytable.name, mytable.data \nFROM mytable \n LIMIT ALL OFFSET ?") def test_select_with_limit(self): """