rails/rails — Issue #4044: Identity Map doesn't play nicely with Postgres' schema search path
Author: burke
Created: 2011-12-20 05:49:09+00:00
State: open

Somewhere between 3.1 and 3.2, the Postgres adapter got a lot of love in terms of supporting the schema search path. This is awesome. I'm using schema separation heavily in my app, and it looks like I'm able to remove 4/5 of the hacks I have in place to make 3.1 do what I need. Great work on this!

The Identity Map still doesn't work with the new search path support though -- if a (table_name, id) pair exists in two schemas, they clobber each other in the identity map.

This is the somewhat inelegant solution I came up with for my own app: https://gist.github.com/1dbdb44bdb077edfa2ca . I don't really propose this as a drop-in solution, but perhaps it's a starting point. It is unfortunate that this solution adds overhead for the 99% case where the search path is irrelevant. Perhaps if it were an option? `config.identity_map.key_by_schema_search_path` or similar?

Thoughts? I'm happy to implement this, but I'd like some guidance on how to go about it.