fix(python-driver): quote-escape column aliases in buildCypher() by uesleilima · Pull Request #2373 · apache/age
Always double-quote column names in the AS (...) clause generated by
buildCypher() and _validate_column(). This prevents PostgreSQL parse
errors when column aliases happen to be reserved words (e.g. 'count',
'order', 'type', 'group', 'select').
Before: SELECT * from cypher(NULL,NULL) as (count agtype);
After: SELECT * from cypher(NULL,NULL) as ("count" agtype);
PostgreSQL always accepts double-quoted identifiers, so quoting
unconditionally is safe for all names — no reserved word list needed.
Closes apache#2370
suggested changes Apr 5, 2026
- _validate_column: add comment explaining why type_name is intentionally left unquoted (PG type names are case-insensitive) - buildCypher: fix graphName == None to idiomatic 'is None' - test_reserved_word_count: replace fragile assertNotIn with regex - Add test for reserved word in "name type" pair (e.g. "order agtype") - Add comment explaining intentional _validate_column private import Made-with: Cursor
- Update test_security.py assertions to expect double-quoted column names (consistent with the always-quote-column-names change) - Reword type_name comment to clarify case-folding semantics Made-with: Cursor
This file contains hidden or 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