Skip to content

Commit

Permalink
Snowflake specific subadapter
Browse files Browse the repository at this point in the history
  • Loading branch information
divoxx committed Aug 23, 2023
1 parent 0ac147f commit e3eff15
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
31 changes: 31 additions & 0 deletions lib/odbc_adapter/adapters/snowflake_odbc_adapter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module ODBCAdapter
module Adapters
# A default adapter used for databases that are no explicitly listed in the
# registry. This allows for minimal support for DBMSs for which we don't
# have an explicit adapter.
class SnowflakeODBCAdapter < ActiveRecord::ConnectionAdapters::ODBCAdapter
PRIMARY_KEY = 'INT PRIMARY KEY NOT NULL AUTOINCREMENT'.freeze
VARIANT_TYPE = 'VARIANT'.freeze
DATE_TYPE = 'DATE'.freeze
JSON_TYPE = 'JSON'.freeze
# Using a BindVisitor so that the SQL string gets substituted before it is
# sent to the DBMS (to attempt to get as much coverage as possible for
# DBMSs we don't support).
def arel_visitor
Arel::Visitors::PostgreSQL.new(self)
end

# Explicitly turning off prepared_statements in the null adapter because
# there isn't really a standard on which substitution character to use.
def prepared_statements
false
end

# Turning off support for migrations because there is no information to
# go off of for what syntax the DBMS will expect.
def supports_migrations?
false
end
end
end
end
5 changes: 3 additions & 2 deletions lib/odbc_adapter/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ class Registry

def initialize
@dbs = {
/my.*sql/i => :MySQL,
/postgres/i => :PostgreSQL
/my.*sql/i => :MySQL,
/postgres/i => :PostgreSQL,
/snowflake/i => :Snowflake,
}
end

Expand Down

0 comments on commit e3eff15

Please sign in to comment.