-
Notifications
You must be signed in to change notification settings - Fork 16
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
[WIP] Proper AR5 Support #16
Conversation
1 similar comment
WHERE schemaname = ANY (current_schemas(false)) | ||
AND viewname NOT LIKE 'pg\_%' | ||
SQL | ||
sql += " AND schemaname != 'postgis'" if adapter_name == 'PostGIS' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the deal with comparing the schemaname and ignoring PostGIS?
I'm not really familiar with PostGIS, but I guess it does something strange here?
@ronen do you have any suggestions what to do with that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the thread and PR that introduced it: SchemaPlus/schema_plus#94. I guess it's analogous to suppressing the pr_*
tables. I'm not familiar with PostGIS either but over the years we've had occasional people raise issues/submit PRs to deal with it. Possibly this too could be maintained via middleware if it's still an issue?
I think schema_plus_compatibility should remain only for the purpose of helping to develop gems, not to provide a user-level API (you yourself didn't even want to document it!) One of the features of SchemaPlus has long been to normalize inconsistent/inconvenient behavior of AR to make it more usable. So I think it's OK to continue doing that. In particular:
That's a documented feature of schema_plus_views, and I think we should keep it: The reason for supporting (Given the existence of AR5's
Here too, this is for usability. If somebody is including schema_plus_views, that means they work with views and expect to have views in their db. So it makes sense to fix The only time I really want to keep in line with ActiveRecord is when AR introduces new features that "catch up" to features SchemaPlus was already supporting, but uses different syntax; then we should wean our users off SchemaPlus and onto the native AR functionality, by providing shims and deprecating them, and eventually removing them. I'd be happy for SchemaPlus to one day wither away entirely if AR does everything! Speaking of which, what's up with |
I see. But shouldn't we filter out internal tables as well then? Well, to tell the truth, DB-internal tables (such as the SCHEMA table) are already filtered, it's the new ar_internal_metadata table that isn't. So we could say hiding DB level views is consistent with the way tables work.
Right now there's no Or we can go the simpler way and just override tables with schema_monkey, but when AR 5.1 comes out it would make sense to reintroduce the middleware anyway. |
That would be a wonderful day indeed. :D
No, no such luck. AR5 provides no support of views besides listing them separately from tables. |
Hi, sorry for the delay.
Yes, you're right... I think the way to go is to put that functionality in schema_plus_tables (which right now does very little). I guess in 5.0 it would provide the Tables middleware, and in 5.1 the Middleware could go back to schema_plus_core. Then other gems could have a dependency on schema_plus_tables as needed. (I think we'd still want to keep the table helpers in schema_plus_compatibility though, for lower-level testing.) |
Sorry for the delay on my side this time. :) schema_plus_core would introduce the Views middleware, without filtering or modifying the views and schema_plus_views would hook into the Views and DataSources middlewares and filter the views. In schema_plus_tables, I'll basically throw away everything it's doing now (since the cascade option has been deprecated for years now, and if_exists is already supported by AR5) and hook into the data_sources middleware to filter the views. Since Postgres needs SQL to do the filtering (it's not enough to just filter out specific names in the middleware later) we'll set a flag on the middleware env in schema_plus_core that enables this filtering and the middleware hooks would just enable that flag.
I agree that is a good idea to provide the Tables middleware in schema_plus_tables now, until AR5.1 to avoid compatibility mess. |
Between, us, it's shambling forward slowly... But let me again take the opportunity to repeat how much I appreciate your doing all this! No way I'd be able to do it myself.
All sounds good
This is the only thing I'm wary of. I think schema_plus_core shouldn't be doing any SQL or implementation of features for other gems. Instead the middleware for Postgresql can define the |
Thanks. I'm really appreciate your help reviewing my ideas and making sure we get the best implementation.
I actually wasn't aware that |
I actually have an idea I like more now: Add a new value to This means SP::Core won't modify any behavior by default unless at least one of the middlewares tell it to do so, but middlewares can still be chained together without overriding each other. |
Started work here: Next we need middleware support for filtering in DataSources Views (in SP::Core) and Tables (SP::Tables, will be moved to SP::Core later). |
@ronen The pull requests now passes all tests (with gemfile.local :)) |
@ronen Can you give me permission to add new repositories to the schema_plus project? |
Has development of AR5 support stalled? |
A little bit :( |
@boazy let me know if there's something else i should look at or can help with. (given my still limited time :( ) |
@ronen I just wish I have more time myself. I didn't have time to update SP::Core and SP::Tables with the new middleware. Since Rails master is already fully differentiating data_sources, views and tables, I think we can just put separate middleware stacks for Tables, Views and DataSources directly there. If anyone relied on SP::Core 1.x Tables middleware directly (highly unlikely) they would have migrated by now, and we've released a new major version anyway. I still need to create a separate gem, probably called schema_plus_sql_constraints or just schema_plus_sql that will let Tables/Views/DataSources Middleware add extra SQL constraints to the native queries. It can also have this functionality for TableExists and other middleware. |
any news here? |
@joxxoxo Sorry, my status re all of schema_plus remains unfortunately that I'm not currently using rails in any of my day jobs, and unfortunately I don't have enough spare time to do any serious work with it. So best I'm able to do is (often belatedly) view and merge PRs, and occasionally offer some advice. I'd be thrilled if you (or anybody) were able to take a more active role. |
@boazy how goes... still interested in this? my availability status hasn't changed. at this point i'd say we can skip AR 5.0 and 5.1 and switch directly to 5.2 :) |
@ronen Wow, I'll have to come back and check in again. |
If you can that'd be great. Seems like there'll be others out there appreciative of the work! (#18) |
BTW schema_plus_core is now on AR5.2, so that's not something to have to worry about. |
- Use middleware to filter views for PostgreSQL
Do you have a plan to merge this into master? |
I got the same failure as in the tests when I use this branch:
Do I need a special configuration to use the postgres adapter? |
Closing in favor of #21 |
PostgreSQL tests still fails.
The main issue is that the old
connection.views
used to filter out internal Postgres views ("pg_*"), and AR5 is not doing that.We can easily monkey patch that to conform, but seeing the equivalent behavior of
connection.tables
, I think we should just adduser_views_only
(just as we have user_tables_only) to schema_plus_compatibility.Besides that, there's another breaking change I didn't realize we're going to have before: SchemaPlus::Views patches
connection.tables
(using middleware) to filter out views. This would be the normal behavior of table in the future, but right now we haveconnection.tables_only
for that, so I rather keep in line with ActiveRecord here.@ronen, what do you think?