Sha256: d55a50c96323cfbf5e156a43248ae0ea25e5cc5b9e5d3540c37a5143f5793724

Contents?: true

Size: 803 Bytes

Versions: 1

Compression:

Stored size: 803 Bytes

Contents

class Upsert
  class ColumnDefinition
    # @private
    class Sqlite3 < ColumnDefinition
      class << self
        def all(connection, table_name)
          # activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb
          connection.execute("PRAGMA table_info(#{connection.quote_ident(table_name)})").map do |row|#, 'SCHEMA').to_hash
            default = case row["dflt_value"]
            when /^null$/i
              nil
            when /^'(.*)'$/
              $1.gsub(/''/, "'")
            when /^"(.*)"$/
              $1.gsub(/""/, '"')
            else
              row["dflt_value"]
            end
            new connection, row['name'], row['type'], default
          end.sort_by do |cd|
            cd.name
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
upsert-1.2.0 lib/upsert/column_definition/sqlite3.rb