Skip to content

Commit e30ee9f

Browse files
Further improve diagnostics for signatures with no SQL form (pgcentralfoundation#2215)
While we use `do_not_recommend` on the various implementations of `FunctionMetadata`, it still appears as "this bound was not fulfilled". Provide a further hint about why.
1 parent 25285e4 commit e30ee9f

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

pgrx-sql-entity-graph/src/metadata/function_metadata.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ assert_eq!(
3333
);
3434
```
3535
*/
36+
#[diagnostic::on_unimplemented(
37+
message = "cannot generate SQL schema for this function",
38+
label = "some types in {Self} cannot be translated to SQL"
39+
)]
3640
pub trait FunctionMetadata<A> {
3741
fn path() -> &'static str {
3842
core::any::type_name::<Self>()

pgrx-tests/tests/compile-fail/u32.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
error[E0277]: the trait bound `fn(u32) -> u32: FunctionMetadata<_>` is not satisfied
1+
error[E0277]: cannot generate SQL schema for this function
22
--> tests/compile-fail/u32.rs:6:5
33
|
44
5 | #[pg_extern]
55
| ------------ in this procedural macro expansion
66
6 | pub fn whatever(a: u32) -> u32 {
7-
| ^^ the trait `FunctionMetadata<_>` is not implemented for `fn(u32) -> u32`
7+
| ^^ some types in fn(u32) -> u32 cannot be translated to SQL
88
|
9+
= help: the trait `FunctionMetadata<_>` is not implemented for `fn(u32) -> u32`
910
= note: this error originates in the attribute macro `pg_extern` (in Nightly builds, run with -Z macro-backtrace for more info)
1011

1112
error[E0599]: `u32` has no representation in SQL

0 commit comments

Comments
 (0)