Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Maximum retries of 10000 reached without finding a unique value #2043

Open
steven7mwesigwa opened this issue Aug 13, 2020 · 1 comment
Open

Comments

@steven7mwesigwa
Copy link

steven7mwesigwa commented Aug 13, 2020

  • DistrictFactory.php
<?php

/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Models\GeneralSetting\Location\District;
use Faker\Generator as Faker;

$factory->define(District::class, function (Faker $faker) {
	return [
		"district_name" => $faker->unique()->state
	];
});
  • Error log
Seeded:  ClientsTableSeeder (0.75 seconds)
Seeding: DistrictsTableSeeder

   OverflowException

  Maximum retries of 10000 reached without finding a unique value

  at C:\xampp\htdocs\api-epitome\epitomeapi\vendor\fzaninotto\faker\src\Faker\UniqueGenerator.php:51
    47|         do {
    48|             $res = call_user_func_array(array($this->generator, $name), $arguments);
    49|             $i++;
    50|             if ($i > $this->maxRetries) {
  > 51|                 throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries));
    52|             }
    53|         } while (array_key_exists(serialize($res), $this->uniques[$name]));
    54|         $this->uniques[$name][serialize($res)]= null;
    55|

  1   C:\xampp\htdocs\api-epitome\epitomeapi\vendor\fzaninotto\faker\src\Faker\UniqueGenerator.php:32
      Faker\UniqueGenerator::__call("state", [])

  2   C:\xampp\htdocs\api-epitome\epitomeapi\database\factories\DistrictFactory.php:9
      Faker\UniqueGenerator::__get("state")
  • Faker version
    "fzaninotto/faker": "^1.9.1",

  • PHP version
    PHP 7.3.9 (cli) (built: Aug 28 2019 09:28:48) ( ZTS MSVC15 (Visual C++ 2017) x64 )

  • Laravel version
    "laravel/framework": "^7.0",

@Guxinpei
Copy link

Guxinpei commented Sep 18, 2020

Hi @steven7mwesigwa
Please sure do not use it more than numbers of state, this will happen when every state already used.

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

No branches or pull requests

2 participants