Extending customer results SQLSTATE[23000]
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 72
- Joined: 22 Mar 2021, 16:56
Extending customer results SQLSTATE[23000]
Hello,
Ive extended the customer following the decorator method described in the docs.
I notice in my logs that I am seeing the following errors. Specifically when the user checks out as a guest and check the box to create an account - which is obviously failing.
My implementation is simple, here is the attributes I am using in the decorator.
And here is my schemea
I know I can make the field nullable which solves the issue, perhaps that what I should do...but I would prefer to use an integer here. Reading the docs on the doctrine website the default is nullable so I shouldn't need to set the notnull flag
Does anyone have similar experiences?
Thanks
Ive extended the customer following the decorator method described in the docs.
I notice in my logs that I am seeing the following errors. Specifically when the user checks out as a guest and check the box to create an account - which is obviously failing.
Code: Select all
Unable to create an account: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'reward_points' cannot be null:
Code: Select all
[
'reward_points' => [
'code' => 'reward_points',
'internalcode' => ' lvu."reward_points"',
'label' => 'Reward Points',
'type' => 'integer',
'internaltype' => Base::PARAM_INT,
],
]
Code: Select all
[
'table' => [
'users' => function (Schema $schema) {
$table = $schema->getTable('users');
$table->addColumn('reward_points', 'integer', [
'default' => 0,
]);
return $schema;
},
]
]
Does anyone have similar experiences?
Thanks
Re: Extending customer results SQLSTATE[23000]
Doctrine default value settting is NOT NULL, thus the message.
You should add
if your schema file. The other option is to overwrite the item and manager like described here:
https://aimeos.org/docs/latest/models/e ... custom-way
You should add
Code: Select all
'notnull' => false
https://aimeos.org/docs/latest/models/e ... custom-way
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 72
- Joined: 22 Mar 2021, 16:56
Re: Extending customer results SQLSTATE[23000]
Thanks for confirming. What is confusing me is the default value you assign in the schema?
If there is no value, then I would expect the default to have been used in this instance.
It seems like my options are
1. Make the the column nullable
2. Overwrite the manager and manually assign the default.
If there is no value, then I would expect the default to have been used in this instance.
It seems like my options are
1. Make the the column nullable
2. Overwrite the manager and manually assign the default.
-
- Posts: 72
- Joined: 22 Mar 2021, 16:56
Re: Extending customer results SQLSTATE[23000]
A few months later and I have come across this thread I created after still having the issue
I managed to solve it and not have to go through the process of implementing new managers, items and queries by implementing the following method in my decorator which sets the default value.
I managed to solve it and not have to go through the process of implementing new managers, items and queries by implementing the following method in my decorator which sets the default value.
Code: Select all
public function createItem(array $values = []): \Aimeos\MShop\Common\Item\Iface
{
return parent::createItem(array_merge($values, [
'reward_points' => 0
]));
}