From b0427d6b9229d81b1f069b6375179378b6a0d683 Mon Sep 17 00:00:00 2001 From: Joshua Fraustro Date: Thu, 17 Oct 2024 12:34:31 -0400 Subject: [PATCH 1/6] add new ADQL-2.1 keywords --- vo_models/adql/misc.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vo_models/adql/misc.py b/vo_models/adql/misc.py index 400885e..c9003b2 100644 --- a/vo_models/adql/misc.py +++ b/vo_models/adql/misc.py @@ -32,8 +32,8 @@ "CATALOG", "CHAR", "CHARACTER", - "CHARACTER_LENGTH", "CHAR_LENGTH", + "CHARACTER_LENGTH", "CHECK", "CLOSE", "COALESCE", @@ -238,6 +238,7 @@ "ATAN2", "CEILING", "COS", + "COT", "DEGREES", "EXP", "FLOOR", @@ -252,7 +253,6 @@ "SIN", "SQRT", "TAN", - "TOP", "TRUNCATE", # ADQL geometry keywords "AREA", @@ -268,4 +268,13 @@ "POINT", "POLYGON", "REGION", + # Cast functions and datatypes + "BIGINT", + # String functions and operators + "ILIKE", + # Conversion functions + "IN_UNIT", + # Cardinality + "OFFSET", + "TOP", ] From 293c426a4a061f9dcefee6dda8d28b6968208602 Mon Sep 17 00:00:00 2001 From: Joshua Fraustro Date: Thu, 17 Oct 2024 12:34:46 -0400 Subject: [PATCH 2/6] fix column name handling --- vo_models/vodataservice/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vo_models/vodataservice/models.py b/vo_models/vodataservice/models.py index 0ac37c5..c6cc2cf 100644 --- a/vo_models/vodataservice/models.py +++ b/vo_models/vodataservice/models.py @@ -176,7 +176,8 @@ def validate_colname(cls, value: str): value: - The column name to escape. """ - if value.upper() in ADQL_SQL_KEYWORDS: + if value.strip("'\"").upper() in ADQL_SQL_KEYWORDS: + value = value.strip("'\"") value = f'"{value}"' return value From 93bbec462e9a0f82708b6b2404106f14a1666501 Mon Sep 17 00:00:00 2001 From: Joshua Fraustro Date: Thu, 17 Oct 2024 12:34:56 -0400 Subject: [PATCH 3/6] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 18c5a15..c3d7e41 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "vo-models" -version = "0.4.1" +version = "0.4.2" authors = [ {name = "Joshua Fraustro", email="jfraustro@stsci.edu"}, {name = "MAST Archive Developers", email="archive@stsci.edu"} From ba2a7481245b407e64cbb73c06fac845058db189 Mon Sep 17 00:00:00 2001 From: Joshua Fraustro Date: Fri, 18 Oct 2024 13:19:52 -0400 Subject: [PATCH 4/6] add tests --- .../vodataservice/vodataservice_models_test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/vodataservice/vodataservice_models_test.py b/tests/vodataservice/vodataservice_models_test.py index 10a8a83..1f003bc 100644 --- a/tests/vodataservice/vodataservice_models_test.py +++ b/tests/vodataservice/vodataservice_models_test.py @@ -164,6 +164,24 @@ def test_write_to_xml(self): canonicalize(self.test_xml, strip_text=True), ) + def test_reserved_adql_words(self): + """Test that reserved ADQL/SQL words are properly escaped in column names""" + + non_reserved = TableParam(column_name="aperture") + reserved_no_quotes = TableParam(column_name="distance") + reserved_single_quotes = TableParam(column_name="'offset'") + reserved_mixed_quotes = TableParam(column_name='"\'top\'"') + + self.assertEqual(non_reserved.column_name, "aperture") + self.assertEqual(reserved_no_quotes.column_name, '"distance"') + self.assertEqual(reserved_single_quotes.column_name, '"offset"') + self.assertEqual(reserved_mixed_quotes.column_name, '"top"') + + self.assertIn("aperture", non_reserved.to_xml(encoding=str)) + self.assertIn("\"distance\"", reserved_no_quotes.to_xml(encoding=str)) + self.assertIn("\"offset\"", reserved_single_quotes.to_xml(encoding=str)) + self.assertIn("\"top\"", reserved_mixed_quotes.to_xml(encoding=str)) + class TestTableElement(TestCase): """Test the Table element model""" From c5d7ad9b10c1cdd3126163d711ff6473170b65e6 Mon Sep 17 00:00:00 2001 From: Joshua Fraustro Date: Fri, 18 Oct 2024 13:31:56 -0400 Subject: [PATCH 5/6] set version to dev --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c3d7e41..d40c418 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "vo-models" -version = "0.4.2" +version = "0.4.2.dev0" authors = [ {name = "Joshua Fraustro", email="jfraustro@stsci.edu"}, {name = "MAST Archive Developers", email="archive@stsci.edu"} From c43d7a36168a21f6a43cf014caa61e3c62c45243 Mon Sep 17 00:00:00 2001 From: Joshua Fraustro Date: Mon, 21 Oct 2024 09:54:12 -0400 Subject: [PATCH 6/6] update version to 0.4.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d40c418..c3d7e41 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "vo-models" -version = "0.4.2.dev0" +version = "0.4.2" authors = [ {name = "Joshua Fraustro", email="jfraustro@stsci.edu"}, {name = "MAST Archive Developers", email="archive@stsci.edu"}