-
Notifications
You must be signed in to change notification settings - Fork 125
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
Generating schema Fails #408
Comments
I guess we could add |
I think the point I was getting at is that I think it should fail and detect a failure rather than generate code that doesn't compile. You could potentially run into the same issue with table_ or such. Maintain a reserve words that are part of your model if they're not overriden via the custom config. |
The only way the generator can detect build failure is to initiate go build. I think that would be too much responsibility for a generator. Also, it would probably trigger every anti-virus software out there.
True, but there is always an option to customize the generator.
Since the default generator always generates columns in |
Okay, maybe we should add a note in the wiki to call that out? So, detecting a build failure is likely overkill, what I was getting at is ensuring those values are not used. Since we have a finite set of reserved words, can't the generator fail if it finds a column name titled one of those values you listed above? It does add a check to check on every field but it's a better user experience than trying out jet after never hearing about it and having it blow up and moving on since it's obviously 'broken'. |
It doesn't have to fail. If generator encounters any of above listed values, generator can add any character and thus break the name conflict. For instance if we add type auditActions struct {
postgres.Table
// Columns
TableName_ postgres.ColumnString
} |
Ah, so dynamic renaming naming... yeah that'd be much better. 👍 |
Describe the bug
The code generator should fail if datamodel contains reserved fields.
There is a collision with the way the code is constructed, because postgres.Table exposes TalbeName() and the table contains a field named TableName the code does not compile.
Environment (please complete the following information):
Code snippet
Expected behavior
Generated code to compile successfully or fail hard on the generation and provide context on the reason for the failure
The text was updated successfully, but these errors were encountered: