Skip to content

Make quantity and quantity_per_user nullable in cart_rule table#1581

Merged
Quetzacoalt91 merged 1 commit intoPrestaShop:devfrom
boherm:fix-columns-quantity-total-and-per-user-for-discounts
Jan 23, 2026
Merged

Make quantity and quantity_per_user nullable in cart_rule table#1581
Quetzacoalt91 merged 1 commit intoPrestaShop:devfrom
boherm:fix-columns-quantity-total-and-per-user-for-discounts

Conversation

@boherm
Copy link
Member

@boherm boherm commented Dec 18, 2025

Questions Answers
Description? Make quantity and quantity_per_user nullable in cart_rule table. Related to PrestaShop/PrestaShop#40330
Type? improvement
BC breaks? no
Deprecations? no
Fixed ticket? ~
Sponsor company PrestaShop SA
How to test? ~

nicosomb
nicosomb previously approved these changes Dec 18, 2025
@Quetzacoalt91 Quetzacoalt91 added the Blocked Status: The issue is blocked by another task label Jan 2, 2026
@Quetzacoalt91
Copy link
Member

Blocked until PrestaShop/PrestaShop#40330 is merged

@boherm boherm force-pushed the fix-columns-quantity-total-and-per-user-for-discounts branch from e72e32f to bfd7d9e Compare January 9, 2026 08:50
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 9, 2026

@Quetzacoalt91 Quetzacoalt91 removed the Blocked Status: The issue is blocked by another task label Jan 14, 2026
@AureRita AureRita self-assigned this Jan 15, 2026
Copy link
Contributor

@AureRita AureRita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @boherm

Thank you for your PR, I tested it and it seems to works as you can see :

With PR :

Capture d’écran du 2026-01-15 17-09-35 Capture d’écran du 2026-01-16 10-55-31

without PR :

Capture d’écran du 2026-01-15 16-49-59

Tested from :
9.0.2 to 9.1.0
8.1.4 to 9.1.0

Because the PR seems to works as expected, It's QA ✔️

Thank you

@AureRita AureRita added QA ✔️ Status: Check done, Code approved and removed waiting for QA labels Jan 16, 2026
Copy link
Contributor

@Hlavtox Hlavtox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BC break

Code may stop working or throw errors if nulls are present:
if ($row['quantity'] > 0) { ... }

SQL queries with WHERE quantity = 0 can fail and not select proper lines.

@Quetzacoalt91
Copy link
Member

Quetzacoalt91 commented Jan 16, 2026

Thanks for the feedback @Hlavtox, however are you sure this is the proper place for it?

This PR is focused on the change of the database regarding another PR already merged on the core, it will be merged because Update Assistant aims to be aligned with PrestaShop. If there is a BC Break, you should warn about it either on the Core PR and/or an issue on https://github.com/PrestaShop/PrestaShop so it can be dealt with the Core team separately. 🙏

@Quetzacoalt91 Quetzacoalt91 added enhancement Type: Improvement and removed waiting for QA labels Jan 16, 2026
@Hlavtox
Copy link
Contributor

Hlavtox commented Jan 16, 2026

@Quetzacoalt91 I know, but there is no need to merge changes into autoupgrade, when the core PR is wrong and should be changed. :-)

@jolelievre
Copy link
Contributor

jolelievre commented Jan 22, 2026

@Hlavtox, this is not a breaking change, the column is made nullable, it doesn't mean we force the null value! The default value is still 0, which means all the existing cart rules will work as usual, and all the cart rules created via migration using the legacy page will work as usual.

What will change? It will only change IF you enable the discount feature flag AND you create a new discount AND you select no limit in the discount you are creating. Only in this case will you get a null value in your DB, and that's the purpose of a feature flag and an experimental feature.

The problem you mentioned can also only happen in this case, and it won't happen in the core because we already fixed/adapted the relevant places. So it's only in an external module that you will have this problem. What does it mean then? It means the module needs to adapt its code to be compatible with the future discount feature; it means that it can anticipate this change to be compatible with the future major version that will include this new discount feature.

And that's exactly the purpose of adding an experimental feature behind a feature flag. So your blocking of this PR and the modification in the core is not relevant.

@Hlavtox
Copy link
Contributor

Hlavtox commented Jan 22, 2026

So it's only in an external module that you will have this problem.

Dude, that's the whole purpose of BC break promise.

The problem is that if you enable the new discount feature, create this cart rule with no limit (which is by the way 99% of our cart rules), then you disable it, you still have the "faulty" code that will keep breaking external modules. This is a BC break.

@jolelievre
Copy link
Contributor

The problem is that if you enable the new discount feature, create this cart rule with no limit (which is by the way 99% of our cart rules), then you disable it, you still have the "faulty" code that will keep breaking external modules. This is a BC break.

Ok I anticipated this argument, but my message was already too long 😅 So experimental features are called experimental for a good reason, you're not supposed to test them on a prod environement If you want to test it safely you use a preprod or a local environment, from the moment you enable an experimental feature you are in a development context And we can't guaranty full retro compatibility from this moment even if you revert the FF

Ideally, I agree with it should be the case, but it would mean we need to implement a special revert action for each feature flag and frankly, we don't have enough time or resources for this

@Hlavtox
Copy link
Contributor

Hlavtox commented Jan 22, 2026

Hmmmm, well, OK. But it would be good to establish this "grey zone" in our ADR. :-)

Something like - it's not a BC break if you break your install because of experimental feature. WDYT?

@nicosomb
Copy link
Contributor

@Hlavtox is that ok for you to remove your block on this PR?

Copy link
Contributor

@Hlavtox Hlavtox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made an issue so it's not forgotten - PrestaShop/ADR#44

@jolelievre
Copy link
Contributor

@Hlavtox thanks, I noted it in my tasks but the issue doesn't hurt

@Quetzacoalt91 Quetzacoalt91 added this to the 7.6.0 milestone Jan 23, 2026
@Quetzacoalt91 Quetzacoalt91 merged commit 6fb95a4 into PrestaShop:dev Jan 23, 2026
69 of 71 checks passed
@github-project-automation github-project-automation bot moved this from Ready for review to Merged in PR Dashboard Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Type: Improvement Migration script QA ✔️ Status: Check done, Code approved

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants