Repository navigation
Conversation
AdbcReader now keeps the resolved &'static DatabaseEntry instead of just the peeled-off AdbcInfo, so quirk access goes through the entry and the double registry lookup in from_connection_string collapses to one. OdbcReader resolves the registry entry once per connection and derives both the dialect and fetch behavior (batch size, numeric-as-double) from it, replacing the separate detect_or_err / detect calls. Adds registry::detect_entry_or_err for callers that need the full entry. First step of #575.
Adds DatabaseEntry::odbc_credential_provider, a pre-connect hook that rewrites the ODBC connection string. The Snowflake entry points it at a single apply_workbench_credentials() in odbc/snowflake.rs, and the two is_snowflake() string-match call sites in from_odbc_conn_str collapse into one registry-dispatched invocation keyed on the Driver= value. is_snowflake() itself is removed — its matching is subsumed by registry detection. Closes the remaining item of #575.
registry.rs is compiled unconditionally, but odbc::snowflake only exists with the odbc cargo feature, so the unconditional reference broke no-default-features builds (CI). Reference the hook through a cfg-gated constant instead; without the feature the entry simply has no provider.
teunbrand
approved these changes
Oct 12, 2026
teunbrand
left a comment
Collaborator
There was a problem hiding this comment.
LGTM but I think we ought so simplify the detection mechanism.
Comment on lines
+574
to
+589
| pub fn detect_entry_or_err( | ||
| dbms_name: Option<&str>, | ||
| driver_hint: Option<&str>, | ||
| ) -> crate::Result<&'static DatabaseEntry> { | ||
| detect(dbms_name, driver_hint).ok_or_else(|| unknown_backend_error(dbms_name, driver_hint)) | ||
| } | ||
|
|
||
| /// Detect a dialect from an ODBC DBMS name and/or driver string, or error | ||
| /// naming what was seen. Unknown backends are an **error** — silently | ||
| /// falling back to ANSI produced broken SQL too often. The escape hatch is | ||
| /// a `dialect=ansi` (or `dialect=<scheme>`) parameter; see | ||
| /// naming what was seen. Unknown backends are an **error** — the escape | ||
| /// hatch is a `dialect=ansi` (or `dialect=<scheme>`) parameter; see | ||
| /// [`dialect_override`]. | ||
| pub fn detect_or_err( | ||
| dbms_name: Option<&str>, | ||
| driver_hint: Option<&str>, | ||
| ) -> crate::Result<crate::reader::DialectRef> { | ||
| detect(dbms_name, driver_hint) | ||
| .map(|e| e.dialect()) | ||
| .ok_or_else(|| { | ||
| crate::GgsqlError::ReaderError(format!( | ||
| "Unrecognized database backend (DBMS name: {}, driver: {}). \ | ||
| ggsql does not know which SQL dialect to use. If the backend \ | ||
| is close to a supported one, pin the dialect explicitly with \ | ||
| a `dialect=<scheme>` parameter (e.g. dialect=postgres), or use \ | ||
| dialect=ansi for generic ANSI SQL.", | ||
| dbms_name.unwrap_or("<none>"), | ||
| driver_hint.unwrap_or("<none>"), | ||
| )) | ||
| }) | ||
| detect_entry_or_err(dbms_name, driver_hint).map(|e| e.dialect()) |
Collaborator
There was a problem hiding this comment.
I think we're going a bit overboard with the wrappers here. The simplest thing might be to make detect return a result with nice message and handle that at caller sites.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #575
This is a follow-up to #569 addressing some concerns that came up but were pushed due to the already humonguous size of the PR
In short, it moves more logic into the registry, avoiding to keep weird driver quirks scattered throughout the codebase