yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

SQLSRV wildcard in model generation table name #18365

Closed achretien closed 3 years ago

achretien commented 4 years ago

What steps will reproduce the problem?

Using a wildcard in model name generation with a SqlServer DB

What's expected?

finding at least one table

What do you get instead?

finding nothing

Additional info

Q A
Yii version 2.0.38
PHP version 7.4
Database version last sqlserver docker image
Operating system Ubuntu

Since https://github.com/yiisoft/yii2/commit/6b10bbcec29b8c60e754a8b2cc0dc83e7c8d5d3e#diff-ea76a30d7da4b9fb69fe63d479c0764c4fd9bf99fbb859ba664ff0bc79a6bf8c

The table name return by the driver are like [tableName] instead of tableName.

In https://github.com/yiisoft/yii2-gii/blob/aa5307c827e47ea5673da9bd9214bb1c7cc118bc/src/generators/model/Generator.php#L959

we test /^\w+$/ against a table name starting with [

samdark commented 4 years ago

Moved to primary Yii 2 repository since it seems to be only MSSQL returning already quoted table names from schema. No other driver does that. I think the fix should be moving the quoting to higher layers and returning un-quoted names from schema itself.

Just patching Gii isn't a good solution.

@alexkart, @darkdef would you please check this one?

darkdef commented 3 years ago

@alexkart May be speak about this issue in tg or slack?