bake icon indicating copy to clipboard operation
bake copied to clipboard

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

Open othercorey opened this issue 2 years ago • 3 comments

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 avatar Jun 13 '22 21:06 othercorey

@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.

ajibarra avatar Jul 08 '22 08:07 ajibarra

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[bot] avatar Jan 11 '23 00:01 github-actions[bot]

Is this still valid and reproducable?

dereuromark avatar Nov 03 '23 11:11 dereuromark