Skip to content

fix(query): refuse keyed values in a having and()/or() group - #1096

Merged
abnegate merged 1 commit into
mainfrom
fix/having-logical-list
Dec 1, 2026
Merged

abnegate merged 1 commit into
mainfrom
fix/having-logical-list

Conversation

@abnegate

@abnegate abnegate commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Follow-up to #1095. Having now validates the conditions of an and()/or() group itself, which skipped Filter's list-shape check, so a group whose conditions were given as an object ({"high": ..., "low": ...}) passed. It is now refused with Or query values must be a list, as a filter is.

Found in review of the Rust port (appwrite/appwrite#16355), which gets the same fix.

Test Plan

  • New QueryShapeHavingTest case for a keyed logical group; fails without the fix
  • Validator unit tests (1,093) and QueryShapeDatabaseTest pass; PHPStan clean

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • HAVING conditions now reject logical queries with keyed or associative values, providing a clearer validation error.

Validating group conditions directly skipped Filter's list-shape check, so an object of conditions passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@appwrite

appwrite Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Code review

Commit Status Tier Verdict Details
fe4ac0e Reviewed Reviewed 🟢 S · Ready to merge ✅ Approved View review

The validation change matches the existing Filter list-shape contract and includes a regression test.

The Having validator now rejects and()/or() groups whose child conditions are keyed rather than list-shaped. A regression case verifies the validator reports the list-shape error for a keyed logical group.

Walkthrough (2)
File Change
src/Database/Validator/Query/Having.php Check logical-group child values are a list before validating each child.
tests/unit/Validator/QueryShapeHavingTest.php Add a regression case for keyed conditions in an or() group.

Reviewed fe4ac0e

Tip

Comment @appwrite review to re-run, or mention @appwrite with a question.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

HAVING logical-condition validation now rejects values that are not a list and sets a method-specific error. A test checks that an Or query with keyed conditions is rejected with the expected error.

Changes: HAVING validation

Layer / File(s) Summary
Logical-condition shape validation
src/Database/Validator/Query/Having.php, tests/unit/Validator/QueryShapeHavingTest.php
isValidLogicalCondition now rejects logical-query values that are not lists and sets an error message. The test covers an Or query with keyed conditions and checks the error.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Possibly related PRs

  • utopia-php/database#1095: Changes validation of conditions in Having logical groups. Both PRs affect the validation contract for those groups.

Suggested reviewers: appwrite

Merge Risk: Minimal · up to fe4ac

This change rejects keyed logical groups in HAVING queries with a clear error, matching filter behavior. Valid list-shaped groups are unaffected, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: Having and()/or() groups now refuse keyed values, which matches the summary that Having::isValidLogicalCondition rejects non-list values with "Or query values must be a lis…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: Having and()/or() groups now refuse keyed values, which matches the summary that Having::isValidLogicalCondition rejects non-list values with "Or query values must be a list" and the new test case. The conventional-commit prefix fix(query) fits a validation bug fix. The title is specific and concise.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8ca4f54 and fe4ac0e.

Files selected for processing: 2

  • src/Database/Validator/Query/Having.php
  • tests/unit/Validator/QueryShapeHavingTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@abnegate
abnegate merged commit 13638a7 into main Dec 1, 2026
31 checks passed
@abnegate
abnegate deleted the fix/having-logical-list branch December 1, 2026 03:03
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.

1 participant