Skip to content

Commit

Permalink
make schema attr lookup case insensitive
Browse files Browse the repository at this point in the history
If the ODBC connection string doesn't specifically
set the `schema` connection param name as all lowercase,
the lookup for `current_schema` will result in `nil` which
in turn leads to various errors that depend on this value
being properly set.

This lookup was only checking for strictly `schema` attribute,
however, the ODBC connection string seems to allow for some
flexibility in how its param names are formatted - we've seen
these attributes writen as "schema", "Schema", or "SCHEMA"
(e.g. this repo's README and code examples show the
uppercase variant for its ODBC strings [1][2]).

This makes the lookup case-insensitive to allow
all variants of formatting for this attribute name.

[1] https://github.com/doximity/odbc_adapter/blob/d36c64ee2973942558b960c706848db06f50ffde/README.md#L45
[2] https://github.com/doximity/odbc_adapter/blob/a18a9ef02d27488a3b2b31ad7c695743bc2ff098/lib/active_record/connection_adapters/odbc_adapter.rb#L56
  • Loading branch information
zokioki committed Aug 30, 2024
1 parent 88fc21e commit 23ab5a4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/odbc_adapter/schema_statements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def current_database
end

def current_schema
@config[:driver].attrs['schema']
@config[:driver].attrs.transform_keys(&:downcase)['schema']
end

def name_regex(name)
Expand Down

0 comments on commit 23ab5a4

Please sign in to comment.