pub struct OrderByClause {
pub field: String,
pub field_source: FieldSource,
pub direction: SortOrder,
pub collation: Option<String>,
pub nulls_handling: Option<NullsHandling>,
}Expand description
Represents a complete ORDER BY clause
Supports:
- Both JSONB fields and direct columns
- PostgreSQL collations
- NULLS FIRST/LAST handling
- Mixed multi-field ordering
§Examples
use fraiseql_wire::operators::{OrderByClause, FieldSource, SortOrder, NullsHandling};
// Order by JSONB field with collation
let _ = OrderByClause {
field: "name".to_string(),
field_source: FieldSource::JsonbPayload,
direction: SortOrder::Asc,
collation: Some("en-US".to_string()),
nulls_handling: None,
};
// Order by direct column with NULLS LAST
let _ = OrderByClause {
field: "created_at".to_string(),
field_source: FieldSource::DirectColumn,
direction: SortOrder::Desc,
collation: None,
nulls_handling: Some(NullsHandling::Last),
};Fields§
§field: StringField name (validated separately based on field_source)
field_source: FieldSourceWhere the field comes from
direction: SortOrderSort direction
collation: Option<String>Optional collation name (e.g., “en-US”, “C”, “de_DE.UTF-8”)
When specified, generates: field COLLATE "collation_name"
nulls_handling: Option<NullsHandling>Optional NULLS handling
Implementations§
Source§impl OrderByClause
impl OrderByClause
Sourcepub fn jsonb_field(field: impl Into<String>, direction: SortOrder) -> Self
pub fn jsonb_field(field: impl Into<String>, direction: SortOrder) -> Self
Create a new ORDER BY clause for a JSONB field
Sourcepub fn direct_column(field: impl Into<String>, direction: SortOrder) -> Self
pub fn direct_column(field: impl Into<String>, direction: SortOrder) -> Self
Create a new ORDER BY clause for a direct column
Sourcepub fn with_collation(self, collation: impl Into<String>) -> Self
pub fn with_collation(self, collation: impl Into<String>) -> Self
Add collation to this clause
Sourcepub const fn with_nulls(self, handling: NullsHandling) -> Self
pub const fn with_nulls(self, handling: NullsHandling) -> Self
Add NULLS handling to this clause
Trait Implementations§
Source§impl Clone for OrderByClause
impl Clone for OrderByClause
Source§fn clone(&self) -> OrderByClause
fn clone(&self) -> OrderByClause
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OrderByClause
impl Debug for OrderByClause
Auto Trait Implementations§
impl Freeze for OrderByClause
impl RefUnwindSafe for OrderByClause
impl Send for OrderByClause
impl Sync for OrderByClause
impl Unpin for OrderByClause
impl UnsafeUnpin for OrderByClause
impl UnwindSafe for OrderByClause
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
Mutably borrows from an owned value. Read more