Module: ActiveRecord::ConnectionAdapters::SQLite3::Quoting
- Extended by:
- ActiveSupport::Concern
- Included in:
- ActiveRecord::ConnectionAdapters::SQLite3Adapter
- Defined in:
- lib/active_record/connection_adapters/sqlite3/quoting.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- QUOTED_COLUMN_NAMES =
:nodoc:
Concurrent::Map.new
- QUOTED_TABLE_NAMES =
:nodoc:
Concurrent::Map.new
Instance Method Summary collapse
-
#quote_default_expression(value, column) ⇒ Object
:nodoc:.
- #quote_string(s) ⇒ 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
#quote_default_expression(value, column) ⇒ Object
:nodoc:
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 86 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
53 54 55 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 53 def quote_string(s) ::SQLite3::Database.quote(s) end |
#quote_table_name_for_assignment(table, attr) ⇒ Object
57 58 59 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 57 def quote_table_name_for_assignment(table, attr) quote_column_name(attr) end |
#quoted_binary(value) ⇒ Object
66 67 68 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 66 def quoted_binary(value) "x'#{value.hex}'" end |
#quoted_false ⇒ Object
78 79 80 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 78 def quoted_false "0" end |
#quoted_time(value) ⇒ Object
61 62 63 64 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 61 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
70 71 72 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 70 def quoted_true "1" end |
#type_cast(value) ⇒ Object
:nodoc:
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 99 def type_cast(value) # :nodoc: case value when BigDecimal, Rational 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
82 83 84 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 82 def unquoted_false 0 end |
#unquoted_true ⇒ Object
74 75 76 |
# File 'lib/active_record/connection_adapters/sqlite3/quoting.rb', line 74 def unquoted_true 1 end |