Skip to content

Derive Ord and PartialOrd for Auto#544

Open
ElijahAhianyo wants to merge 1 commit intomasterfrom
elijah/auto-query-fix
Open

Derive Ord and PartialOrd for Auto#544
ElijahAhianyo wants to merge 1 commit intomasterfrom
elijah/auto-query-fix

Conversation

@ElijahAhianyo
Copy link
Copy Markdown
Contributor

Description

This allows us to do this:

#[model]
#[derive(Debug, Clone)]
struct Foo{
   id: Auto<i64>
}

...

let _ = query!(Foo, $id > 1).all(&db).await.unwrap();

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / cleanup
  • Performance improvement
  • Other (describe above)

Checklist

  • I've read the contributing guide
  • Tests pass locally (just test-all)
  • Code passes clippy (just clippy)
  • Code is properly formatted (cargo fmt)
  • New tests added (regression test for bugs, coverage for new features)
  • Documentation (both code and site) updated (if applicable)

@github-actions github-actions bot added the C-lib Crate: cot (main library crate) label Apr 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

🐰 Bencher Report

Branchelijah/auto-query-fix
Testbedgithub-ubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
empty_router/empty_router📈 view plot
🚷 view threshold
6.68 ms
(+9.99%)Baseline: 6.07 ms
7.37 ms
(90.59%)
json_api/json_api📈 view plot
🚷 view threshold
1.20 ms
(+13.45%)Baseline: 1.06 ms
1.26 ms
(95.42%)
nested_routers/nested_routers📈 view plot
🚷 view threshold
1.10 ms
(+12.58%)Baseline: 0.97 ms
1.15 ms
(95.51%)
single_root_route/single_root_route📈 view plot
🚷 view threshold
1.06 ms
(+13.32%)Baseline: 0.94 ms
1.11 ms
(95.32%)
single_root_route_burst/single_root_route_burst📈 view plot
🚷 view threshold
17.72 ms
(+0.23%)Baseline: 17.68 ms
21.08 ms
(84.05%)
🐰 View full continuous benchmarking report in Bencher

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
rust 89.99% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cot/src/db.rs 86.17% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ElijahAhianyo ElijahAhianyo requested review from m4tx and seqre April 5, 2026 13:12
@ElijahAhianyo
Copy link
Copy Markdown
Contributor Author

@m4tx some more info on this from our call earlier today.

query!(Foo, $id > 1).all(&db).await.unwrap();

expands to become:

<Foo as ::cot::db::Model>::objects().filter(
        ::cot::db::query::ExprOrd::gt(<Order as ::cot::db::Model>::Fields::id, 1)
  )

The impl of ExprOrd::gt requires that the ToDbFieldValue (Auto in this case) implements Ord as well:

impl<T: ToDbFieldValue + Ord + 'static> ExprOrd<T> for FieldRef<T> {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-lib Crate: cot (main library crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants