All AR::ConnectionAdapters#tables return only tables(exclude views)#21601
All AR::ConnectionAdapters#tables return only tables(exclude views)#21601senny merged 1 commit intorails:masterfrom
AR::ConnectionAdapters#tables return only tables(exclude views)#21601Conversation
|
r? @arthurnn (@rails-bot has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
I don't think name is being used anywhere so lets remove it.
There was a problem hiding this comment.
Also can we make this method private? It is not being used anywhere besides test.
There was a problem hiding this comment.
it is my mistakes, I will fix them :)
|
This will break apps I have worked on in the past for sure. |
|
The inconsistency between PG and the rest bothers me as well, though. |
|
We should deal with that inconsistency somehow. It's quite the difference in behavior and client code for all adapters can never be sure what they'll get. I think there's a handful of issues on GitHub about that behavior. One approach that comes to mind would be deprecating |
Sure. But at the same time, I think someone is depending in the fact that it does not return view (postgresql users). I am not sure changing all adapters to returns table + view is better than only return table. @senny |
|
I need to have a better look where I like the idea of passing in |
|
/cc @matthewd |
|
@yui-knk please hold changes to this PR, I'm currently working on a patch that should make the situation for |
|
@yui-knk I merged my patch. We can now put in place the necessary deprecations to change the behavior of
Then after This means that in the transition phase. Basically |
03db04d to
308406e
Compare
|
@senny I updated to only warning! |
There was a problem hiding this comment.
Thank, I fixed it. Copy & paste is evil 👿
308406e to
ddb3eae
Compare
There was a problem hiding this comment.
What about the following wording:
#tables currently returns both tables and views. This behavior is deprecated and will be changed with Rails 5.1 to only return tables. Use #data_sources instead.
|
@yui-knk running the update produces tons of warnings. We should change our internals to no longer depend on any of the deprecated behavior. This means to also touch on the behavior of |
There was a problem hiding this comment.
SchemaMigration#table_exists? is used for SchemaMigration#create_table and SchemaMigration#drop_table. It seems that should use table_exists? rather than data_source_exists?.
Reported on rails#21509, how views is treated by `#tables` are differ by each adapters. To fix this different behavior, after Rails 5.0 is released, deprecate `#tables`. And `#table_exists?` would check both tables and views. To make their behavior consistent with `#tables`, after Rails 5.0 is released, deprecate `#table_exists?`.
94f0440 to
7429633
Compare
All `AR::ConnectionAdapters#tables` return only tables(exclude views)
|
🎉 @yui-knk thank you for working on this! 💛 |
|
@senny 🎉 thanks for your review !!!! 😍 |
also deprecate `#table_exists?`, `#tables` and passing arguments to `#tables` Refer rails/rails#21601 rails/rails#21509
Passing `name` to `tables` is already deprecated at rails#21601. Passing `name` to `indexes` is also unused.
As reported on #21509,
tablesmethod of adapters for mysql and sqlite include viewbut for postgresql does not include. This commit fix all of them
to return only tables(exclude views). Close #21509.
This commit includes these fixes:
Implement
tables_and_viewsfor mysql and sqlitetablesmethod of adapters for mysql and sqlite has twofunctions.
(specified by argument)
Move no. 2 function to
tables_and_viewsmethod.Change arguments of
tablesmethodNow the responsibility of
tablesis to return all tables names,so change this method to be argument-less method.
Change some tests
test_tables_quotingin activerecord/test/cases/adapters/mysql2/schema_test.rbThis test asserts database name is quoted internally.
tables_and_viewsacceptsdatabase name. So change from
@connection.tablesto@connection.tables_and_views.test_tables_logs_namein activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rbThis test asserts what SQL is executed. SQL created by
tablesis changed, so changesqlused to assertion.