bake icon indicating copy to clipboard operation
bake copied to clipboard

Blocking bake.

Open HumanG33k opened this issue 4 years ago • 8 comments

Description

When i try to bin/bake all AModel there is runtime exception because of "error" on not related table. it should be warning but not error. (as the tables can not be involve)

Example :

  • error: [Cake\Database\Exception\DatabaseException] Cannot describe categories. It has 0 columns.
  • error: [RuntimeException] ORM queries generate field aliases using the table name/alias and column name. The table alias HttpStatusCodesUniformResourceLocators and column uniform_resource_locator_id create an alias longer than (61). You must change the table schema in the database and shorten either the table or column identifier so they fit within the database alias limits.

Pretty sure the code loop on list and check on it instead of loop and check if table is pick.

CakePHP Version

4.3.0

PHP Version

7.*

HumanG33k avatar Dec 03 '21 20:12 HumanG33k

Please describe the tables you are trying to bake.

othercorey avatar Dec 03 '21 20:12 othercorey

@othercorey what information you need about the table ?

HumanG33k avatar Dec 07 '21 07:12 HumanG33k

The schemas. You post an error about "unrelated tables" but gave us no information.

othercorey avatar Dec 07 '21 20:12 othercorey

The schema is compose (because wip) of empty table not link in way or another. I currently have to re check to be sure. Because i also have 2 databases. I will try to do that this week-end.

HumanG33k avatar Dec 10 '21 01:12 HumanG33k

ping @HumanG33k

dereuromark avatar Mar 08 '22 17:03 dereuromark

Add it on my week todo list.

HumanG33k avatar Mar 08 '22 22:03 HumanG33k

@dereuromark i just have a coworker having the same issue :

The database is seen as connected.

error: [Cake\Database\Exception\DatabaseException] Cannot describe states. It has 0 columns. in
           /home/user/public_html/project/vendor/cakephp/cakephp/src/Database/Schema/Collection.php on line 120
           Stack Trace:
           - /home/user/public_html/project/vendor/cakephp/cakephp/src/ORM/Table.php:513
           - /home/user/public_html/project/vendor/cakephp/bake/src/Command/ModelCommand.php:111
           - /home/user/public_html/project/vendor/cakephp/bake/src/Command/ModelCommand.php:94
           - /home/user/public_html/project/vendor/cakephp/bake/src/Command/AllCommand.php:115
           - /home/user/public_html/project/vendor/cakephp/cakephp/src/Console/BaseCommand.php:190
           - /home/user/public_html/project/vendor/cakephp/cakephp/src/Console/CommandRunner.php:334
           - /home/user/public_html/project/vendor/cakephp/cakephp/src/Console/CommandRunner.php:172
           - /home/user/public_html/project/bin/cake.php:12

the command

bin/cake bake all states

the sql script used to create

CREATE TABLE states (id uuid NOT NULL, name varchar(255) NOT NULL, description text, created timestamp, updated timestamp, PRIMARY KEY (id));

I will check right on the database if it's where the issue come from i think a error for user instead of an exeption can be great.

HumanG33k avatar Jun 08 '22 10:06 HumanG33k

Ok it was an tables owner issue.

a

select * from states;

run in the "cakephp" sql user send me an error.

After changing the owner of all table of the database(which as the right owner)

it works like a charm. After fixing the issue the error message make sense but a word on the "maybe wrong rights" can be great.

I let you close issue when you read it.

Do you want i make a pull request with some additionnal text on the error ?

HumanG33k avatar Jun 08 '22 10:06 HumanG33k