Open DCrow opened 2 years ago
See also: #998 I assume the current user (sa?) has the dbo schema as default schema. Why should we enumerate all others schemas? How should it handled if there are duplicate names?
Why should we enumerate all others schemas?
We should enumerate since other database adapters support this.
For example rails postgres adapter. It also supports which schemas to enumerate using schema_search_path
option in database.yml.
How should it handled if there are duplicate names?
I think data_sources should return names with schema, so that it will be possible to differentiate same table names with different schemas. Also it should be noted that truncating tables doesn't always work if you use a table which has a different schema from default.
Is there an SQL Server equivalent to PostgreSQL's ANY (current_schemas(false))
(https://github.com/rails/rails/blob/6-0-stable/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L749)?
Something like this should work
ANY(SELECT DISTINCT TABLE_SCHEMA from INFORMATION_SCHEMA.TABLES)
Hi @DCrow assign this task to me.
Issue
When using a database with multiple schemas, not all tables are found for method
It seems to stem from this line. When
ActiveRecord::Base.connection.data_source_sql
is called, it's called without any parameters and because of thatquoted_scope
(inside that method) always returnsdbo
. Maybe this adapter should search all schemas like postgres adapter not justdbo
?Expected behavior
I'm expecting that all tables with different schemas are found.
Actual behavior
Tables with schemas other than
dbo
are not found.How to reproduce
See example
Details
6.0.4.4
6.0.4.4
2.1.5