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

Support equality coercions, in particular in implicit joins #4025

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ten0
Copy link
Member

@Ten0 Ten0 commented May 14, 2024

Not sure to what extent we want this because it's maybe a bit edge-case to support.

I've needed it because I'm joining on a partially-migrated schema that has FK types as i64 and source table as i32, but I'd be fine with just having that merged in our fork until it's fully migrated.

Nonetheless it's implemented so I'm opening this draft PR to gather feedback on whether this is something that we want to support or whether it's not worth it.

@weiznich
Copy link
Member

I think I would rather prefer having a more general solution here. Something along the lines like

impl<T> AsExpression<Int8> for T
where T: Expression<SqlType = Int4> {
 // …
}

That particular impl runs into a conflicting implementation issue, which might be possible to solve. We would also need to investigate whether that causes type inference issues in some situations.

Another alternative is to expose a better structured variant of the internal coerce expression:

https://github.com/diesel-rs/diesel/blob/16c4cf78dda73a7f72d5a7735bc3c79c7a39848a/diesel/src/expression/coerce.rs

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