Sha256: e33d240963d6d7efe08276c2e747943ca0f671b2e4b29d07c37dc8f87c698935
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
class Upsert class Buffer class PG_Connection < Buffer class ColumnDefinition class << self def all(connection, table_name) # activerecord-3.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb#column_definitions res = connection.exec <<-EOS SELECT a.attname AS name, format_type(a.atttypid, a.atttypmod) AS sql_type, d.adsrc AS default FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '#{connection.quote_ident(table_name.to_s)}'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum EOS res.map do |row| new row['name'], row['sql_type'], row['default'] end end end attr_reader :name attr_reader :sql_type attr_reader :default def initialize(name, sql_type, default) @name = name @sql_type = sql_type @default = default end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
upsert-0.0.1 | lib/upsert/buffer/pg_connection/column_definition.rb |