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

[cpp] Ensure sequential order for getfirstID etc #5593

Merged
merged 1 commit into from
May 3, 2024

Conversation

MowFord
Copy link
Contributor

@MowFord MowFord commented May 3, 2024

I affirm:

  • I understand that if I do not agree to the following points by completing the checkboxes my PR will be ignored.
  • I understand I should leave resolving conversations to the LandSandBoat team so that reviewers won't miss what was said.
  • I have read and understood the Contributing Guide and the Code of Conduct.
  • I have tested my code and the things my code has changed since the last commit in the PR and will test after any later commits.

What does this pull request do?

As mentioned in this PR, the IDs.lua helper functions rely on pulling the list of sequential npc and mobs from a zone to do shift-proof mappings. The query in luautils was not ensuring proper order, and relying on the results to always be in the order of insertion. There are scenarios where mariadb does not return those results in order of smallest to greatest ID (modules doing inserts/deletes would be the most obvious, but i'm sure there are others)

Steps to test these changes

Compile with this change, see that GetFirstID and GetTableOfIDs return what you would expect in terms of the objects being in order of smallest IDs first

Copy link
Contributor

@zach2good zach2good left a comment

Choose a reason for hiding this comment

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

SQL keywords in caps please, to help differentiate them from args like mobid

@zach2good
Copy link
Contributor

Also, add ASC or DESC to the ORDER BY for clarity

@MowFord
Copy link
Contributor Author

MowFord commented May 3, 2024

Also, add ASC or DESC to the ORDER BY for clarity

aww no fair I was doing that anyway!

@zach2good
Copy link
Contributor

https://learn.microsoft.com/en-us/sql/t-sql/queries/select-order-by-clause-transact-sql?view=sql-server-ver16

The order in which rows are returned in a result set are not guaranteed unless an ORDER BY clause is specified.

Huh, TIL, makes sense

@zach2good zach2good merged commit 8cae00c into LandSandBoat:base May 3, 2024
11 checks passed
@CatsEyeXI CatsEyeXI deleted the getfirstid_order branch May 10, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants