Skip to content

Instantly share code, notes, and snippets.

@localytics-gist
Last active March 4, 2017 23:25
Show Gist options
  • Save localytics-gist/ba9fe94a9627908ccaa28758b18ab5ad to your computer and use it in GitHub Desktop.
Save localytics-gist/ba9fe94a9627908ccaa28758b18ab5ad to your computer and use it in GitHub Desktop.
# Ensure we have loaded the adapter
require 'odbc_adapter'
# Individual ActiveRecord (and ODBC) adapters get required when they are referenced,
# so we need to explicitly require the PostgreSQL adapter here so we can subclass it
require 'odbc_adapter/adapters/postgresql_odbc_adapter'
# Register a dynamically-defined adapter that will subclass the PostgreSQL adapter,
# and tell ODBCAdapter to use it when the connected-to DBMS reports back a name
# matching the given pattern (in this case vertica).
ODBCAdapter.register(/vertica/i, ODBCAdapter::Adapters::PostgreSQLODBCAdapter) do
# Override the `quote_column_name` method to make it function more closely to what
# Vertica expects in its queries
def quote_column_name(name)
name.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment