Skip to content

fix(py): quote every component of a table name for SQLAlchemy engines - #443

Draft
jat255 wants to merge 1 commit into
jat255/439-divisor-parenthesesfrom
jat255/438-quote-lowercase-tables
Draft

jat255 wants to merge 1 commit into
jat255/439-divisor-parenthesesfrom
jat255/438-quote-lowercase-tables

Conversation

@jat255

@jat255 jat255 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #438

This PR makes the Python package quote every part of a table name that it sends to a SQLAlchemy engine. An all-lowercase name was left bare, so on Snowflake a table created as "survey" was looked up as SURVEY.

Details (agent-written)

EngineBackend.quote() now uses quote_identifier() for each part. SQLAlchemy's quote() treats an all-lowercase name as case-insensitive and leaves it bare.

Behavior change: on Snowflake (and Oracle), a Python user who types tables="orders" for a table stored as ORDERS now has to type ORDERS. The R package already behaves this way, because DBI::dbQuoteIdentifier() always quotes. Mixed-case names were already quoted, so they do not change.

Testing: the full Python suite passes, with two new tests for a lowercase name on SQLite and on the Snowflake dialect. On live Snowflake, the describe test in #434 passes with this fix.

Kata: whhh.

@jat255 jat255 added bug Something isn't working needs-manual-review Agent-created work that needs a human review labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Preview root: https://posit-dev.github.io/commons/pr-443/

Python site preview: https://posit-dev.github.io/commons/pr-443/py/

Built from the latest commit on this branch. The R links in it point at the published R site, which no pull request rebuilds.

@jat255
jat255 force-pushed the jat255/438-quote-lowercase-tables branch from d41e26b to af62e71 Compare October 22, 2026 02:46
EngineBackend.quote() used the preparer's quote() and quote_schema(), which leave an all-lowercase name bare because SQLAlchemy treats it as case-insensitive. Snowflake folds a bare name to upper case, so a table created as "survey" was looked up as SURVEY and every query against it failed. quote_identifier() quotes each component as written, as the R package's dbQuoteIdentifier() does.

A lowercase name typed for an upper-case table on Snowflake or Oracle now has to be typed as stored, which is already the case in R.

Closes #438
@jat255
jat255 force-pushed the jat255/438-quote-lowercase-tables branch from af62e71 to 29bece0 Compare October 23, 2026 22:23
@jat255
jat255 added this pull request to stack #454 October 23, 2026 22:25

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

bug Something isn't working needs-manual-review Agent-created work that needs a human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant