8000 fix(executor): order strings lexicographically in comparison predicates by rnewman · Pull Request #312 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(executor): order strings lexicographically in comparison predicates - #312

Merged
adityamukho merged 1 commit into
project-minigraf:mainfrom
rnewman:fix/string-comparison-ordering
Aug 7, 2026
Merged

adityamukho merged 1 commit into
project-minigraf:mainfrom
rnewman:fix/string-comparison-ordering

Conversation

@rnewman
@rnewman rnewman commented Aug 6, 2026
Copy link
Copy Markdown
Contributor

Summary

Every ordering predicate went through to_float_pair, which returns Err for non-numeric operands, so comparing two strings matched no rows:

  [?e :at ?d] [(>= ?d "2026-01-01")]   -> no results
  [?e :at ?d] [(<  ?d "2026-01-01")]   -> no results

Both directions empty means the filter was not partitioning the relation, it was discarding it. ISO-8601 timestamps stored as strings are the common way to hit this.

The engine already orders strings elsewhere: value_lt backs min/max (functions.rs) and value_cmp backs :order-by (executor.rs:1624), both using lexicographic Ord. Only the predicate path disagreed, so the same two strings ordered one way in an aggregate and not at all in a filter. This aligns the predicate path with the rest of the engine rather than introducing a new ordering.

Deliberately unchanged:

  • mixed-type comparison (string vs number) is still Err, as covered by test_eval_type_mismatch_comparison_is_err.
  • NaN operands still compare false for all four operators, preserved by mapping partial_cmp's None to false rather than propagating an error.
    Fixes # (issue number, if applicable)

Type of change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (requires migration or version bump)
  • Documentation / tests only

Checklist

  • cargo test passes
  • cargo clippy -- -D warnings is clean
  • cargo fmt --check passes
  • New code has tests (unit and/or integration)
  • Error paths are tested, not just happy paths
  • No unwrap() / expect() in library code paths
  • CHANGELOG.md updated under Unreleased
  • I have read PHILOSOPHY.md and this change aligns with it

Notes for reviewer

This changes the behavior of queries, which is arguably a breaking change — but that behavior was incorrect and undesirable, so I would call this a bugfix. No migration is required.

Every ordering predicate went through to_float_pair, which returns Err
for non-numeric operands, so comparing two strings matched no rows:

  [?e :at ?d] [(>= ?d "2026-01-01")]   -> no results
  [?e :at ?d] [(<  ?d "2026-01-01")]   -> no results

Both directions empty means the filter was not partitioning the
relation, it was discarding it. ISO-8601 timestamps stored as strings
are the common way to hit this.

The engine already orders strings elsewhere: value_lt backs min/max
(functions.rs) and value_cmp backs :order-by (executor.rs:1624), both
using lexicographic Ord. Only the predicate path disagreed, so the same
two strings ordered one way in an aggregate and not at all in a filter.
This aligns the predicate path with the rest of the engine rather than
introducing a new ordering.

Deliberately unchanged:
- mixed-type comparison (string vs number) is still Err, as covered by
  test_eval_type_mismatch_comparison_is_err
- NaN operands still compare false for all four operators, preserved by
  mapping partial_cmp's None to false rather than propagating an error
@rnewman
rnewman requested a review from adityamukho as a code owner August 6, 2026 02:05
@codecov
codecov Bot commented Aug 6, 2026
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/query/datalog/executor.rs 91.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 6cd784a into project-minigraf:main Aug 7, 2026
15 checks passed
adityamukho added a commit that referenced this pull request Aug 10, 2026
The report was last synced at v1.2.0 and had drifted well past this release's
own changes, so this is a complete refresh rather than a delta.

Totals: 974 -> 998 (990 passing, 8 ignored). Per-suite counts corrected against
an actual run: unit 653 -> 663, retraction 7 -> 8, predicate-expression 28 -> 32
(#312), magic sets 5 -> 7, plus section headers for complex queries (10 -> 11),
bi-temporal (10 -> 12), window functions (12 -> 14) and UDFs (9 -> 10).

The Test Execution block was the worst of it: it claimed 216 unit tests, and
six of its `--test` targets used names that no longer resolve (`bitemporal`,
`complex_queries`, ...). Names and counts now match `cargo test`, and the nine
suites that were missing entirely (disjunction, temporal metadata, production
patterns, error handling, grammar conformance, magic sets, cross-platform
compat) are listed.

"What's Not Tested Yet" listed disjunction, prepared statements and temporal
pseudo-attributes as pending; all three shipped in Phase 7.3-7.8. Replaced with
the actual roadmap gaps (#182, #183, #277, #241, #185) and a note that the
procfs-only limit on stale-lock reclamation is a real, documented constraint.

Adds a v1.2.2 section covering #312 and #304, and documents the three new
FileLock tests under Storage Backends.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QRGNkzJc5FdfpbzAh4ZZzK
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

0