Open santilin opened 1 month ago
@Tigrov would you please take a look? Is it the same in yiisoft/db?
Current Yii SQLite driver does not support scheme names.
From the documentation
If a schema-name is specified, it must be either "main", "temp", or the name of an attached database.
It makes sense to add support schema names. In Yii3 the same.
In my yii2-sqlite3-full-support proyect I have added support for schemes replacing yii\db\sqlite\Scheme.php with my own version. I have been using it for a while and it works well, thogh it may not be complete.
It would be great to include this onto yii2.
@santilin Could you make a PR for yii2 to support scheme names?
@santilin Could you make a PR for yii2 to support scheme names?
Yes, but firstly, please, point me to a guide on correct formatting of the source code (tools) so that we don't get errors on th PR and another one for making a PR to yii2
https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md
Usually a PR should contain:
Summary: There is a bug in the
findTableNames
method of theSchema
class in Yii2 that affects the retrieval of table names when a schema is specified. The current implementation does not correctly handle the schema prefix, leading to incorrect SQL queries for SQLite databases.Environment:
Description: The method
findTableNames
is designed to return distinct table names from the SQLite database. However, when a schema is provided, the SQL query constructed does not correctly reference thesqlite_master
table. The modification proposed in the code snippet aims to prepend the schema to thesqlite_master
reference.Code Snippet:
Expected Behavior: When calling
findTableNames('my_schema')
, the expected SQL should be:This query should return all table names under the specified schema.
Actual Behavior: The current implementation returns the table names of the
main
database.Steps to Reproduce:
findTableNames
method with the schema namesecond_schema
as a parameter.References:
Citations: [1] https://www.yiiframework.com/doc/api/2.0/yii-db-schema [2] https://www.yiiframework.com/doc/api/2.0/yii-db-mysql-schema [3] https://www.yiiframework.com/doc/api/2.0/yii-db-sqlite-schema [4] https://forum.yiiframework.com/t/cdbschema-findtablenames-not-part-of-schemacachingduration/73388 [5] https://github.com/yiisoft/yii2/issues/8096 [6] https://github.com/yiisoft/yii/issues/2299 [7] https://forum.yiiframework.com/t/table-name-issue-in-oracle-db-and-yii2/79566 [8] https://www.yiiframework.com/doc/api/2.0/yii-db-oci-schema