Module: ActiveRecord::ConnectionAdapters::Spanner::Quoting
- Included in:
- ActiveRecord::ConnectionAdapters::SpannerAdapter
- Defined in:
- lib/active_record/connection_adapters/spanner/quoting.rb
Constant Summary collapse
- QUOTED_COLUMN_NAMES =
:nodoc:
Concurrent::Map.new
- QUOTED_TABLE_NAMES =
:nodoc:
Concurrent::Map.new
Instance Method Summary collapse
- #_type_cast(value) ⇒ Object
- #quote_column_name(name) ⇒ Object
- #quote_string(s) ⇒ Object
- #quote_table_name(name) ⇒ Object
- #quoted_binary(value) ⇒ Object
Instance Method Details
#_type_cast(value) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/active_record/connection_adapters/spanner/quoting.rb', line 61 def _type_cast value case value when Array ActiveSupport::JSON.encode value else super end end |
#quote_column_name(name) ⇒ Object
38 39 40 |
# File 'lib/active_record/connection_adapters/spanner/quoting.rb', line 38 def quote_column_name name QUOTED_COLUMN_NAMES[name] ||= "`#{super.gsub '`', '``'}`".freeze end |
#quote_string(s) ⇒ Object
53 54 55 |
# File 'lib/active_record/connection_adapters/spanner/quoting.rb', line 53 def quote_string s s.gsub STR_ESCAPE_REGX, STR_ESCAPE_VALUES end |
#quote_table_name(name) ⇒ Object
42 43 44 |
# File 'lib/active_record/connection_adapters/spanner/quoting.rb', line 42 def quote_table_name name QUOTED_TABLE_NAMES[name] ||= super.gsub(".", "`.`").freeze end |
#quoted_binary(value) ⇒ Object
57 58 59 |
# File 'lib/active_record/connection_adapters/spanner/quoting.rb', line 57 def quoted_binary value "b'#{value}'" end |