You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code compiles, and creates a useful QueryableByName trait implementation.
What is the actual output?
In the first case above, the error is:
error[E0283]: type annotations needed
--> src/main.rs:11:10
|
11 | #[derive(QueryableByName)]
| ^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `String: FromSql<_, __DB>`
= help: the following types implement trait `FromSql<A, DB>`:
<String as FromSql<Citext, Pg>>
<String as FromSql<ST, DB>>
note: required by a bound in `diesel::row::NamedRow::get`
--> /xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/diesel-2.2.2/src/row.rs:133:12
|
131 | fn get<ST, T>(&self, column_name: &str) -> deserialize::Result<T>
| --- required by a bound in this associated function
132 | where
133 | T: FromSql<ST, DB>;
| ^^^^^^^^^^^^^^^ required by this bound in `NamedRow::get`
= note: this error originates in the derive macro `QueryableByName` (in Nightly builds, run with -Z macro-backtrace for more info)
In the second case, the error is:
error[E0283]: type annotations needed
--> src/main.rs:11:10
|
11 | #[derive(QueryableByName)]
| ^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `Value: FromSql<_, __DB>`
= help: the following types implement trait `FromSql<A, DB>`:
<Value as FromSql<Json, Pg>>
<Value as FromSql<Jsonb, Pg>>
note: required by a bound in `diesel::row::NamedRow::get`
--> /xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/diesel-2.2.2/src/row.rs:133:12
|
131 | fn get<ST, T>(&self, column_name: &str) -> deserialize::Result<T>
| --- required by a bound in this associated function
132 | where
133 | T: FromSql<ST, DB>;
| ^^^^^^^^^^^^^^^ required by this bound in `NamedRow::get`
= note: this error originates in the derive macro `QueryableByName` (in Nightly builds, run with -Z macro-backtrace for more info)
Steps to reproduce
Write the code above, with diesel dependency, and features postgres (and serde_json in the second case). If added to src/main.rs, you should see the above compile errors.
Setup
Versions
Feature Flags
postgres
Problem Description
What are you trying to accomplish?
Attempting to use
QueryableByName
+sql_query
. In this case, two fields have the same type in the struct, but different SQL types.Example:
Alternative example (this also requires the
serde_json
feature of diesel):What is the expected output?
The code compiles, and creates a useful
QueryableByName
trait implementation.What is the actual output?
In the first case above, the error is:
In the second case, the error is:
Steps to reproduce
Write the code above, with
diesel
dependency, and featurespostgres
(andserde_json
in the second case). If added tosrc/main.rs
, you should see the above compile errors.Checklist
closed if this is not the case)
The text was updated successfully, but these errors were encountered: