localytics / odbc_adapter

An ActiveRecord ODBC adapter
MIT License
46 stars 107 forks source link

Handle tables with long comments #55

Closed mattbrown-msb closed 3 months ago

mattbrown-msb commented 3 months ago

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