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

Name clash in tables with newest release #305

Open
sweigert opened this issue Nov 22, 2024 · 1 comment
Open

Name clash in tables with newest release #305

sweigert opened this issue Nov 22, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@sweigert
Copy link

sweigert commented Nov 22, 2024

Hi,

I was upgrading to the latest release but I get an error in the generated code. It is related to how the variables are named in the generated models since it generated an error variable for the unique constraints which seems to follow the naming pattern <TableName>Errors.
But if you actually have a table, called device_errors it will also translate to DeviceErrors.

Here is a minimal example:

CREATE TABLE devices (
  id UUID,
  id2 UUID,
  PRIMARY KEY (id)
);

CREATE TABLE device_errors (
  id UUID,
  PRIMARY KEY (id)
);

ALTER TABLE devices ADD CONSTRAINT unique_devices UNIQUE (id, id2);

The generated code cannot compile since DeviceErrors will be defined multiple times.

Btw, I am really enjoying bob. Thanks for your work!

@stephenafamo
Copy link
Owner

Not good 😬 . I'll think of some ideas to prevent this in the future.

Temporarily, consider adding an alias for device_errors so that it is generated with a different name.

@stephenafamo stephenafamo added the enhancement New feature or request label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants