MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / parse_order_by_nulls_policy

Function parse_order_by_nulls_policy

crates/gitql-parser/src/parse_ordering.rs:109–144  ·  view source on GitHub ↗
(
    tokens: &[Token],
    position: &mut usize,
    sorting_order: &SortingOrder,
)

Source from the content-addressed store, hash-verified

107}
108
109fn parse_order_by_nulls_policy(
110 tokens: &[Token],
111 position: &mut usize,
112 sorting_order: &SortingOrder,
113) -> Result<NullsOrderPolicy, Box<Diagnostic>> {
114 // Check for `NULLs FIRST` or `NULLs LAST`
115 if is_current_token(tokens, position, TokenKind::Nulls) {
116 // Consume `NULLs` keyword
117 *position += 1;
118
119 // Consume `FIRST` and return NUlls First policy
120 if is_current_token(tokens, position, TokenKind::First) {
121 *position += 1;
122 return Ok(NullsOrderPolicy::NullsFirst);
123 }
124
125 // Consume `LAST` and return NUlls Last policy
126 if is_current_token(tokens, position, TokenKind::Last) {
127 *position += 1;
128 return Ok(NullsOrderPolicy::NullsLast);
129 }
130
131 return Err(Diagnostic::error("Unexpected NULL ordering policy")
132 .add_note("Null ordering policy must be `FIRST` or `LAST`")
133 .add_help("Please use `NULL FIRST` or `NULL LAST`")
134 .with_location(tokens[*position].location)
135 .as_boxed());
136 }
137
138 let default_null_ordering_policy = match sorting_order {
139 SortingOrder::Ascending => NullsOrderPolicy::NullsLast,
140 SortingOrder::Descending => NullsOrderPolicy::NullsFirst,
141 };
142
143 Ok(default_null_ordering_policy)
144}
145
146#[inline(always)]
147fn is_order_by_using_operator(token: &Token) -> bool {

Callers 1

parse_order_by_statementFunction · 0.85

Calls 5

is_current_tokenFunction · 0.85
as_boxedMethod · 0.80
with_locationMethod · 0.80
add_helpMethod · 0.80
add_noteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…