Class: ActiveRecord::Tablefree::Connection
- Inherits:
-
Object
- Object
- ActiveRecord::Tablefree::Connection
- Defined in:
- lib/activerecord/tablefree/connection.rb
Instance Method Summary collapse
-
#cacheable_query(arel) ⇒ Object
This is used in the StatementCache object.
-
#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.
- #current_transaction ⇒ Object
- #execute(*_args) ⇒ Object
- #lookup_cast_type_from_column(*_args) ⇒ Object
- #quote_column_name(*_args) ⇒ Object
- #quote_table_name(*_args) ⇒ Object
-
#sanitize_limit(limit) ⇒ Object
Fixes Issue #17.
- #schema_cache(*_args) ⇒ Object
- #substitute_at(*_args) ⇒ Object
Instance Method Details
#cacheable_query(arel) ⇒ Object
This is used in the StatementCache object. It returns an object that can be used to query the database repeatedly.
62 63 64 65 66 67 68 |
# File 'lib/activerecord/tablefree/connection.rb', line 62 def cacheable_query(arel) # :nodoc: if prepared_statements ActiveRecord::StatementCache.query visitor, arel.ast else ActiveRecord::StatementCache.partial_query visitor, arel.ast, collector end 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.
44 45 46 |
# File 'lib/activerecord/tablefree/connection.rb', line 44 def combine_bind_parameters(**_args) '' end |
#current_transaction ⇒ Object
52 53 54 |
# File 'lib/activerecord/tablefree/connection.rb', line 52 def current_transaction @_current_transaction ||= ActiveRecord::Tablefree::Transaction.new end |
#execute(*_args) ⇒ Object
56 57 58 |
# File 'lib/activerecord/tablefree/connection.rb', line 56 def execute(*_args) {} end |
#lookup_cast_type_from_column(*_args) ⇒ Object
48 49 50 |
# File 'lib/activerecord/tablefree/connection.rb', line 48 def lookup_cast_type_from_column(*_args) @_cast_type ||= ActiveRecord::Tablefree::CastType.new end |
#quote_column_name(*_args) ⇒ Object
7 8 9 |
# File 'lib/activerecord/tablefree/connection.rb', line 7 def quote_column_name(*_args) '' end |
#quote_table_name(*_args) ⇒ Object
3 4 5 |
# File 'lib/activerecord/tablefree/connection.rb', line 3 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.
31 32 33 34 35 36 37 38 39 |
# File 'lib/activerecord/tablefree/connection.rb', line 31 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 |
#schema_cache(*_args) ⇒ Object
15 16 17 |
# File 'lib/activerecord/tablefree/connection.rb', line 15 def schema_cache(*_args) @_schema_cache ||= ActiveRecord::Tablefree::SchemaCache.new end |
#substitute_at(*_args) ⇒ Object
11 12 13 |
# File 'lib/activerecord/tablefree/connection.rb', line 11 def substitute_at(*_args) nil end |