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

Table with *_id column that isn't a foreign key doesn't generate validation #834

Open
othercorey opened this issue Jun 13, 2022 · 3 comments

Comments

@othercorey
Copy link
Member

When baking a model for a table with a column that "looks" like a foreign key such as external_id but has no target table, no validation is generated for the column. Instead an association to a non-existent model is generated.

After removing the invalid association, the user might not notice the validation is missing.

@othercorey othercorey added this to the 2.x (CakePHP 4) milestone Jun 13, 2022
@othercorey othercorey changed the title Baking model with *_id column that isn't a foreign key doesn't generate validation Table with *_id column that isn't a foreign key doesn't generate validation Jun 16, 2022
@ajibarra
Copy link
Member

ajibarra commented Jul 8, 2022

@othercorey Hi, I was trying to reproduce this bug using a table with a field theme_id and no themes table but the validation was generated correctly:

 $validator
            ->nonNegativeInteger('theme_id')
            ->requirePresence('theme_id', 'create')
            ->notEmptyString('theme_id');

Could you please provide more details about how to reproduce this bug? Please include Bake version and a DB schema if possible.

@github-actions
Copy link

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

@github-actions github-actions bot added the stale label Jan 11, 2023
@othercorey othercorey added pinned and removed stale labels Jan 11, 2023
@dereuromark
Copy link
Member

Is this still valid and reproducable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants