postgresql adapter : primary_key method fails on table with capital letters #5920

isc opened this Issue Apr 21, 2012 · 2 comments

4 participants


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[1]
      WHERE cons.contype = 'p'
        AND dep.refobjid = $1::regclass
Ruby on Rails member

This code is very different on master. I'm not sure if this means the issue has gone away or not.

Ruby on Rails member

@steveklabnik I verified the issue on master and submitted a PR to fix it #7850

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment