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

Incorrect faker provider generated from column defined as "name: enum" #691

Open
runofthemill opened this issue Jun 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@runofthemill
Copy link

  • Laravel Version: 11.1.1
  • PHP Version: 8.3.7
  • Blueprint Version: 2.10.0
  • Platform: Mac

Issue:

It's possible this is intended behavior, but feels more like a bug?

If I define a model with a column name of name and a type enum

models:
  Post:
    name: enum:one,two,three

I would expect the generated factory definition to look like this

return [
  'name' => $this->faker->randomElement(["one","two","three"]),
];

but instead I get

return [
  'name' => $this->faker->name(),
];

Looks like the FactoryGenerator looks for an implicit match before an explicit one:

$faker = FakerRegistry::fakerData($column->name()) ?? FakerRegistry::fakerDataType($column->dataType());

Repro:

composer create-project laravel/laravel example-app
cd example-app
composer require -W --dev laravel-shift/blueprint
php artisan blueprint:new
# fill in draft.yaml as above
php artisan blueprint:build

As a workaround I can easily change the name of the column, but as-is the generated migration ends up with $table->enum('name', ["one","two","three"]);, so if nothing else, the logic seems to differ a bit between the Factory and Migration generators ¯\_(ツ)_/¯

@runofthemill runofthemill added bug Something isn't working pending This issue is pending review labels Jun 7, 2024
@jasonmccreary jasonmccreary removed the pending This issue is pending review label Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants