Skip to content

Fix order in when conditions#96

Merged
atimin merged 2 commits into
mainfrom
preserve-order-in-query
Oct 15, 2025
Merged

Fix order in when conditions#96
atimin merged 2 commits into
mainfrom
preserve-order-in-query

Conversation

@atimin
Copy link
Copy Markdown
Member

@atimin atimin commented Oct 15, 2025

Closes #

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • [] Docs have been added / updated (for bug fixes / features)
  • CHANGELOG.md has been updated (for bug fixes / features / docs)

What kind of change does this PR introduce?

Bug fix

What was changed?

This PR fixes a bug in a query logic where the $limit clause was applied before filtering by other query parameters such as "$score". As a result, queries like { "&score": { "$eq": 10 }, $limit: 2 } could return incorrect results, since the limit was applied to the unfiltered set. With this change, the query now applies filters before applying the limit, ensuring the correct items are returned.

Related issues

None

Does this PR introduce a breaking change?

No.

Other information:

N/A

@atimin atimin requested a review from Copilot October 15, 2025 08:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for preserving key insertion order in query option serialization and introduces a test to verify record ordering in queries.

  • Switches QueryOptionsToJsonString return type from nlohmann::json to nlohmann::ordered_json.
  • Adds a new test section asserting ordered query results.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/reduct/entry_api_test.cc Adds a new SECTION validating order of returned records.
src/reduct/internal/serialisation.h Changes return type of QueryOptionsToJsonString to ordered_json to preserve key order.
src/reduct/internal/serialisation.cc Implements the ordered_json change and parses nested JSON with ordered_json::parse.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/reduct/internal/serialisation.h
Comment thread src/reduct/internal/serialisation.cc
@atimin atimin changed the title Preserve order in queries Fix order in when conditions Oct 15, 2025
@atimin atimin merged commit 502a417 into main Oct 15, 2025
2 checks passed
@atimin atimin deleted the preserve-order-in-query branch October 15, 2025 08:30
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.

2 participants