Class: ActiveRecord::ConnectionAdapters::SinglestoreAdapter

Inherits:
AbstractMysqlAdapter
  • Object
show all
Includes:
MySQL::DatabaseStatements
Defined in:
lib/active_record/connection_adapters/singlestore_adapter.rb

Constant Summary collapse

ADAPTER_NAME =
"SingleStore"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, logger, connection_options, config) ⇒ SinglestoreAdapter

Returns a new instance of SinglestoreAdapter.



46
47
48
49
50
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 46

def initialize(connection, logger, connection_options, config)
  superclass_config = config.reverse_merge(prepared_statements: false)
  super(connection, logger, connection_options, superclass_config)
  configure_connection
end

Class Method Details

.database_exists?(config) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
55
56
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 52

def self.database_exists?(config)
  !!ActiveRecord::Base.singlestore_connection(config)
rescue ActiveRecord::NoDatabaseError
  false
end

Instance Method Details

#active?Boolean

– CONNECTION MANAGEMENT ==================================== ++

Returns:

  • (Boolean)


110
111
112
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 110

def active?
  @connection.ping
end

#create_table_definition(name, **options) ⇒ Object



138
139
140
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 138

def create_table_definition(name, **options)
  ActiveRecord::ConnectionAdapters::Singlestore::TableDefinition.new(self, name, **options)
end

#discard!Object

:nodoc:



128
129
130
131
132
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 128

def discard! # :nodoc:
  super
  @connection.automatic_close = false
  @connection = nil
end

#disconnect!Object

Disconnects from the database if already connected. Otherwise, this method does nothing.



123
124
125
126
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 123

def disconnect!
  super
  @connection.close
end

#each_hash(result) ⇒ Object

HELPER METHODS ===========================================



84
85
86
87
88
89
90
91
92
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 84

def each_hash(result) # :nodoc:
  if block_given?
    result.each(as: :hash, symbolize_keys: true) do |row|
      yield row
    end
  else
    to_enum(:each_hash, result)
  end
end

#error_number(exception) ⇒ Object



94
95
96
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 94

def error_number(exception)
  exception.error_number if exception.respond_to?(:error_number)
end

#extract_table_options!(options) ⇒ Object



142
143
144
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 142

def extract_table_options!(options)
  options.extract!(:temporary, :if_not_exists, :options, :as, :comment, :charset, :collation, :rowstore)
end

#quote_string(string) ⇒ Object

– QUOTING ================================================== ++



102
103
104
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 102

def quote_string(string)
  @connection.escape(string)
end

#reconnect!Object Also known as: reset!



114
115
116
117
118
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 114

def reconnect!
  super
  disconnect!
  connect
end

#schema_creationObject



134
135
136
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 134

def schema_creation
  ActiveRecord::ConnectionAdapters::Singlestore::SchemaCreation.new(self)
end

#supports_advisory_locks?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 78

def supports_advisory_locks?
  false
end

#supports_comments?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 62

def supports_comments?
  true
end

#supports_comments_in_create?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 66

def supports_comments_in_create?
  true
end

#supports_json?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 58

def supports_json?
  !mariadb? && database_version >= "5.7.8"
end

#supports_lazy_transactions?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 74

def supports_lazy_transactions?
  true
end

#supports_savepoints?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 70

def supports_savepoints?
  true
end