The table name is not quoted in the primary_key method (quoting has been removed at a certain point : 1d7c751#L0L867) and it causes the primary_key method to fail on tables named with capital letters with the following error :
1.9.3-p125 :003 > ActiveRecord::Base.connection.primary_key 'CustomUser'
ActiveRecord::StatementInvalid: PGError: ERROR: relation "customuser" does not exist
: SELECT DISTINCT(attr.attname)
FROM pg_attribute attr
INNER JOIN pg_depend dep ON attr.attrelid = dep.refobjid AND attr.attnum = dep.refobjsubid
INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey
WHERE cons.contype = 'p'
AND dep.refobjid = $1::regclass
This code is very different on master. I'm not sure if this means the issue has gone away or not.
@steveklabnik I verified the issue on master and submitted a PR to fix it #7850
PostgreSQL, quote table names when fetching the primary key. Closes #…