Skip to content

Commit 4064d6e

Browse files
committed
fix: support
1 parent df42172 commit 4064d6e

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
0.8.15 (unreleased)
22
-------------------
33

4-
- Nothing changed yet.
4+
- Fix SQLAlchemy V2 support (https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/319).
55

66

77
0.8.14 (2023-04-07)

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='sqlalchemy-redshift',
8-
version='0.8.16.dev0',
8+
version='0.8.15.dev1',
99
description='Amazon Redshift Dialect for sqlalchemy',
1010
long_description=readme + '\n\n' + history,
1111
long_description_content_type='text/x-rst',
@@ -39,6 +39,8 @@
3939
"Programming Language :: Python :: 3.8",
4040
"Programming Language :: Python :: 3.9",
4141
"Programming Language :: Python :: 3.10",
42+
"Programming Language :: Python :: 3.11",
43+
"Programming Language :: Python :: 3.12",
4244
],
4345
entry_points={
4446
'sqlalchemy.dialects': [

sqlalchemy_redshift/commands.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections import Iterable
99

1010
import sqlalchemy as sa
11+
from sqlalchemy.sql import text
1112
from sqlalchemy import exc as sa_exc
1213
from sqlalchemy.ext import compiler as sa_compiler
1314
from sqlalchemy.sql import expression as sa_expression
@@ -188,7 +189,7 @@ def visit_alter_table_append_command(element, compiler, **kw):
188189
source=compiler.preparer.format_table(element.source),
189190
fill_option=fill_option,
190191
)
191-
return compiler.process(sa.text(query_text), **kw)
192+
return compiler.process(text(query_text), **kw)
192193

193194

194195
class UnloadFromSelect(_ExecutableClause):
@@ -385,7 +386,7 @@ def visit_unload_from_select(element, compiler, **kw):
385386
),
386387
)
387388

388-
query = sa.text(qs)
389+
query = text(qs)
389390

390391
if el.delimiter is not None:
391392
query = query.bindparams(sa.bindparam(
@@ -895,7 +896,7 @@ def visit_copy_command(element, compiler, **kw):
895896
parameters='\n'.join(parameters)
896897
)
897898

898-
return compiler.process(sa.text(qs).bindparams(*bindparams), **kw)
899+
return compiler.process(text(qs).bindparams(*bindparams), **kw)
899900

900901

901902
class CreateLibraryCommand(_ExecutableClause):
@@ -995,7 +996,7 @@ def visit_create_library_command(element, compiler, **kw):
995996
query = query.format(name=quoted_lib_name,
996997
or_replace='OR REPLACE' if element.replace else '',
997998
region='REGION :region' if element.region else '')
998-
return compiler.process(sa.text(query).bindparams(*bindparams), **kw)
999+
return compiler.process(text(query).bindparams(*bindparams), **kw)
9991000

10001001

10011002
class RefreshMaterializedView(_ExecutableClause):

sqlalchemy_redshift/dialect.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import pkg_resources
88
import sqlalchemy as sa
9+
from sqlalchemy.sql import text
910
from packaging.version import Version
1011
from sqlalchemy import inspect
1112
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION
@@ -753,7 +754,7 @@ def get_check_constraints(self, connection, table_name, schema=None, **kw):
753754
)
754755
table_oid = 'NULL' if not table_oid else table_oid
755756

756-
result = connection.execute(sa.text("""
757+
result = connection.execute(text("""
757758
SELECT
758759
cons.conname as name,
759760
pg_get_constraintdef(cons.oid) as src
@@ -796,7 +797,7 @@ def get_table_oid(self, connection, table_name, schema=None, **kw):
796797
schema_field = '"{schema}".'.format(schema=schema) if schema else ""
797798

798799
result = connection.execute(
799-
sa.text(
800+
text(
800801
"""
801802
select '{schema_field}"{table_name}"'::regclass::oid;
802803
""".format(
@@ -894,7 +895,7 @@ def get_view_definition(self, connection, view_name, schema=None, **kw):
894895
:meth:`~sqlalchemy.engine.interfaces.Dialect.get_view_definition`.
895896
"""
896897
view = self._get_redshift_relation(connection, view_name, schema, **kw)
897-
return sa.text(view.view_definition)
898+
return text(view.view_definition)
898899

899900
def get_indexes(self, connection, table_name, schema, **kw):
900901
"""
@@ -1060,7 +1061,7 @@ def _get_all_relation_info(self, connection, **kw):
10601061
) if table_name else ""
10611062
)
10621063

1063-
result = connection.execute(sa.text("""
1064+
result = connection.execute(text("""
10641065
SELECT
10651066
c.relkind,
10661067
n.oid as "schema_oid",
@@ -1122,7 +1123,7 @@ def _get_schema_column_info(self, connection, **kw):
11221123
)
11231124

11241125
all_columns = defaultdict(list)
1125-
result = connection.execute(sa.text(REFLECTION_SQL.format(
1126+
result = connection.execute(text(REFLECTION_SQL.format(
11261127
schema_clause=schema_clause,
11271128
table_clause=table_clause
11281129
)))
@@ -1147,7 +1148,7 @@ def _get_all_constraint_info(self, connection, **kw):
11471148
) if table_name else ""
11481149
)
11491150

1150-
result = connection.execute(sa.text("""
1151+
result = connection.execute(text("""
11511152
SELECT
11521153
n.nspname as "schema",
11531154
c.relname as "table_name",
@@ -1434,6 +1435,10 @@ def create_connect_args(self, *args, **kwargs):
14341435
default_args.update(cparams)
14351436
return cargs, default_args
14361437

1438+
def _set_backslash_escapes(self, connection):
1439+
# Redshift doesn’t implement SHOW standard_conforming_strings
1440+
self._backslash_escapes = "off"
1441+
14371442

14381443
def gen_columns_from_children(root):
14391444
"""

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ envlist =
44
py39-pg28-sa14
55
py310-pg28-sa13
66
py310-pg28-sa14
7+
py310-pg28-sa20
8+
py311-pg28-sa20
9+
py312-pg28-sa20
710
lint
811
docs
912

@@ -13,6 +16,7 @@ passenv = PGPASSWORD,REDSHIFT_USERNAME,REDSHIFT_HOST,REDSHIFT_PORT,REDSHIFT_DATA
1316
deps =
1417
sa13: sqlalchemy==1.3.24
1518
sa14: sqlalchemy==1.4.15
19+
sa20: sqlalchemy==2.0.23
1620
pg28: psycopg2==2.8.6
1721
pg29: psycopg2==2.9.5
1822
alembic==1.9.2

0 commit comments

Comments
 (0)