-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mraba/underscore_column_id: use
_
as column identifier (#538)
- Loading branch information
1 parent
62bab2f
commit 695c0a9
Showing
5 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved. | ||
|
||
# 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( | ||
"identifier", | ||
( | ||
pytest.param("_", id="underscore"), | ||
pytest.param(".", id="dot"), | ||
), | ||
) | ||
def test_insert_with_identifier_as_column_name(identifier: str, engine_testaccount): | ||
expected_identifier = f"test: {identifier}" | ||
metadata = MetaData() | ||
table = Table( | ||
"table_1745924", | ||
metadata, | ||
Column("ca", Integer), | ||
Column("cb", String), | ||
Column(identifier, String), | ||
) | ||
|
||
try: | ||
metadata.create_all(engine_testaccount) | ||
|
||
with engine_testaccount.connect() as connection: | ||
connection.execute( | ||
insert(table).values( | ||
{ | ||
"ca": 1, | ||
"cb": "test", | ||
identifier: f"test: {identifier}", | ||
} | ||
) | ||
) | ||
result = connection.execute(select(table)).fetchall() | ||
assert result == [(1, "test", expected_identifier)] | ||
finally: | ||
metadata.drop_all(engine_testaccount) |