Recommand · May 14, 2022 0


Symfony – fixtures load throw unexpected error

In my Symfony 6 project, I am trying to load a fixture:

 /**
 * @param ObjectManager $manager
 */
public function load(ObjectManager $manager): void
{
    $manager1 = $manager;
    $manager1->persist($this->persistCompanyOne());
    $manager1->flush();
}

private function persistCompanyOne(): Company
{
    $company = new Company();
    $company->setCompanyName('Company One');
    return $company;
}

And my Company entity:

/**
 * @ORM\Column(type="string", length=180, nullable=false)
 */
private string $companyName;

 /**
 * @return string
 */
 public function getCompanyName(): string
 {
   return $this->name;
 }

   /**
     * @param mixed
     * @return Company
     */
    public function setCompanyName(string $name): Company
    {
        $this->name = $name;
        return $this;
    }

When running php bin/console doctrine:fixtures:load I get an error:

 Integrity constraint violation: 1048 Column 'company_name' cannot be null

Can not figure out what can be the problem? it’s pretty straightforward..




You may also like…




amazon-web-services android angular api arrays c# css dart dataframe django docker excel express firebase flutter html ios java javascript jquery json kotlin laravel linux list mongodb mysql node.js pandas php postgresql python python-3.x r react-native reactjs regex spring spring-boot sql sql-server string swift typescript vue.js