Module: ActiveRecord::ConnectionAdapters::SQLServer::Quoting
- Included in:
- ActiveRecord::ConnectionAdapters::SQLServerAdapter
- Defined in:
- lib/active_record/connection_adapters/sqlserver/quoting.rb
Constant Summary collapse
- QUOTED_TRUE =
'1'.freeze
- QUOTED_FALSE =
'0'.freeze
- QUOTED_STRING_PREFIX =
'N'.freeze
Instance Method Summary collapse
- #fetch_type_metadata(sql_type, sqlserver_options = {}) ⇒ Object
- #quote_column_name(name) ⇒ Object
- #quote_default_expression(value, column) ⇒ Object
- #quote_string(s) ⇒ Object
- #quote_string_single(s) ⇒ Object
- #quote_string_single_national(s) ⇒ Object
- #quoted_date(value) ⇒ Object
- #quoted_false ⇒ Object
- #quoted_true ⇒ Object
- #unquoted_false ⇒ Object
- #unquoted_true ⇒ Object
Instance Method Details
#fetch_type_metadata(sql_type, sqlserver_options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 10 def (sql_type, = {}) cast_type = lookup_cast_type(sql_type) SQLServer::SqlTypeMetadata.new( sql_type: sql_type, type: cast_type.type, limit: cast_type.limit, precision: cast_type.precision, scale: cast_type.scale, sqlserver_options: ) end |
#quote_column_name(name) ⇒ Object
34 35 36 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 34 def quote_column_name(name) SQLServer::Utils.extract_identifiers(name).quoted end |
#quote_default_expression(value, column) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 38 def quote_default_expression(value, column) cast_type = lookup_cast_type(column.sql_type) if cast_type.type == :uuid && value =~ /\(\)/ value else super end end |
#quote_string(s) ⇒ Object
22 23 24 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 22 def quote_string(s) SQLServer::Utils.quote_string(s) end |
#quote_string_single(s) ⇒ Object
26 27 28 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 26 def quote_string_single(s) SQLServer::Utils.quote_string_single(s) end |
#quote_string_single_national(s) ⇒ Object
30 31 32 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 30 def quote_string_single_national(s) SQLServer::Utils.quote_string_single_national(s) end |
#quoted_date(value) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 63 def quoted_date(value) if value.acts_like?(:date) Type::Date.new.serialize(value) else value.acts_like?(:time) Type::DateTime.new.serialize(value) end end |
#quoted_false ⇒ Object
55 56 57 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 55 def quoted_false QUOTED_FALSE end |
#quoted_true ⇒ Object
47 48 49 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 47 def quoted_true QUOTED_TRUE end |
#unquoted_false ⇒ Object
59 60 61 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 59 def unquoted_false 0 end |
#unquoted_true ⇒ Object
51 52 53 |
# File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 51 def unquoted_true 1 end |