Sha256: 7ae815b8a34a3ebfe4c474699fbae0a92f4d40494730a7bd36498f21453f26ac

Contents?: true

Size: 1.78 KB

Versions: 21

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

module ActiveRecord
  module ConnectionAdapters
    module SQLite3
      module Quoting # :nodoc:
        def quote_string(s)
          @connection.class.quote(s)
        end

        def quote_table_name_for_assignment(table, attr)
          quote_column_name(attr)
        end

        def quote_table_name(name)
          @quoted_table_names[name] ||= super.gsub(".", "\".\"").freeze
        end

        def quote_column_name(name)
          @quoted_column_names[name] ||= %Q("#{super.gsub('"', '""')}").freeze
        end

        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

        def quoted_binary(value)
          "x'#{value.hex}'"
        end

        def quoted_true
          ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer ? "1".freeze : "'t'".freeze
        end

        def unquoted_true
          ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer ? 1 : "t".freeze
        end

        def quoted_false
          ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer ? "0".freeze : "'f'".freeze
        end

        def unquoted_false
          ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer ? 0 : "f".freeze
        end

        private

          def _type_cast(value)
            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
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
activerecord-5.2.8.1 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.8 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.7.1 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.7 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.6.3 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.6.2 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.6.1 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.6 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.4.6 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.5 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.4.5 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.4.4 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.4.3 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.4.2 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.4.1 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.4 lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.4.rc1 lib/active_record/connection_adapters/sqlite3/quoting.rb
spiral_form-0.1.1 vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/sqlite3/quoting.rb
spiral_form-0.1.0 vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/sqlite3/quoting.rb
activerecord-5.2.3 lib/active_record/connection_adapters/sqlite3/quoting.rb