Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Set an explicit fallback ORDER BY for the migrate command #84

Merged
merged 1 commit into from
Sep 24, 2018

Conversation

stevegrunwell
Copy link
Contributor

When a test creates multiple test orders within the same second, the resulting products cause MySQL to try to guess which order should come first rather than — as I had assumed — falling back to sorting by ID. As a result, ordering products by p.post_date alone cannot reliably keep two orders sorted the same way, since MySQL may decide to give precedence to any one of the rows with matching timestamps. Further details are available in MySQL's "ORDER BY Optimization" documentation.

This PR ensures that the migrate command explicitly falls back to sorting by wp_posts.ID in descending order, which matches the intent of "migrate the most recent orders (which are presumably more likely to be active) first, working backwards historically".

Additionally, this PR cleans up instances where tests were passing integers instead of arrays to TestCase::count_orders_in_table_with_ids(), relying on type coercion.

Fixes #83.

When a test creates multiple test orders within the same second, the resulting products cause MySQL to try to guess which order should come first rather than — as I had assumed — falling back to sorting by ID. As a result, ordering products by p.post_date alone cannot reliably keep two orders sorted the same way, since MySQL may decide to give precedence to any one of the rows with matching timestamps. Further details are [available in MySQL's "ORDER BY Optimization" documentation](https://dev.mysql.com/doc/refman/5.5/en/order-by-optimization.html).

This commit ensures that the `migrate` command explicitly falls back to sorting by `wp_posts.ID` in descending order, which matches the intent of "migrate the most recent orders (which are presumably more likely to be active) first, working backwards historically".

Additionally, this commit cleans up instances where tests were passing integers instead of arrays to `TestCase::count_orders_in_table_with_ids()`, relying on type coercion.

Fixes #83.
@stevegrunwell stevegrunwell added bug testing cli migration Issues related to the WP-CLI migration script labels Sep 24, 2018
@stevegrunwell stevegrunwell added this to the Version 1.0.0 milestone Sep 24, 2018
@bswatson bswatson merged commit a4034b0 into develop Sep 24, 2018
@bswatson bswatson deleted the fix/migration-test-issues branch September 24, 2018 17:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug cli migration Issues related to the WP-CLI migration script testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants