find_by_id "1-slug" does not truncate string to integer

Issue #113 invalid
mikeymicrophone created an issue

I believe that ActiveRecord intends for strings that begin with integers to be valid for primary key lookups. Using Postgres, however, this behavior is available via find but not find_by_id.

Comments (4)

  1. Michael Granger repo owner

    This project is for the 'pg' gem, the PostgreSQL client library. You'll likely want to submit this to the ActiveRecord/Rails bugtracker, as that's where #find_by_id comes from.

  2. mikeymicrophone reporter

    (Reply via mike...@gmail.com):

    Thanks for the quick reply. I figured it was an adapter issue since the technique works perfectly in MySQL.

  3. mikeymicrophone reporter

    (Reply via mike...@gmail.com):

    I mixed up this gem with the activerecord pg adapter. Do you know where I can find that library?

  4. Lars Kanis

    This projects 'pg' gem is the one that is used by the ActiveRecord adapter, but this issue is definitely an activerecord thing. The AR-specs specify find("1-slug") but don't specifiy find_by_id("1-slug"), so there could be different behaviour between different adapters. You may post this as AR issue in the rails project to clarify the situation.

  5. Log in to comment