Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rkusa committed Jun 7, 2024
1 parent 70e4089 commit 093039e
Show file tree
Hide file tree
Showing 19 changed files with 396 additions and 110 deletions.
2 changes: 1 addition & 1 deletion postgres-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn derive_fromsql(input: TokenStream) -> TokenStream {
.into()
}

#[proc_macro_derive(Enum, attributes(postgres))]
#[proc_macro_derive(Enum)]
pub fn derive_enum(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
error[E0277]: the trait bound `Role: Query<sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>>>>` is not satisfied
error[E0277]: the trait bound `Role: sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>>>>` is not satisfied
--> tests/fail-nightly/enum_array_to_enum_literal.rs:17:10
|
17 | .await
| -^^^^^
| ||
| |the trait `Query<sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>>>>` is not implemented for `Role`, which is required by `Sql<'_, sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>>>, _>: IntoFuture`
| |the trait `sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>>>>` is not implemented for `Role`, which is required by `Sql<'_, sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>>>, _>: IntoFuture`
| help: remove the `.await`
|
= help: the following other types implement trait `Query<Cols>`:
<() as Query<()>>
<Option<T> as Query<Primitive<<T as SqlType>::Type>>>
<Option<T> as Query<Struct<Cols>>>
<Option<Vec<u8>> as Query<Primitive<Bytea>>>
<Vec<T> as Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as Query<Struct<Cols>>>
<Vec<T> as Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Vec<Vec<u8>> as Query<Primitive<Bytea>>>
= help: the following other types implement trait `sqlm_postgres::query::Query<Cols>`:
<() as sqlm_postgres::query::Query<()>>
<Option<T> as sqlm_postgres::query::Query<Primitive<<T as SqlType>::Type>>>
<Option<T> as sqlm_postgres::query::Query<Struct<Cols>>>
<Option<Vec<u8>> as sqlm_postgres::query::Query<Primitive<Bytea>>>
<Vec<T> as sqlm_postgres::query::Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as sqlm_postgres::query::Query<Struct<Cols>>>
<Vec<T> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<Primitive<Bytea>>>
and $N others
= note: required for `Sql<'_, sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>>>, Role>` to implement `IntoFuture`
18 changes: 9 additions & 9 deletions postgres-macros/tests/fail-nightly/enum_extra_variant.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error[E0277]: the trait bound `Vec<User>: Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not satisfied
error[E0277]: the trait bound `Vec<User>: sqlm_postgres::query::Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not satisfied
--> tests/fail-nightly/enum_extra_variant.rs:26:59
|
26 | let _: Vec<User> = sql!("SELECT id, role FROM users").await.unwrap();
| -^^^^^
| ||
| |the trait `Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not implemented for `Vec<User>`, which is required by `Sql<'_, Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>, _>: IntoFuture`
| |the trait `sqlm_postgres::query::Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not implemented for `Vec<User>`, which is required by `Sql<'_, Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>, _>: IntoFuture`
| help: remove the `.await`
|
= help: the following other types implement trait `Query<Cols>`:
<Vec<T> as Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as Query<Struct<Cols>>>
<Vec<T> as Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Vec<Vec<u8>> as Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as Query<sqlm_postgres::types::Array<Vec<Bytea>>>>
<Vec<u8> as Query<Primitive<Bytea>>>
= help: the following other types implement trait `sqlm_postgres::query::Query<Cols>`:
<Vec<T> as sqlm_postgres::query::Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as sqlm_postgres::query::Query<Struct<Cols>>>
<Vec<T> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<Bytea>>>>
<Vec<u8> as sqlm_postgres::query::Query<Primitive<Bytea>>>
= note: required for `Sql<'_, Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>, Vec<User>>` to implement `IntoFuture`
18 changes: 9 additions & 9 deletions postgres-macros/tests/fail-nightly/enum_missing_variant.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error[E0277]: the trait bound `Vec<User>: Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not satisfied
error[E0277]: the trait bound `Vec<User>: sqlm_postgres::query::Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not satisfied
--> tests/fail-nightly/enum_missing_variant.rs:20:59
|
20 | let _: Vec<User> = sql!("SELECT id, role FROM users").await.unwrap();
| -^^^^^
| ||
| |the trait `Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not implemented for `Vec<User>`, which is required by `Sql<'_, Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>, _>: IntoFuture`
| |the trait `sqlm_postgres::query::Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not implemented for `Vec<User>`, which is required by `Sql<'_, Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>, _>: IntoFuture`
| help: remove the `.await`
|
= help: the following other types implement trait `Query<Cols>`:
<Vec<T> as Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as Query<Struct<Cols>>>
<Vec<T> as Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Vec<Vec<u8>> as Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as Query<sqlm_postgres::types::Array<Vec<Bytea>>>>
<Vec<u8> as Query<Primitive<Bytea>>>
= help: the following other types implement trait `sqlm_postgres::query::Query<Cols>`:
<Vec<T> as sqlm_postgres::query::Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as sqlm_postgres::query::Query<Struct<Cols>>>
<Vec<T> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<Bytea>>>>
<Vec<u8> as sqlm_postgres::query::Query<Primitive<Bytea>>>
= note: required for `Sql<'_, Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>, Vec<User>>` to implement `IntoFuture`
18 changes: 9 additions & 9 deletions postgres-macros/tests/fail-nightly/enum_variant_mismatch.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error[E0277]: the trait bound `Vec<User>: Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not satisfied
error[E0277]: the trait bound `Vec<User>: sqlm_postgres::query::Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not satisfied
--> tests/fail-nightly/enum_variant_mismatch.rs:23:59
|
23 | let _: Vec<User> = sql!("SELECT id, role FROM users").await.unwrap();
| -^^^^^
| ||
| |the trait `Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not implemented for `Vec<User>`, which is required by `Sql<'_, Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>, _>: IntoFuture`
| |the trait `sqlm_postgres::query::Query<Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>>` is not implemented for `Vec<User>`, which is required by `Sql<'_, Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>, _>: IntoFuture`
| help: remove the `.await`
|
= help: the following other types implement trait `Query<Cols>`:
<Vec<T> as Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as Query<Struct<Cols>>>
<Vec<T> as Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Vec<Vec<u8>> as Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as Query<sqlm_postgres::types::Array<Vec<Bytea>>>>
<Vec<u8> as Query<Primitive<Bytea>>>
= help: the following other types implement trait `sqlm_postgres::query::Query<Cols>`:
<Vec<T> as sqlm_postgres::query::Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as sqlm_postgres::query::Query<Struct<Cols>>>
<Vec<T> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<Bytea>>>>
<Vec<u8> as sqlm_postgres::query::Query<Primitive<Bytea>>>
= note: required for `Sql<'_, Struct<(StructColumn<i64, "id">, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<"admin">, EnumVariant<"user">)>, "role">)>, Vec<User>>` to implement `IntoFuture`
22 changes: 11 additions & 11 deletions postgres-macros/tests/fail-nightly/literal_array_to_literal.stderr
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
error[E0277]: the trait bound `String: Query<sqlm_postgres::types::Array<Vec<String>>>` is not satisfied
error[E0277]: the trait bound `String: sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<String>>>` is not satisfied
--> tests/fail-nightly/literal_array_to_literal.rs:6:10
|
6 | .await
| -^^^^^
| ||
| |the trait `Query<sqlm_postgres::types::Array<Vec<String>>>` is not implemented for `String`, which is required by `Sql<'_, sqlm_postgres::types::Array<Vec<String>>, _>: IntoFuture`
| |the trait `sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<String>>>` is not implemented for `String`, which is required by `Sql<'_, sqlm_postgres::types::Array<Vec<String>>, _>: IntoFuture`
| help: remove the `.await`
|
= help: the following other types implement trait `Query<Cols>`:
<() as Query<()>>
<Option<T> as Query<Primitive<<T as SqlType>::Type>>>
<Option<T> as Query<Struct<Cols>>>
<Option<Vec<u8>> as Query<Primitive<Bytea>>>
<Vec<T> as Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as Query<Struct<Cols>>>
<Vec<T> as Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Vec<Vec<u8>> as Query<Primitive<Bytea>>>
= help: the following other types implement trait `sqlm_postgres::query::Query<Cols>`:
<() as sqlm_postgres::query::Query<()>>
<Option<T> as sqlm_postgres::query::Query<Primitive<<T as SqlType>::Type>>>
<Option<T> as sqlm_postgres::query::Query<Struct<Cols>>>
<Option<Vec<u8>> as sqlm_postgres::query::Query<Primitive<Bytea>>>
<Vec<T> as sqlm_postgres::query::Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as sqlm_postgres::query::Query<Struct<Cols>>>
<Vec<T> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<Primitive<Bytea>>>
and $N others
= note: required for `Sql<'_, sqlm_postgres::types::Array<Vec<String>>, String>` to implement `IntoFuture`
22 changes: 11 additions & 11 deletions postgres-macros/tests/fail-stable/enum_array_to_enum_literal.stderr
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
error[E0277]: the trait bound `Role: Query<sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>>>>` is not satisfied
error[E0277]: the trait bound `Role: sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>>>>` is not satisfied
--> tests/fail-stable/enum_array_to_enum_literal.rs:17:10
|
17 | .await
| -^^^^^
| ||
| |the trait `Query<sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>>>>` is not implemented for `Role`, which is required by `Sql<'_, sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>>>, _>: IntoFuture`
| |the trait `sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>>>>` is not implemented for `Role`, which is required by `Sql<'_, sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>>>, _>: IntoFuture`
| help: remove the `.await`
|
= help: the following other types implement trait `Query<Cols>`:
<Vec<u8> as Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as Query<sqlm_postgres::types::Array<Vec<Bytea>>>>
<Vec<T> as Query<Struct<Cols>>>
<Vec<T> as Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Option<Vec<u8>> as Query<Primitive<Bytea>>>
<Option<T> as Query<Struct<Cols>>>
= help: the following other types implement trait `sqlm_postgres::query::Query<Cols>`:
<Vec<u8> as sqlm_postgres::query::Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<Bytea>>>>
<Vec<T> as sqlm_postgres::query::Query<Struct<Cols>>>
<Vec<T> as sqlm_postgres::query::Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
<Option<Vec<u8>> as sqlm_postgres::query::Query<Primitive<Bytea>>>
<Option<T> as sqlm_postgres::query::Query<Struct<Cols>>>
and $N others
= note: required for `Sql<'_, sqlm_postgres::types::Array<Vec<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>>>, Role>` to implement `IntoFuture`
18 changes: 9 additions & 9 deletions postgres-macros/tests/fail-stable/enum_extra_variant.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error[E0277]: the trait bound `Vec<User>: Query<Struct<(StructColumn<i64, 6898215271518772730>, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>, 18137070463969723500>)>>` is not satisfied
error[E0277]: the trait bound `Vec<User>: sqlm_postgres::query::Query<Struct<(StructColumn<i64, 6898215271518772730>, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>, 18137070463969723500>)>>` is not satisfied
--> tests/fail-stable/enum_extra_variant.rs:26:59
|
26 | let _: Vec<User> = sql!("SELECT id, role FROM users").await.unwrap();
| -^^^^^
| ||
| |the trait `Query<Struct<(StructColumn<i64, 6898215271518772730>, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>, 18137070463969723500>)>>` is not implemented for `Vec<User>`, which is required by `Sql<'_, Struct<(StructColumn<i64, 6898215271518772730>, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>, 18137070463969723500>)>, _>: IntoFuture`
| |the trait `sqlm_postgres::query::Query<Struct<(StructColumn<i64, 6898215271518772730>, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>, 18137070463969723500>)>>` is not implemented for `Vec<User>`, which is required by `Sql<'_, Struct<(StructColumn<i64, 6898215271518772730>, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>, 18137070463969723500>)>, _>: IntoFuture`
| help: remove the `.await`
|
= help: the following other types implement trait `Query<Cols>`:
<Vec<u8> as Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as Query<sqlm_postgres::types::Array<Vec<Bytea>>>>
<Vec<T> as Query<Struct<Cols>>>
<Vec<T> as Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
= help: the following other types implement trait `sqlm_postgres::query::Query<Cols>`:
<Vec<u8> as sqlm_postgres::query::Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<Primitive<Bytea>>>
<Vec<Vec<u8>> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<Bytea>>>>
<Vec<T> as sqlm_postgres::query::Query<Struct<Cols>>>
<Vec<T> as sqlm_postgres::query::Query<Primitive<<T as SqlType>::Type>>>
<Vec<T> as sqlm_postgres::query::Query<sqlm_postgres::types::Array<Vec<<T as SqlType>::Type>>>>
= note: required for `Sql<'_, Struct<(StructColumn<i64, 6898215271518772730>, StructColumn<sqlm_postgres::types::Enum<(EnumVariant<5755620910692865178>, EnumVariant<10465144470622129318>)>, 18137070463969723500>)>, Vec<User>>` to implement `IntoFuture`
Loading

0 comments on commit 093039e

Please sign in to comment.