(
array: &str,
row: usize,
attrs: &[ArrayAttrLiteral],
view: &ArrayCatalogView,
)
| 87 | } |
| 88 | |
| 89 | fn validate_attrs( |
| 90 | array: &str, |
| 91 | row: usize, |
| 92 | attrs: &[ArrayAttrLiteral], |
| 93 | view: &ArrayCatalogView, |
| 94 | ) -> Result<()> { |
| 95 | if attrs.len() != view.attrs.len() { |
| 96 | return Err(SqlError::Parse { |
| 97 | detail: format!( |
| 98 | "ARRAY {array} row {row}: attr arity {} != attr count {}", |
| 99 | attrs.len(), |
| 100 | view.attrs.len() |
| 101 | ), |
| 102 | }); |
| 103 | } |
| 104 | for (i, a) in attrs.iter().enumerate() { |
| 105 | let spec = &view.attrs[i]; |
| 106 | match a { |
| 107 | ArrayAttrLiteral::Null if !spec.nullable => { |
| 108 | return Err(SqlError::TypeMismatch { |
| 109 | detail: format!("ARRAY {array} row {row}: attr `{}` is NOT NULL", spec.name), |
| 110 | }); |
| 111 | } |
| 112 | ArrayAttrLiteral::Null => {} |
| 113 | other if !attr_compatible(other, spec.dtype) => { |
| 114 | return Err(SqlError::TypeMismatch { |
| 115 | detail: format!( |
| 116 | "ARRAY {array} row {row}: attr `{}` (declared {:?}) is incompatible", |
| 117 | spec.name, spec.dtype |
| 118 | ), |
| 119 | }); |
| 120 | } |
| 121 | _ => {} |
| 122 | } |
| 123 | } |
| 124 | Ok(()) |
| 125 | } |
| 126 | |
| 127 | fn coord_compatible(c: &ArrayCoordLiteral, dtype: ArrayDimType) -> bool { |
| 128 | matches!( |
no test coverage detected