Apply LIMIT clause to query result
(
&self,
mut result: QueryResult,
limit_clause: &crate::ast::LimitClause,
)
| 8458 | |
| 8459 | /// Apply LIMIT clause to query result |
| 8460 | fn apply_limit( |
| 8461 | &self, |
| 8462 | mut result: QueryResult, |
| 8463 | limit_clause: &crate::ast::LimitClause, |
| 8464 | ) -> Result<QueryResult, ExecutionError> { |
| 8465 | let offset = limit_clause.offset.unwrap_or(0); |
| 8466 | let count = limit_clause.count; |
| 8467 | |
| 8468 | // Apply offset |
| 8469 | if offset > 0 { |
| 8470 | if offset >= result.rows.len() { |
| 8471 | result.rows.clear(); |
| 8472 | } else { |
| 8473 | result.rows.drain(0..offset); |
| 8474 | } |
| 8475 | } |
| 8476 | |
| 8477 | // Apply limit |
| 8478 | if result.rows.len() > count { |
| 8479 | result.rows.truncate(count); |
| 8480 | } |
| 8481 | |
| 8482 | Ok(result) |
| 8483 | } |
| 8484 | |
| 8485 | /// Expand SELECT items, handling wildcard (*) by creating return items for all node properties |
| 8486 | fn expand_select_items( |
no test coverage detected