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

Can't implement InternalSaveChangesDsl for another backend #1736

Closed
pgab opened this Issue May 28, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@pgab

pgab commented May 28, 2018

Setup

Versions

  • Rust: nightly-2018-03-07-x86_64-unknown-linux-gnu
  • Diesel: 1.2.2
  • Database: Oracle 12g
  • Operating System Ubuntu 18.04

Problem Description

I am trying to get another backend for diesel working. Namely oracle/oci. Therefore I need to implement e.g. InternalSaveChangesDsl. Since all oracle/oci related code is currently outside of diesel, it is impossible to implement this. Please note that I made save_changes_dsl public.

What is the actual output?

error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct<T>`); only traits defined in the current crate can be implemented for a type parameter
  --> src/oracle/query_dsl/save_changes_dsl.rs:15:1
   |
15 | / impl<T, U> InternalSaveChangesDsl<OciConnection, U> for T
16 | |     where
17 | |         T: Copy + Identifiable,
18 | |         T: AsChangeset<Target = <T as HasTable>::Table> + IntoUpdateTarget,
...  |
26 | |     }
27 | | }
   | |_^

Steps to reproduce

There is some code at https://github.com/GiGainfosystems/diesel-oci/tree/feature/save_changes_dsl available. I also had to change some diesel code: https://github.com/GiGainfosystems/diesel/tree/feature/save_changes_dsl
Within diesel/diesel_tests I run

cargo +nightly test --features oracle

Checklist

  • I have already looked over the issue tracker for similar issues.
  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
@sgrif

This comment has been minimized.

Member

sgrif commented May 29, 2018

This isn't really a bug in Diesel, but more a limitation of the language. To fix this we would need disjointness based on associated types, and probably specialization as well. Without those in the language, there's nothing we can do about this. The orphan rules exist for a reason.

@sgrif sgrif closed this May 29, 2018

@sgrif

This comment has been minimized.

Member

sgrif commented May 29, 2018

@weiznich Has an idea about how to fix this.

@sgrif sgrif reopened this May 29, 2018

weiznich added a commit to GiGainfosystems/diesel that referenced this issue May 30, 2018

Restructure `InternalSaveChangesDsl`
This allows this trait to be implemented outside of diesel.
Also reexport this trait as hidden api. (It is only usfull if someone
tries to implement a additional backend)

Fix diesel-rs#1736

weiznich added a commit to weiznich/diesel that referenced this issue Jun 7, 2018

Restructure `InternalSaveChangesDsl`
This allows this trait to be implemented outside of diesel.
Also reexport this trait as hidden api. (It is only usfull if someone
tries to implement a additional backend)

Fix diesel-rs#1736
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment