Skip to main content

ToAggregateName

Trait ToAggregateName 

Source
pub trait ToAggregateName {
    const NAME: &'static str;
}
Expand description

A trait representing a type-level identifier for an aggregate function.

This trait is used to associate a constant name with a Rust type, which is then used as the name of the corresponding SQL aggregate in PostgreSQL (e.g., the name you’d use in SELECT my_agg(col) FROM table;).

This is especially useful in combination with procedural macros like #[derive(AggregateName)], which automatically implements this trait for a given struct or enum.

§Examples

§Default name (based on type name)

#[derive(pgrx::AggregateName)]
struct MySum;

assert_eq!(<MySum as pgrx::ToAggregateName>::NAME, "MySum");

§Custom name using #[aggregate_name = "..."]

#[derive(pgrx::AggregateName)]
#[aggregate_name = "my_custom_sum"]
struct MySum;

assert_eq!(<MySum as pgrx::ToAggregateName>::NAME, "my_custom_sum");

Required Associated Constants§

Source

const NAME: &'static str

The name of the aggregate. (eg. What you’d pass to SELECT agg(col) FROM tab.)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§