Module: Rack::DevInsight::SqlDialects

Defined in:
lib/rack/dev_insight/sql_dialects.rb

Constant Summary collapse

MYSQL =
'mysql'
POSTGRESQL =
'postgresql'
SQLITE =
'sqlite'
DIALECTS =
[MYSQL, POSTGRESQL, SQLITE].freeze

Class Method Summary collapse

Class Method Details

.detect_dialectObject



12
13
14
15
16
17
18
19
20
# File 'lib/rack/dev_insight/sql_dialects.rb', line 12

def detect_dialect
  if defined?(Mysql2)
    MYSQL
  elsif defined?(PG)
    POSTGRESQL
  elsif defined?(SQLite3)
    SQLITE
  end
end

.validate!(dialect, error_klass) ⇒ Object

Raises:

  • (error_klass)


22
23
24
25
26
# File 'lib/rack/dev_insight/sql_dialects.rb', line 22

def validate!(dialect, error_klass)
  return if DIALECTS.include?(dialect)

  raise error_klass, "Unsupported SQL dialect: #{dialect}. Supported dialects are: #{DIALECTS.join(', ')}"
end