Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opt-in to handle errors caused by long comments on tables #9

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

mattbrown-msb
Copy link

Allow clients to opt-in to handling long-comment tables by using a SHOW TABLES query. The fetch_all function is using a bound 'remarks' column that is configured to have a max_length of 254 characters. That max length is not configurable and the column cannot be unbound. So when a table with a comment longer than 254 characters exists in the result set, we run into the negative string size (or size too big) error.

This change uses a show tables query which generates a comment column definition with the max length allowed in snowflake. This allows us to pull down tables with any size comment. Since the result set is different between the show tables query and the fetch_all function on the tables ODBC:Statement object, the application must opt-in to using this functionality by defining silo_fetch_all_tables in the database.yml file (see below).

snowflake_predict_db_ads:
  adapter: odbc
  dsn: PredictDbAds
  pool: <%= ENV.fetch("RAILS_DB_CONNECTIONS") { 15 } %>
  silo_fetch_all_tables: true

@chelsea76 chelsea76 merged commit b61b90b into master Jun 27, 2024
6 checks passed
zokioki added a commit to doximity/odbc_adapter that referenced this pull request Aug 30, 2024
… comments

This change fixes an issue with the `tables` call erroring out if attempting to
fetch any tables that have longer than 254 character comments on them. This fix
is based on the approach used by the patterninc fork of the gem, whose PR does
a great job of explaining the issue and idea behind the solution:

> The fetch_all function is using a bound 'remarks' column that is configured to
> have a max_length of 254 characters. That max length is not configurable and the
> column cannot be unbound. So when a table with a comment longer than 254 characters
> exists in the result set, we run into the negative string size (or size too big) error.

- patterninc#9

The primary difference here is that we're using `SHOW TABLES IN ACCOUNT` query,
which should return the same set of tables as `fetch_all` was returning before,
eliminating the need for an opt-in config flag.

Snowflake docs on the SHOW TABLES query:
https://docs.snowflake.com/en/sql-reference/sql/show-tables
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.

3 participants