Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen bad exception #1153

Open
vmakre opened this issue Jan 19, 2017 · 5 comments
Open

codegen bad exception #1153

vmakre opened this issue Jan 19, 2017 · 5 comments
Labels
bug good-first-issue A nice and easy issue to try and fix if you are new to the community
Milestone

Comments

@vmakre
Copy link

vmakre commented Jan 19, 2017

I have a lot of tables with a lot of columns , but debugging codegen errors is sometime a bad process . Why i can't see where is my problem? . Errors like "Table does not exist or there is no primary key" are totally unusable . Maybe some var_dump or column name where codegen stalled will make sense . I know column naming is a big problem but i must remember what i had changed to know where i was wrong. You can test this with just put some dot in column name and codegen will break.

@kpirbhai
Copy link
Contributor

I'm not sure having "." in the column name is going to work at all. You would need to use a "backquote" or ` around the full column name within the queries.

The "Table does not exist" error I would imagine is being caused because you are referencing a non-existent table in codegen_settings.xml for foreign key relationships. That would see like the most likely cause to me. The error should include the name of the table attempting to be referenced, just go find the reference and fix it.

No primary key is the same type of thing. The error should include the table which does not have a primary key. Almost always you will need a primary key in a table so just go make one in the database and that should fix that problem.

@vmakre
Copy link
Author

vmakre commented Jan 20, 2017

I found column name was problem but from error i can't see where is problem. Error is "Table does not exist or no primary key " , table exist and have primary key but column name was wrong. I think codegen cannot create model from table and cannot continue.

@spekary
Copy link
Member

spekary commented Jan 20, 2017

Looking at the code, that is not the exact message. It should read:

Table does not exist or does not have a defined Primary Key:

Followed by the name of the table. If there is nothing there, then something you did is causing it to look for a completely empty table. If you can't see anything obvious in your table names, then the issue is likely with your foreign keys. Somehow, you have a foreign key which is referring to a blank table.

What kind of database are you using? If Mysql, are you using an Innodb table, or are you putting your relationships in the codegen_settings.xml?

Its hard for us to help you because we have never seen this error. The code is trying to give a reasonable error message, but for some reason, its looking for a blank table.

@vmakre
Copy link
Author

vmakre commented Jan 20, 2017

Yes "Table does not exist or does not have a defined Primary Key"
As I said before problem was with column names contains special characters as a dot (i didn't tested with other chars). Also when column name is number only !!! , must be prefixed by letter. Otherwise everything works fine .

@spekary
Copy link
Member

spekary commented Mar 19, 2017

OK, lets make this a v3.2 request to clean this up and check for it in codegen.

@spekary spekary added this to the 3.2 Release milestone Mar 19, 2017
@matthiaz matthiaz added bug good-first-issue A nice and easy issue to try and fix if you are new to the community labels Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good-first-issue A nice and easy issue to try and fix if you are new to the community
Projects
None yet
Development

No branches or pull requests

4 participants