Sha256: 8c5416965c28ced94f3dbd247935ba27d498f771e9fba51bbb35b7e5e9a17d47

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

module ActiveRecord
  module ConnectionAdapters
    module SQLServer
      module Quoting

        QUOTED_TRUE  = '1'
        QUOTED_FALSE = '0'
        QUOTED_STRING_PREFIX = 'N'

        def quote_string(s)
          SQLServer::Utils.quote_string(s)
        end

        def quote_column_name(name)
          SQLServer::Utils.extract_identifiers(name).quoted
        end

        def quote_default_value(value, column)
          if column.type == :uuid && value =~ /\(\)/
            value
          else
            quote(value, column)
          end
        end

        def quoted_true
          QUOTED_TRUE
        end

        def unquoted_true
          1
        end

        def quoted_false
          QUOTED_FALSE
        end

        def unquoted_false
          0
        end

        def quoted_date(value)
          if value.acts_like?(:date)
            Type::Date.new.type_cast_for_database(value)
          else value.acts_like?(:time)
            Type::DateTime.new.type_cast_for_database(value)
          end
        end


        private

        def _quote(value)
          case value
          when Type::Binary::Data
            "0x#{value.hex}"
          when ActiveRecord::Type::SQLServer::Char::Data
            value.quoted
          when String, ActiveSupport::Multibyte::Chars
            "#{QUOTED_STRING_PREFIX}#{super}"
          else
            super
          end
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
activerecord-sqlserver-adapter_new-4.2.15 lib/active_record/connection_adapters/sqlserver/quoting.rb
activerecord-sqlserver-adapter-4.2.15 lib/active_record/connection_adapters/sqlserver/quoting.rb
activerecord-sqlserver-adapter-4.2.13 lib/active_record/connection_adapters/sqlserver/quoting.rb
activerecord-sqlserver-adapter-4.2.12 lib/active_record/connection_adapters/sqlserver/quoting.rb
activerecord-sqlserver-adapter-4.2.11 lib/active_record/connection_adapters/sqlserver/quoting.rb