Class: ActiveRecord::Tablefree::Connection

Inherits:
ConnectionAdapters::AbstractAdapter
  • Object
show all
Defined in:
lib/activerecord/tablefree/connection.rb

Instance Method Summary collapse

Constructor Details

#initializeConnection

Returns a new instance of Connection.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/activerecord/tablefree/connection.rb', line 3

def initialize
  @connection          = Object.new # The Raw Connection
  @owner               = nil
  @instrumenter        = ActiveSupport::Notifications.instrumenter
  @logger              = Object.new
  @config              = Object.new
  @pool                = nil
  @schema_cache        = ActiveRecord::Tablefree::SchemaCache.new
  @quoted_column_names, @quoted_table_names = {}, {}
  @visitor = Object.new
  @lock = Object.new
  @prepared_statements = false
end

Instance Method Details

#cacheable_query(arel) ⇒ Object

This is used in the StatementCache object.



71
72
73
# File 'lib/activerecord/tablefree/connection.rb', line 71

def cacheable_query(arel) # :nodoc:
  ActiveRecord::Tablefree::StatementCache.partial_query visitor, arel.ast, collector
end

#combine_bind_parameters(**_args) ⇒ Object

Called by bound_attributes in /lib/active_record/relation/query_methods.rb Returns a SQL string with the from, join, where, and having clauses,

in addition to the limit and offset.


54
55
56
# File 'lib/activerecord/tablefree/connection.rb', line 54

def combine_bind_parameters(**_args)
  ''
end

#current_transactionObject



62
63
64
# File 'lib/activerecord/tablefree/connection.rb', line 62

def current_transaction
  @_current_transaction ||= ActiveRecord::Tablefree::Transaction.new
end

#execute(*_args) ⇒ Object



66
67
68
# File 'lib/activerecord/tablefree/connection.rb', line 66

def execute(*_args)
  {}
end

#lookup_cast_type_from_column(*_args) ⇒ Object



58
59
60
# File 'lib/activerecord/tablefree/connection.rb', line 58

def lookup_cast_type_from_column(*_args)
  @_cast_type ||= ActiveRecord::Tablefree::CastType.new
end

#quote_column_name(*_args) ⇒ Object



21
22
23
# File 'lib/activerecord/tablefree/connection.rb', line 21

def quote_column_name(*_args)
  ''
end

#quote_table_name(*_args) ⇒ Object



17
18
19
# File 'lib/activerecord/tablefree/connection.rb', line 17

def quote_table_name(*_args)
  ''
end

#sanitize_limit(limit) ⇒ Object

Fixes Issue #17. github.com/softace/activerecord-tablefree/issues/17 The following method is from the ActiveRecord gem:

/lib/active_record/connection_adapters/abstract/database_statements.rb .

Sanitizes the given LIMIT parameter in order to prevent SQL injection.

The limit may be anything that can evaluate to a string via #to_s. It should look like an integer, or a comma-delimited list of integers, or an Arel SQL literal.

Returns Integer and Arel::Nodes::SqlLiteral limits as is. Returns the sanitized limit parameter, either as an integer, or as a string which contains a comma-delimited list of integers.



41
42
43
44
45
46
47
48
49
# File 'lib/activerecord/tablefree/connection.rb', line 41

def sanitize_limit(limit)
  if limit.is_a?(Integer) || limit.is_a?(Arel::Nodes::SqlLiteral)
    limit
  elsif limit.to_s.include?(',')
    Arel.sql limit.to_s.split(',').map { |i| Integer(i) }.join(',')
  else
    Integer(limit)
  end
end

#substitute_at(*_args) ⇒ Object



25
26
27
# File 'lib/activerecord/tablefree/connection.rb', line 25

def substitute_at(*_args)
  nil
end