summaryrefslogtreecommitdiffstats
path: root/tests/test_schema.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-05-03 09:12:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-05-03 09:12:28 +0000
commit67c28dbe67209effad83d93b850caba5ee1e20e3 (patch)
treedffdfbfb4f0899c92a4c978e6eac55af2ff76367 /tests/test_schema.py
parentReleasing debian version 11.5.2-1. (diff)
downloadsqlglot-67c28dbe67209effad83d93b850caba5ee1e20e3.tar.xz
sqlglot-67c28dbe67209effad83d93b850caba5ee1e20e3.zip
Merging upstream version 11.7.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_schema.py')
-rw-r--r--tests/test_schema.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/test_schema.py b/tests/test_schema.py
index dc7e5b2..92cf04a 100644
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -163,8 +163,8 @@ class TestSchema(unittest.TestCase):
self.assertEqual(schema.column_names("test"), ["x", "y"])
def test_schema_get_column_type(self):
- schema = MappingSchema({"a": {"b": "varchar"}})
- self.assertEqual(schema.get_column_type("a", "b").this, exp.DataType.Type.VARCHAR)
+ schema = MappingSchema({"A": {"b": "varchar"}})
+ self.assertEqual(schema.get_column_type("a", "B").this, exp.DataType.Type.VARCHAR)
self.assertEqual(
schema.get_column_type(exp.Table(this="a"), exp.Column(this="b")).this,
exp.DataType.Type.VARCHAR,
@@ -213,3 +213,11 @@ class TestSchema(unittest.TestCase):
# Clickhouse supports both `` and "" for identifier quotes; sqlglot uses "" when generating sql
schema = MappingSchema(schema={"x": {"`y`": "INT"}}, dialect="clickhouse")
self.assertEqual(schema.column_names(exp.Table(this="x")), ["y"])
+
+ # Check that add_table normalizes both the table and the column names to be added/updated
+ schema = MappingSchema()
+ schema.add_table("Foo", {"SomeColumn": "INT", '"SomeColumn"': "DOUBLE"})
+
+ table_foo = exp.Table(this="fOO")
+
+ self.assertEqual(schema.column_names(table_foo), ["somecolumn", "SomeColumn"])