Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unique constraint from order_key to prevent empty key conflict. #37594

Merged
merged 3 commits into from Apr 13, 2023

Conversation

vedanshujain
Copy link
Contributor

@vedanshujain vedanshujain commented Apr 6, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

While order_key is generally expected to be unique per order, it looks like it's not necessarily true, and orders can have no keys at all. In this case, wpdb->prepare converts a null value to an empty string, which conflicts with existing orders that also don't have any order key.

This PR removes the unique constraint and makes it consistent with the post store. Note that migration for existing orders will be tackled in a different PR.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

Delete the orders table by going to WooCommerce > Status > Tools. Create the tables again, verify that unique constraint is removed.

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Apr 6, 2023
Some order can have order key set to empty string. This commit disallows fetching those orders via key at DB level (its already disallowed from interface).
@github-actions
Copy link
Contributor

github-actions bot commented Apr 6, 2023

Test Results Summary

Commit SHA: 408cf92

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 51s
E2E Tests1860010019613m 49s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@vedanshujain vedanshujain requested review from a team and barryhughes and removed request for a team April 7, 2023 12:02
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2023

Hi @barryhughes,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Member

@barryhughes barryhughes left a comment

Choose a reason for hiding this comment

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

Looks good, one minor tweak to consider re changelog messaging.

I also wondered, should we have a migration in relation to this, or is that non-essential at this stage?

plugins/woocommerce/changelog/fix-order_key_migration Outdated Show resolved Hide resolved
Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>
@vedanshujain
Copy link
Contributor Author

I also wondered, should we have a migration in relation to this, or is that non-essential at this stage?

I am working on an optional migration for both this and #37676 in a separate PR.

@barryhughes barryhughes merged commit fdd0135 into trunk Apr 13, 2023
18 checks passed
@barryhughes barryhughes deleted the fix/order_key_migration branch April 13, 2023 15:50
@github-actions github-actions bot added this to the 7.7.0 milestone Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants