Method: Sequel::Postgres::DatabaseMethods#primary_key
- Defined in:
- lib/sequel/adapters/shared/postgres.rb
#primary_key(table, opts = OPTS) ⇒ Object
Return primary key for the given table.
386 387 388 389 390 391 392 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 386 def primary_key(table, opts=OPTS) quoted_table = quote_schema_table(table) Sequel.synchronize{return @primary_keys[quoted_table] if @primary_keys.has_key?(quoted_table)} sql = "#{SELECT_PK_SQL} AND pg_class.oid = #{literal(regclass_oid(table, opts))}" value = fetch(sql).single_value Sequel.synchronize{@primary_keys[quoted_table] = value} end |