Module: ActiveRecord::ConnectionAdapters::SQLite3::Quoting
- Included in:
- ActiveRecord::ConnectionAdapters::SQLite3Adapter
- Defined in:
- lib/active_record/connection_adapters/sqlite3/quoting.rb
Overview
:nodoc:
Instance Method Summary collapse
- #column_name_matcher ⇒ Object
- #column_name_with_order_matcher ⇒ Object
- #quote_column_name(name) ⇒ Object
-
#quote_default_expression(value, column) ⇒ Object
:nodoc:.
- #quote_string(s) ⇒ Object
- #quote_table_name(name) ⇒ Object
- #quote_table_name_for_assignment(table, attr) ⇒ Object
- #quoted_binary(value) ⇒ Object
- #quoted_false ⇒ Object
- #quoted_time(value) ⇒ Object
- #quoted_true ⇒ Object
-
#type_cast(value) ⇒ Object
:nodoc:.
- #unquoted_false ⇒ Object
- #unquoted_true ⇒ Object
Instance Method Details
#column_name_matcher ⇒ Object
76 77 78 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 76 def column_name_matcher COLUMN_NAME end |
#column_name_with_order_matcher ⇒ Object
80 81 82 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 80 def column_name_with_order_matcher COLUMN_NAME_WITH_ORDER end |
#quote_column_name(name) ⇒ Object
19 20 21 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 19 def quote_column_name(name) self.class.quoted_column_names[name] ||= %Q("#{super.gsub('"', '""')}") end |
#quote_default_expression(value, column) ⇒ Object
:nodoc:
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 48 def quote_default_expression(value, column) # :nodoc: if value.is_a?(Proc) value = value.call if value.match?(/\A\w+\(.*\)\z/) "(#{value})" else value end else super end end |
#quote_string(s) ⇒ Object
7 8 9 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 7 def quote_string(s) @connection.class.quote(s) end |
#quote_table_name(name) ⇒ Object
15 16 17 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 15 def quote_table_name(name) self.class.quoted_table_names[name] ||= super.gsub(".", "\".\"").freeze end |
#quote_table_name_for_assignment(table, attr) ⇒ Object
11 12 13 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 11 def quote_table_name_for_assignment(table, attr) quote_column_name(attr) end |
#quoted_binary(value) ⇒ Object
28 29 30 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 28 def quoted_binary(value) "x'#{value.hex}'" end |
#quoted_false ⇒ Object
40 41 42 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 40 def quoted_false "0" end |
#quoted_time(value) ⇒ Object
23 24 25 26 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 23 def quoted_time(value) value = value.change(year: 2000, month: 1, day: 1) quoted_date(value).sub(/\A\d\d\d\d-\d\d-\d\d /, "2000-01-01 ") end |
#quoted_true ⇒ Object
32 33 34 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 32 def quoted_true "1" end |
#type_cast(value) ⇒ Object
:nodoc:
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 61 def type_cast(value) # :nodoc: case value when BigDecimal value.to_f when String if value.encoding == Encoding::ASCII_8BIT super(value.encode(Encoding::UTF_8)) else super end else super end end |
#unquoted_false ⇒ Object
44 45 46 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 44 def unquoted_false 0 end |
#unquoted_true ⇒ Object
36 37 38 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 36 def unquoted_true 1 end |