Struct pgrx_sql_entity_graph::ToSqlConfigEntity
source · pub struct ToSqlConfigEntity {
pub enabled: bool,
pub callback: Option<fn(_: &SqlGraphEntity, _: &PgrxSql) -> Result<String, Box<dyn Error + Send + Sync + 'static>>>,
pub content: Option<&'static str>,
}
Expand description
Represents configuration options for tuning the SQL generator.
When an item that can be rendered to SQL has these options at hand, they should be respected. If an item does not have them, then it is not expected that the SQL generation for those items can be modified.
The default configuration has enabled
set to true
, and callback
to None
, which indicates
that the default SQL generation behavior will be used. These are intended to be mutually exclusive
options, so callback
should only be set if generation is enabled.
When enabled
is false, no SQL is generated for the item being configured.
When callback
has a value, the corresponding ToSql
implementation should invoke the
callback instead of performing their default behavior.
Fields§
§enabled: bool
§callback: Option<fn(_: &SqlGraphEntity, _: &PgrxSql) -> Result<String, Box<dyn Error + Send + Sync + 'static>>>
§content: Option<&'static str>
Implementations§
source§impl ToSqlConfigEntity
impl ToSqlConfigEntity
sourcepub fn to_sql(
&self,
entity: &SqlGraphEntity,
context: &PgrxSql
) -> Option<Result<String>>
pub fn to_sql( &self, entity: &SqlGraphEntity, context: &PgrxSql ) -> Option<Result<String>>
Given a SqlGraphEntity, this function converts it to SQL based on the current configuration.
If the config overrides the default behavior (i.e. using the ToSql
trait), then Some(eyre::Result)
is returned. If the config does not override the default behavior, then None
is returned. This can
be used to dispatch SQL generation in a single line, e.g.:
config.to_sql(entity, context).unwrap_or_else(|| entity.to_sql(context))?
Trait Implementations§
source§impl Clone for ToSqlConfigEntity
impl Clone for ToSqlConfigEntity
source§fn clone(&self) -> ToSqlConfigEntity
fn clone(&self) -> ToSqlConfigEntity
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ToSqlConfigEntity
impl Debug for ToSqlConfigEntity
source§impl Default for ToSqlConfigEntity
impl Default for ToSqlConfigEntity
source§fn default() -> ToSqlConfigEntity
fn default() -> ToSqlConfigEntity
source§impl Hash for ToSqlConfigEntity
impl Hash for ToSqlConfigEntity
source§impl Ord for ToSqlConfigEntity
impl Ord for ToSqlConfigEntity
source§impl PartialEq for ToSqlConfigEntity
impl PartialEq for ToSqlConfigEntity
source§impl PartialOrd for ToSqlConfigEntity
impl PartialOrd for ToSqlConfigEntity
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for ToSqlConfigEntity
Auto Trait Implementations§
impl Freeze for ToSqlConfigEntity
impl RefUnwindSafe for ToSqlConfigEntity
impl Send for ToSqlConfigEntity
impl Sync for ToSqlConfigEntity
impl Unpin for ToSqlConfigEntity
impl UnwindSafe for ToSqlConfigEntity
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.