Skip to content

fix(postgres): unwrap string literal defaults from column_default - #1779

Open
chenyangsu wants to merge 1 commit into
datajoint:masterfrom
chenyangsu:fix/postgres-string-default-describe
Open

chenyangsu wants to merge 1 commit into
datajoint:masterfrom
chenyangsu:fix/postgres-string-default-describe

Conversation

@chenyangsu

Copy link
Copy Markdown

For ''::character varying and 'abc'::character varying from information_schema.columns.column_default, PostgreSQLAdapter.parse_column_info passes the raw text through, so Heading wraps them as "''::character varying" and "'abc'::character varying".

Could we unwrap single-quoted string literals with optional PostgreSQL type casts and unescape doubled single quotes in _parse_column_default, leaving expressions like CURRENT_TIMESTAMP and nextval(...) untouched? Happy to adjust the cast matcher or move the helper onto PostgreSQLAdapter if you prefer.

Testing: pytest --noconftest tests/unit/test_adapters.py -> 107 passed (20 new cases fail on master), ruff 0.8.4 and codespell clean. Integration test added in tests/integration/test_declare.py (Docker unavailable locally).

Fixes #1725

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

describe() on PostgreSQL shows string defaults with their type cast

1 participant