New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix table_exists? in postgresql adapter to always use current search_path #1607
Conversation
fyi, I was working on something similar based off master, see: #1632 |
ah good one! Ya I planned on adding a patch for master also, just haven't gotten around to it as we don't use 3.1 in production ATM. |
…oderick van Domburg]
Can someone give me some feedback on this pull request? It's been sitting here for a month without any comments (save 1) I'm interested to know how I can improve it |
Yes! If this were in Rails it would have saved me many hours. I had monkey patched table_exists? so that I could use Postgresql schemas and I was running into problems when I used set_table_name on a model with a schema (i.e. set_table_name 'meta.accounts'). I applied your patch and it fixed my issues with table_exists? Would love to see this added into Rails as I have an app that makes heavy use of Postgresql schemas, a feature which is mostly unusable with an unhacked Rails install. |
fyi this is what we're using in production if you need to use this patch:
|
Brad, +1 (again;-) |
cool, thx @tardate, will take a look. |
/cc @tenderlove |
fix table_exists? in postgresql adapter to always use current search_path
Was this merged in master and 3-1-stable? |
3-1-stable has a different fix from @tardate. This was just for 3-0-stable |
cool |
This issue still exists in 3-1-stable |
really @tardate can you comment? I'm not on 3.1 yet |
I hit this on a 3.0.10 to 3.1 upgrade yesterday on a relative new multi-tenant build. Big thanks for the original fix. |
#1632 addressed this for 3.1 but it looks like that while it's in rails/master it didn't get merged to an RC or 3.1 stable. |
modified table_exists? in the postgresql adapter to always use the current search_path unless a explicit schema is specified.
Currently one cannot load schema.rb into a new (empty) postgresql schema. create_table forces a table drop which checks table_exists? first. This returns true even though the table doesn't actually exist in the current schema. Thus a PG error is thrown when it tries to drop the nonexistent table.