Skip to content

Commit 4d0fb3b

Browse files
committed
fix(python-driver): address Copilot follow-ups on antlr/parser PR
- Use PostgreSQL "$user" placeholder in SET search_path. - Exercise real escapes and Unicode in special-characters vertex test (json.dumps). - Add Python 3.9 trove classifier to match requires-python and dependency comment. Made-with: Cursor
1 parent 281e6f3 commit 4d0fb3b

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

drivers/python/age/age.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def setUpAge(conn:psycopg.connection, graphName:str, load_from_plugins:bool=Fals
144144
else:
145145
cursor.execute("LOAD 'age';")
146146

147-
cursor.execute("SET search_path = ag_catalog, '$user', public;")
147+
cursor.execute('SET search_path = ag_catalog, "$user", public;')
148148

149149
ag_info = TypeInfo.fetch(conn, 'agtype')
150150

drivers/python/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ authors = [
2929
{name = "Ikchan Kwon, Apache AGE", email = "dev-subscribe@age.apache.org"}
3030
]
3131
classifiers = [
32+
"Programming Language :: Python :: 3.9",
3233
"Programming Language :: Python :: 3.10",
3334
"Programming Language :: Python :: 3.11",
3435
"Programming Language :: Python :: 3.12",

drivers/python/test_agtypes.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
# specific language governing permissions and limitations
1414
# under the License.
1515

16+
import json
17+
import math
1618
import unittest
1719
from decimal import Decimal
18-
import math
20+
1921
import age
2022

2123

@@ -144,16 +146,17 @@ def test_vertex_large_array_properties(self):
144146
self.assertEqual(vertex["tags"][11], "tag12")
145147

146148
def test_vertex_special_characters_in_properties(self):
147-
"""Issue #2367: Parser should handle properties with special characters."""
149+
"""Issue #2367: Parser should handle escaped quotes, paths, newlines, and Unicode."""
150+
expected_description = 'Quoted "text", path C:\\tmp\\file, line1\nline2, café 雪'
151+
props = json.dumps({"name": "test", "description": expected_description})
148152
vertexExp = (
149153
'{"id": 1125899906842626, "label": "TestNode", '
150-
'"properties": {"name": "test", '
151-
'"description": "A long description with unicode chars"}}::vertex'
154+
f'"properties": {props}}::vertex'
152155
)
153156
vertex = self.parse(vertexExp)
154157
self.assertEqual(vertex.id, 1125899906842626)
155158
self.assertEqual(vertex["name"], "test")
156-
self.assertIn("unicode", vertex["description"])
159+
self.assertEqual(vertex["description"], expected_description)
157160

158161
def test_vertex_nested_properties(self):
159162
"""Issue #2367: Parser should handle deeply nested property structures."""

0 commit comments

Comments
 (0)