Skip to content

Commit 4b41b01

Browse files
SNOW-452342 fix breaking change introduced in sqlalchemy 1.4 (#242)
Co-authored-by: Omri Fima <[email protected]>
1 parent 96f9151 commit 4b41b01

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

snowdialect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from sqlalchemy.schema import Table
2020
from sqlalchemy.sql import text
2121
from sqlalchemy.sql.elements import quoted_name
22+
from sqlalchemy.sql.sqltypes import String
2223
from sqlalchemy.types import (
2324
BIGINT,
2425
BINARY,
@@ -102,7 +103,7 @@ class SnowflakeDialect(default.DefaultDialect):
102103
# unicode strings
103104
supports_unicode_statements = True
104105
supports_unicode_binds = True
105-
returns_unicode_strings = True
106+
returns_unicode_strings = String.RETURNS_UNICODE
106107
description_encoding = None
107108

108109
# No lastrowid support. See SNOW-11155

test/test_orm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

7+
import enum
78
import pytest
8-
from sqlalchemy import Column, ForeignKey, Integer, Sequence, String
9+
from sqlalchemy import Column, ForeignKey, Integer, Sequence, String, Enum
910
from sqlalchemy.ext.declarative import declarative_base
1011
from sqlalchemy.orm import Session, relationship
1112

@@ -16,12 +17,17 @@ def test_basic_orm(engine_testaccount):
1617
"""
1718
Base = declarative_base()
1819

20+
class UserStatus(enum.Enum):
21+
ACTIVE = "active",
22+
INACTIVE = "inactive"
23+
1924
class User(Base):
2025
__tablename__ = 'user'
2126

2227
id = Column(Integer, Sequence('user_id_seq'), primary_key=True)
2328
name = Column(String)
2429
fullname = Column(String)
30+
status = Column(Enum(UserStatus), default=UserStatus.ACTIVE)
2531

2632
def __repr__(self):
2733
return "<User(%r, %r)>" % (self.name, self.fullname)

0 commit comments

Comments
 (0)