Skip to content

Commit

Permalink
mraba/underscore_column_id: test fix 3
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mraba committed Oct 23, 2024
1 parent 678a1d9 commit c791afb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 35 deletions.
15 changes: 0 additions & 15 deletions tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,6 @@ def test_now_func(self):
dialect="snowflake",
)

def test_dot_as_valid_identifier(self):
_table = table(
"table_1745924",
column("ca", Integer),
column("cb", String),
column(".", String),
)

stmt = insert(_table).values({"ca": 1, "cb": "test", ".": "test_"})
self.assert_compile(
stmt,
'INSERT INTO table_1745924 (ca, cb, ".") VALUES (%(ca)s, %(cb)s, %(_)s)',
dialect="snowflake",
)

def test_underscore_as_valid_identifier(self):
_table = table(
"table_1745924",
Expand Down
27 changes: 7 additions & 20 deletions tests/test_quote_identifiers.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
#
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
import pytest
from sqlalchemy import (
Column,
Integer,
MetaData,
String,
Table,
create_engine,
insert,
select,
)

from snowflake.sqlalchemy import URL

from .parameters import CONNECTION_PARAMETERS
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
import pytest
from sqlalchemy import Column, Integer, MetaData, String, Table, insert, select


@pytest.mark.parametrize(
Expand All @@ -24,7 +13,7 @@
pytest.param(".", id="dot"),
),
)
def test_insert_with_identifier_as_column_name(identifier: str):
def test_insert_with_identifier_as_column_name(identifier: str, engine_testaccount):
expected_identifier = f"test: {identifier}"
metadata = MetaData()
table = Table(
Expand All @@ -35,12 +24,10 @@ def test_insert_with_identifier_as_column_name(identifier: str):
Column(identifier, String),
)

engine = create_engine(URL(**CONNECTION_PARAMETERS))

try:
metadata.create_all(engine)
metadata.create_all(engine_testaccount)

with engine.connect() as connection:
with engine_testaccount.connect() as connection:
connection.execute(
insert(table).values(
{
Expand All @@ -53,4 +40,4 @@ def test_insert_with_identifier_as_column_name(identifier: str):
result = connection.execute(select(table)).fetchall()
assert result == [(1, "test", expected_identifier)]
finally:
metadata.drop_all(engine)
metadata.drop_all(engine_testaccount)

0 comments on commit c791afb

Please sign in to comment.