You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, I posted this issue => #36033, but it's not really an issue but a discussion (thanks @Progi1984 for this advice).
I think Prestashop database schema isn't strong enough.
Prestashop database doesn't have default value for several fields. But a lot of them can be set to 0. For example, into ps_specific_prices, id_specific_price_rule can be equal to 0.
So when a developer does an insert, he may ignore it because it's null.
If MySQL/MariaDB SQL MODE is set to STRICT_TRANS_TABLES, (the default install value), it will work.
But if your sysadmin uses STRICT_ALL_TABLES, it won't work.
I think it can be a good practice to fix this in order to make all development stronger.
Example:
In phpmyadmin, to this request: INSERT INTO ps_specific_price SET id_product = '1',id_shop = '0',id_currency = '0',id_country = '0',id_group = '0',id_customer = '1',id_product_attribute = '',price = '-1',from_quantity = '1',reduction = '0.1',reduction_tax = '0',reduction_type = 'percentage'
with STRICT_TRANS_TABLES, we have only warning, but it "works":
If you switch to STRICT_ALL_TABLES, all warnings become fatal error.
The solution
First, I suggest,"asap" to update documentation in order to recommend SQL_MODE "STRICT_TRANS_TABLES" because it will hide the problem, and it can help to not have some strange bug.
And later, add everywhere default value in database schema.
Alternatives
I think community should talk about it. We can think this is a developer QA issue, he must check his request with all sql_mode. It's not a Prestashop core problem.
Or maybe, the spirit of Prestashop core is to do core strong as possible, and this can help.
Let's talk about it!
Additional context
(maybe I can help with a PR, but i don't check the box, I should internal validate it before)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The problem
First, I posted this issue => #36033, but it's not really an issue but a discussion (thanks @Progi1984 for this advice).
I think Prestashop database schema isn't strong enough.
Prestashop database doesn't have default value for several fields. But a lot of them can be set to 0. For example, into ps_specific_prices, id_specific_price_rule can be equal to 0.
So when a developer does an insert, he may ignore it because it's null.
If MySQL/MariaDB SQL MODE is set to STRICT_TRANS_TABLES, (the default install value), it will work.
But if your sysadmin uses STRICT_ALL_TABLES, it won't work.
I think it can be a good practice to fix this in order to make all development stronger.
Example:
In phpmyadmin, to this request:
INSERT INTO ps_specific_price SET id_product = '1',id_shop = '0',id_currency = '0',id_country = '0',id_group = '0',id_customer = '1',id_product_attribute = '',price = '-1',from_quantity = '1',reduction = '0.1',reduction_tax = '0',reduction_type = 'percentage'
with STRICT_TRANS_TABLES, we have only warning, but it "works":
If you switch to STRICT_ALL_TABLES, all warnings become fatal error.
The solution
First, I suggest,"asap" to update documentation in order to recommend SQL_MODE "STRICT_TRANS_TABLES" because it will hide the problem, and it can help to not have some strange bug.
And later, add everywhere default value in database schema.
Alternatives
I think community should talk about it. We can think this is a developer QA issue, he must check his request with all sql_mode. It's not a Prestashop core problem.
Or maybe, the spirit of Prestashop core is to do core strong as possible, and this can help.
Let's talk about it!
Additional context
(maybe I can help with a PR, but i don't check the box, I should internal validate it before)
Do you plan to work on this subject?
Beta Was this translation helpful? Give feedback.
All reactions