Skip to content

Commit

Permalink
Tests: Fix PGCompiler SQL renderer anomaly on limit clauses
Browse files Browse the repository at this point in the history
4532ef7 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.
  • Loading branch information
amotl committed Dec 22, 2022
1 parent 412d9b7 commit cfd24c8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/crate/client/sqlalchemy/tests/compiler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit cfd24c8

Please sign in to comment.