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

Regression in distinct_on: cannot use .nullable() on column #3766

Closed
3 tasks done
Ploppz opened this issue Aug 27, 2023 · 0 comments · Fixed by #3793
Closed
3 tasks done

Regression in distinct_on: cannot use .nullable() on column #3766

Ploppz opened this issue Aug 27, 2023 · 0 comments · Fixed by #3793
Labels

Comments

@Ploppz
Copy link
Contributor

Ploppz commented Aug 27, 2023

Setup

Versions

  • Rust: rustc 1.71.1
  • Diesel: 2.1.1
  • Database: Postgres
  • Operating System Linux

Problem Description

Code using fn distinct_on works in Diesel v2.0.1 but not in v2.1.1.

Minimal reproducible example: https://gist.github.com/Ploppz/f8235d83f287bb7926655cd91dfba8fa
Cargo.toml: diesel = { version = "=2.0.1", features = ["postgres", "r2d2"] }

It compiles in v2.0.1 but in v2.1.1 there is the compiler error:

error[E0277]: the trait bound `NullableExpression<measurement::columns::id>: Column` is not satisfied
  --> src/main.rs:74:10
   |
74 |         .distinct_on(m::id.nullable())
   |          ^^^^^^^^^^^ the trait `Column` is not implemented for `NullableExpression<measurement::columns::id>`
   |

So I tried to remove the nullable() so the two lines become:

        .order_by((m::id, wj::submit_date.nullable().desc()))
        .distinct_on(m::id)

But then I get the error:

error[E0271]: type mismatch resolving `<Only<table> as AppearsInFromClause<table>>::Count == Never`
  --> src/main.rs:74:10
   |
74 |         .distinct_on(m::id)
   |          ^^^^^^^^^^^ expected `Once`, found `Never`
   |

Which makes sense I guess, because the measurement table is left-joined so m::id is not always present.

Checklist

  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
  • This issue can be reproduced without requiring a third party crate
@Ploppz Ploppz added the bug label Aug 27, 2023
weiznich added a commit to weiznich/diesel that referenced this issue Sep 15, 2023
This commit fixes diesel-rs#3766 by adding all the missing impls. It uses the
same strategy as diesel-rs#3643 for all implementations.
@weiznich weiznich mentioned this issue Sep 15, 2023
weiznich added a commit to weiznich/diesel that referenced this issue Sep 15, 2023
This commit fixes diesel-rs#3766 by adding all the missing impls. It uses the
same strategy as diesel-rs#3643 for all implementations.
weiznich added a commit to weiznich/diesel that referenced this issue Sep 20, 2023
This commit fixes diesel-rs#3766 by adding all the missing impls. It uses the
same strategy as diesel-rs#3643 for all implementations.
github-merge-queue bot pushed a commit that referenced this issue Sep 20, 2023
weiznich added a commit to weiznich/diesel that referenced this issue Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant