mercredi 8 janvier 2020

ActiveRecord::NotNullViolation - Mysql2 Column cannot be null

I run into a problem when creating a record via FactoryBot, the problem only occurs at the test environment.

When I run a command at the development console:

FactoryBot.create(:accounting_pbs_reservation, factor: 3.0) (Column factor is defined at the factories too, but I want to pass it explicitly)

Then it's correctly executed and created, but when I run the command at the test environment, then it prints the error:

ActiveRecord::NotNullViolation:
  Mysql2::Error: Column 'factor' cannot be null: 
INSERT INTO `accounting_pbs_reservations` (`start`, `rl_walltime`, `factor`) 
VALUES (1503468000, 1430000, 3.0)

Even when the factor column is presented.

The problem also occurs when I want to create an instance of the model in RSpec controller.

Did anybody runs into a same problem? The database schema for test and development

Aucun commentaire:

Enregistrer un commentaire