Validate PATH constructor expressions
(
path_constructor: &crate::ast::PathConstructor,
ctx: &mut ValidationContext,
errors: &mut Vec<ValidationError>,
)
| 1297 | |
| 1298 | /// Validate PATH constructor expressions |
| 1299 | fn validate_path_constructor( |
| 1300 | path_constructor: &crate::ast::PathConstructor, |
| 1301 | ctx: &mut ValidationContext, |
| 1302 | errors: &mut Vec<ValidationError>, |
| 1303 | ) { |
| 1304 | // Validate each element in the PATH constructor |
| 1305 | for element in &path_constructor.elements { |
| 1306 | validate_expression(element, ctx, errors); |
| 1307 | |
| 1308 | // Check that element types are suitable for PATH constructor |
| 1309 | if let Ok(element_type) = infer_expression_type(element, ctx) { |
| 1310 | match element_type { |
| 1311 | GqlType::String { .. } |
| 1312 | | GqlType::Integer |
| 1313 | | GqlType::BigInt |
| 1314 | | GqlType::SmallInt |
| 1315 | | GqlType::Double |
| 1316 | | GqlType::Float { .. } |
| 1317 | | GqlType::Real => { |
| 1318 | // These types are valid for PATH elements (can be converted to string IDs) |
| 1319 | } |
| 1320 | _ => { |
| 1321 | errors.push(ValidationError { |
| 1322 | message: format!( |
| 1323 | "PATH constructor element must be a string or number type, got: {:?}", |
| 1324 | element_type |
| 1325 | ), |
| 1326 | location: Some(crate::ast::Location::default()), |
| 1327 | error_type: ValidationErrorType::Type, |
| 1328 | }); |
| 1329 | } |
| 1330 | } |
| 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | // PATH elements should follow node-edge-node pattern (optional validation) |
| 1335 | if path_constructor.elements.len().is_multiple_of(2) && path_constructor.elements.len() > 2 { |
| 1336 | // Even number of elements > 2 might indicate incomplete path |
| 1337 | // This is a warning rather than an error since PATH[node, edge] might be valid |
| 1338 | // in some contexts |
| 1339 | } |
| 1340 | } |
| 1341 | |
| 1342 | /// Validate CAST expressions |
| 1343 | fn validate_cast_expression( |
no test coverage detected