@@ -167,20 +167,31 @@ auto nodeExtractDouble(aql::AstNode const* node) -> std::optional<zkd::byte_stri
167
167
return std::nullopt;
168
168
}
169
169
170
+ auto accessDocumentPath (VPackSlice doc, std::vector<basics::AttributeName> const & path) -> VPackSlice {
171
+ for (auto && attrib : path) {
172
+ TRI_ASSERT (attrib.shouldExpand == false );
173
+ if (!doc.isObject ()) {
174
+ return VPackSlice::noneSlice ();
175
+ }
176
+
177
+ doc = doc.get (attrib.name );
178<
8000
/code>
+ }
179
+
180
+ return doc;
181
+ }
182
+
170
183
auto readDocumentKey (VPackSlice doc,
171
184
std::vector<std::vector<basics::AttributeName>> const & fields)
172
185
-> zkd::byte_string {
173
186
std::vector<zkd::byte_string> v;
174
187
v.reserve (fields.size ());
175
188
176
189
for (auto const & path : fields) {
177
- TRI_ASSERT (path.size () == 1 );
178
- TRI_ASSERT (path[0 ].shouldExpand == false );
179
- VPackSlice value = doc.get (path[0 ].name );
190
+ VPackSlice value = accessDocumentPath (doc, path);
180
191
if (!value.isNumber <double >()) {
181
192
THROW_ARANGO_EXCEPTION (TRI_ERROR_QUERY_INVALID_ARITHMETIC_VALUE);
182
193
}
183
- double dv = value.getNumericValue <double >();
194
+ auto dv = value.getNumericValue <double >();
184
195
if (std::isnan (dv)) {
185
196
THROW_ARANGO_EXCEPTION_MESSAGE (TRI_ERROR_BAD_PARAMETER, " NaN is not allowed" );
186
197
}
@@ -238,39 +249,30 @@ void zkd::extractBoundsFromCondition(
238
249
return false ;
239
250
}
240
251
241
- auto & path = attributeData.second ;
242
- // TODO -- make this more generic
243
- TRI_ASSERT (path.size () == 1 && !path[0 ].shouldExpand );
244
-
245
- auto & name = path[0 ].name ;
246
252
for (auto && [idx, field] : enumerate(index ->fields ())) {
247
- TRI_ASSERT (field.size () == 1 );
248
-
249
- if (name != field[0 ].name ) {
253
+ if (attributeData.second != field) {
250
254
continue ;
251
255
}
252
256
253
- if (name == field[0 ].name ) {
254
- switch (op->type ) {
255
- case arangodb::aql::NODE_TYPE_OPERATOR_BINARY_EQ:
256
- useAsBound (idx, op, access , other, true , false );
257
- useAsBound (idx, op, access , other, false , false );
258
- return true ;
259
- case arangodb::aql::NODE_TYPE_OPERATOR_BINARY_LE:
260
- useAsBound (idx, op, access , other, reverse, false );
261
- return true ;
262
- case arangodb::aql::NODE_TYPE_OPERATOR_BINARY_GE:
263
- useAsBound (idx, op, access , other, !reverse, false );
264
- return true ;
265
- case arangodb::aql::NODE_TYPE_OPERATOR_BINARY_LT:
266
- useAsBound (idx, op, access , other, reverse, true );
267
- return true ;
268
- case arangodb::aql::NODE_TYPE_OPERATOR_BINARY_GT:
269
- useAsBound (idx, op, access , other, !reverse, true );
270
- return true ;
271
- default :
272
- break ;
273
- }
257
+ switch (op->type ) {
258
+ case arangodb::aql::NODE_TYPE_OPERATOR_BINARY_EQ:
259
+ useAsBound (idx, op, access , other, true , false );
260
+ useAsBound (idx, op, access , other, false , false );
261
+ return true ;
262
+ case arangodb::aql::NODE_TYPE_OPERATOR_BINARY_LE:
263
+ useAsBound (idx, op, access , other, reverse, false );
264
+ return true ;
265
+ case arangodb::aql::NODE_TYPE_OPERATOR_BINARY_GE:
266
+ useAsBound (idx, op, access , other, !reverse, false );
267
+ return true ;
268
+ case arangodb::aql::NODE_TYPE_OPERATOR_BINARY_LT:
269
+ useAsBound (idx, op, access , other, reverse, true );
270
+ return true ;
271
+ case arangodb::aql::NODE_TYPE_OPERATOR_BINARY_GT:
272
+ useAsBound (idx, op, access , other, !reverse, true );
273
+ return true ;
274
+ default :
275
+ break ;
274
276
}
275
277
}
276
278
0 commit comments