mongory 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +55 -73
- data/docs/clang_bridge.md +2 -2
- data/docs/performance.md +43 -7
- data/ext/mongory_ext/extconf.rb +15 -0
- data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/config.h +28 -43
- data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/memory_pool.h +0 -1
- data/ext/mongory_ext/mongory-core/include/mongory-core/matchers/matcher.h +3 -4
- data/ext/mongory_ext/mongory-core/src/foundations/array.c +28 -5
- data/ext/mongory_ext/mongory-core/src/foundations/config.c +24 -22
- data/ext/mongory_ext/mongory-core/src/foundations/config_private.h +3 -3
- data/ext/mongory_ext/mongory-core/src/foundations/memory_pool.c +22 -13
- data/ext/mongory_ext/mongory-core/src/foundations/string_buffer.c +4 -3
- data/ext/mongory_ext/mongory-core/src/foundations/table.c +60 -224
- data/ext/mongory_ext/mongory-core/src/foundations/table_private.h +36 -0
- data/ext/mongory_ext/mongory-core/src/foundations/utils.c +30 -47
- data/ext/mongory_ext/mongory-core/src/foundations/utils.h +2 -5
- data/ext/mongory_ext/mongory-core/src/foundations/value.c +18 -32
- data/ext/mongory_ext/mongory-core/src/matchers/base_matcher.c +89 -104
- data/ext/mongory_ext/mongory-core/src/matchers/base_matcher.h +18 -11
- data/ext/mongory_ext/mongory-core/src/matchers/compare_matcher.c +35 -150
- data/ext/mongory_ext/mongory-core/src/matchers/composite_matcher.c +244 -418
- data/ext/mongory_ext/mongory-core/src/matchers/composite_matcher.h +30 -0
- data/ext/mongory_ext/mongory-core/src/matchers/existence_matcher.c +15 -56
- data/ext/mongory_ext/mongory-core/src/matchers/external_matcher.c +18 -39
- data/ext/mongory_ext/mongory-core/src/matchers/implicit_array_matcher.c +14 -15
- data/ext/mongory_ext/mongory-core/src/matchers/inclusion_matcher.c +382 -74
- data/ext/mongory_ext/mongory-core/src/matchers/matcher.c +373 -123
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.c +20 -12
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.h +1 -4
- data/ext/mongory_ext/mongory-core/src/matchers/value_matcher.c +214 -171
- data/ext/mongory_ext/mongory-core/src/matchers/value_matcher.h +8 -16
- data/ext/mongory_ext/mongory_ext.c +26 -4
- data/ext/mongory_ext/mongory_ext_internal.h +15 -3
- data/ext/mongory_ext/rb_mongory_adapters.c +52 -19
- data/ext/mongory_ext/rb_mongory_matcher.c +115 -36
- data/ext/mongory_ext/rb_mongory_value.c +124 -51
- data/lib/mongory/converters/abstract_converter.rb +5 -5
- data/lib/mongory/converters/converted.rb +0 -4
- data/lib/mongory/converters/key_converter.rb +13 -36
- data/lib/mongory/converters/value_converter.rb +4 -4
- data/lib/mongory/matchers.rb +8 -7
- data/lib/mongory/query_builder.rb +9 -0
- data/lib/mongory/utils/context.rb +0 -6
- data/lib/mongory/utils/singleton_builder.rb +1 -4
- data/lib/mongory/version.rb +1 -1
- data/lib/mongory.rb +0 -1
- data/script/bench.rb +77 -4
- data/script/coverage.rb +84 -0
- metadata +7 -7
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.c +0 -117
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.h +0 -29
|
@@ -55,6 +55,16 @@ mongory_matcher *mongory_matcher_and_new(mongory_memory_pool *pool, mongory_valu
|
|
|
55
55
|
*/
|
|
56
56
|
mongory_matcher *mongory_matcher_or_new(mongory_memory_pool *pool, mongory_value *condition, void *extern_ctx);
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* @brief Creates a "NOR" ($nor) matcher.
|
|
60
|
+
* Matches if none of the conditions specified in an array of condition tables are met.
|
|
61
|
+
* @param pool Memory pool for allocation.
|
|
62
|
+
* @param condition A `mongory_value` of type `MONGORY_TYPE_ARRAY`, where each
|
|
63
|
+
* element is a `MONGORY_TYPE_TABLE` representing a sub-condition.
|
|
64
|
+
* @return A new `$nor` matcher, or NULL on failure or if condition is invalid.
|
|
65
|
+
*/
|
|
66
|
+
mongory_matcher *mongory_matcher_nor_new(mongory_memory_pool *pool, mongory_value *condition, void *extern_ctx);
|
|
67
|
+
|
|
58
68
|
/**
|
|
59
69
|
* @brief Creates an "element match" ($elemMatch) matcher.
|
|
60
70
|
* Matches an array field if at least one element in the array matches the given
|
|
@@ -122,6 +132,26 @@ mongory_composite_matcher *mongory_matcher_composite_new(mongory_memory_pool *po
|
|
|
122
132
|
*/
|
|
123
133
|
bool mongory_matcher_or_match(mongory_matcher *matcher, mongory_value *value);
|
|
124
134
|
|
|
135
|
+
/**
|
|
136
|
+
* @brief Combines already-built sub-matchers with AND logic ("And" node).
|
|
137
|
+
* @return The And matcher, or NULL on failure.
|
|
138
|
+
*/
|
|
139
|
+
mongory_matcher *mongory_matcher_and_of_new(mongory_memory_pool *pool, mongory_array *sub_matchers, mongory_value *condition,
|
|
140
|
+
void *extern_ctx);
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @brief Creates a "Not" node that negates an already-built matcher.
|
|
144
|
+
*
|
|
145
|
+
* Used for null negations lifted to the field path. With `document_only`,
|
|
146
|
+
* a record that cannot hold fields (not a table or array) never matches.
|
|
147
|
+
*
|
|
148
|
+
* @param inner The matcher to negate (non-NULL).
|
|
149
|
+
* @param condition The positive condition shown by explain/trace.
|
|
150
|
+
* @return The Not matcher, or NULL on failure.
|
|
151
|
+
*/
|
|
152
|
+
mongory_matcher *mongory_matcher_negation_new(mongory_memory_pool *pool, mongory_matcher *inner, mongory_value *condition,
|
|
153
|
+
bool document_only, void *extern_ctx);
|
|
154
|
+
|
|
125
155
|
/**
|
|
126
156
|
* @brief Re-sorts a composite matcher's children by updated priority using
|
|
127
157
|
* copy-on-write atomic publication safe for concurrent readers.
|
|
@@ -19,54 +19,27 @@
|
|
|
19
19
|
* @return True if `condition` is not NULL and is of type `MONGORY_TYPE_BOOL`,
|
|
20
20
|
* false otherwise.
|
|
21
21
|
*/
|
|
22
|
-
static
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
static mongory_matcher *mongory_matcher_bool_new(mongory_memory_pool *pool, mongory_value *condition, void *extern_ctx,
|
|
23
|
+
mongory_matcher_match_func match_fn, const char *name,
|
|
24
|
+
const char *err_msg, double priority) {
|
|
25
|
+
if (!mongory_validate_pool(pool)) {
|
|
26
|
+
return NULL;
|
|
25
27
|
}
|
|
26
|
-
if (condition->type != MONGORY_TYPE_BOOL) {
|
|
27
|
-
|
|
28
|
+
if (condition == NULL || condition->type != MONGORY_TYPE_BOOL) {
|
|
29
|
+
mongory_error_set(pool, MONGORY_ERROR_INVALID_ARGUMENT, err_msg);
|
|
30
|
+
return NULL;
|
|
28
31
|
}
|
|
29
|
-
return
|
|
32
|
+
return (mongory_matcher *)mongory_matcher_alloc_init(
|
|
33
|
+
pool, sizeof(mongory_matcher), condition, extern_ctx, match_fn, mongory_matcher_leaf_traverse, name, priority);
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
/**
|
|
33
|
-
* @brief Match function for the $exists matcher.
|
|
34
|
-
*
|
|
35
|
-
* Compares the existence of the input `value` (i.e., `value != NULL`)
|
|
36
|
-
* with the boolean `matcher->condition->data.b`.
|
|
37
|
-
* - If `condition` is true, matches if `value` is not NULL.
|
|
38
|
-
* - If `condition` is false, matches if `value` is NULL.
|
|
39
|
-
*
|
|
40
|
-
* @param matcher The $exists matcher instance. Its condition must be boolean.
|
|
41
|
-
* @param value The value whose existence is being checked. This is typically
|
|
42
|
-
* the result of a field lookup.
|
|
43
|
-
* @return True if the existence matches the condition, false otherwise.
|
|
44
|
-
*/
|
|
45
36
|
static inline bool mongory_matcher_exists_match(mongory_matcher *matcher, mongory_value *value) {
|
|
46
|
-
|
|
47
|
-
bool condition_expects_existence = matcher->condition->data.b;
|
|
48
|
-
bool actual_value_exists = (value != NULL);
|
|
49
|
-
|
|
50
|
-
return condition_expects_existence == actual_value_exists;
|
|
37
|
+
return matcher->condition->data.b == (value != NULL);
|
|
51
38
|
}
|
|
52
39
|
|
|
53
40
|
mongory_matcher *mongory_matcher_exists_new(mongory_memory_pool *pool, mongory_value *condition, void *extern_ctx) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return NULL;
|
|
57
|
-
}
|
|
58
|
-
mongory_matcher *matcher = mongory_matcher_base_new(pool, condition, extern_ctx);
|
|
59
|
-
if (!matcher) {
|
|
60
|
-
return NULL;
|
|
61
|
-
}
|
|
62
|
-
matcher->match = mongory_matcher_exists_match;
|
|
63
|
-
matcher->original_match = mongory_matcher_exists_match;
|
|
64
|
-
matcher->name = mongory_string_cpy(pool, "Exists");
|
|
65
|
-
if (!matcher->name) {
|
|
66
|
-
return NULL;
|
|
67
|
-
}
|
|
68
|
-
matcher->priority = 2.0;
|
|
69
|
-
return matcher;
|
|
41
|
+
return mongory_matcher_bool_new(pool, condition, extern_ctx, mongory_matcher_exists_match, "Exists",
|
|
42
|
+
"$exists condition must be a boolean value.", 2.0);
|
|
70
43
|
}
|
|
71
44
|
|
|
72
45
|
/**
|
|
@@ -139,20 +112,6 @@ static inline bool mongory_matcher_present_match(mongory_matcher *matcher, mongo
|
|
|
139
112
|
}
|
|
140
113
|
|
|
141
114
|
mongory_matcher *mongory_matcher_present_new(mongory_memory_pool *pool, mongory_value *condition, void *extern_ctx) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return NULL;
|
|
145
|
-
}
|
|
146
|
-
mongory_matcher *matcher = mongory_matcher_base_new(pool, condition, extern_ctx);
|
|
147
|
-
if (!matcher) {
|
|
148
|
-
return NULL;
|
|
149
|
-
}
|
|
150
|
-
matcher->match = mongory_matcher_present_match;
|
|
151
|
-
matcher->original_match = mongory_matcher_present_match;
|
|
152
|
-
matcher->name = mongory_string_cpy(pool, "Present");
|
|
153
|
-
if (!matcher->name) {
|
|
154
|
-
return NULL;
|
|
155
|
-
}
|
|
156
|
-
matcher->priority = 2.0;
|
|
157
|
-
return matcher;
|
|
115
|
+
return mongory_matcher_bool_new(pool, condition, extern_ctx, mongory_matcher_present_match, "Present",
|
|
116
|
+
"$present condition must be a boolean value.", 2.0);
|
|
158
117
|
}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
#include "mongory-core/foundations/error.h" // For MONGORY_ERROR_INVALID_ARGUMENT
|
|
12
12
|
#include "mongory-core/foundations/memory_pool.h"
|
|
13
13
|
#include "mongory-core/foundations/value.h"
|
|
14
|
-
#include "matcher_explainable.h"
|
|
15
14
|
#include "matcher_traversable.h"
|
|
16
15
|
|
|
17
16
|
typedef struct mongory_regex_matcher {
|
|
@@ -34,12 +33,15 @@ typedef struct mongory_regex_matcher {
|
|
|
34
33
|
* input is not a string.
|
|
35
34
|
*/
|
|
36
35
|
static inline bool mongory_matcher_regex_match(mongory_matcher *matcher, mongory_value *value) {
|
|
37
|
-
if (!value || value->type != MONGORY_TYPE_STRING) {
|
|
36
|
+
if (!matcher || !value || value->type != MONGORY_TYPE_STRING) {
|
|
38
37
|
return false; // Regex matching applies only to strings.
|
|
39
38
|
}
|
|
40
39
|
char *options = ((mongory_regex_matcher *)matcher)->options;
|
|
41
40
|
mongory_memory_pool *match_pool = value->pool ? value->pool : matcher->pool;
|
|
42
41
|
if (options) {
|
|
42
|
+
if (!mongory_internal_regex_adapter.options_match_func) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
43
45
|
return mongory_internal_regex_adapter.options_match_func(match_pool, matcher->condition, options, value);
|
|
44
46
|
}
|
|
45
47
|
if (!mongory_internal_regex_adapter.match_func) {
|
|
@@ -86,6 +88,9 @@ static inline bool mongory_matcher_regex_options_validate(mongory_memory_pool *p
|
|
|
86
88
|
|
|
87
89
|
mongory_matcher *mongory_matcher_regex_with_options_new(mongory_memory_pool *pool, mongory_value *condition,
|
|
88
90
|
mongory_value *options, void *extern_ctx) {
|
|
91
|
+
if (!mongory_validate_pool(pool)) {
|
|
92
|
+
return NULL;
|
|
93
|
+
}
|
|
89
94
|
if (!mongory_matcher_regex_condition_validate(condition)) {
|
|
90
95
|
mongory_matcher_regex_error_set(pool, MONGORY_ERROR_INVALID_ARGUMENT, "$regex condition must be a string or a regex object.");
|
|
91
96
|
return NULL;
|
|
@@ -106,29 +111,12 @@ mongory_matcher *mongory_matcher_regex_with_options_new(mongory_memory_pool *poo
|
|
|
106
111
|
return NULL;
|
|
107
112
|
}
|
|
108
113
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
mongory_regex_matcher *matcher = MG_ALLOC_PTR(pool, mongory_regex_matcher);
|
|
114
|
+
mongory_regex_matcher *matcher = (mongory_regex_matcher *)mongory_matcher_alloc_init(
|
|
115
|
+
pool, sizeof(mongory_regex_matcher), condition, extern_ctx, mongory_matcher_regex_match,
|
|
116
|
+
mongory_matcher_leaf_traverse, "Regex", 20.0);
|
|
114
117
|
if (!matcher) {
|
|
115
|
-
pool->error = &MONGORY_ALLOC_ERROR;
|
|
116
118
|
return NULL;
|
|
117
119
|
}
|
|
118
|
-
matcher->base.pool = pool;
|
|
119
|
-
matcher->base.condition = condition;
|
|
120
|
-
matcher->base.sub_count = 0;
|
|
121
|
-
matcher->base.match = mongory_matcher_regex_match;
|
|
122
|
-
matcher->base.original_match = mongory_matcher_regex_match;
|
|
123
|
-
matcher->base.explain = mongory_matcher_base_explain;
|
|
124
|
-
matcher->base.traverse = mongory_matcher_leaf_traverse;
|
|
125
|
-
matcher->base.extern_ctx = extern_ctx;
|
|
126
|
-
matcher->base.name = mongory_string_cpy(pool, "Regex");
|
|
127
|
-
if (!matcher->base.name) {
|
|
128
|
-
return NULL;
|
|
129
|
-
}
|
|
130
|
-
matcher->base.priority = 20.0;
|
|
131
|
-
matcher->base.parent = NULL;
|
|
132
120
|
matcher->options = has_options ? mongory_string_cpy(pool, options->data.s) : NULL;
|
|
133
121
|
if (has_options && !matcher->options) {
|
|
134
122
|
return NULL;
|
|
@@ -152,7 +140,7 @@ typedef struct mongory_custom_matcher {
|
|
|
152
140
|
* @return True if the value matches the matcher, false otherwise.
|
|
153
141
|
*/
|
|
154
142
|
bool mongory_matcher_custom_match(mongory_matcher *matcher, mongory_value *value) {
|
|
155
|
-
if (mongory_custom_matcher_adapter.match == NULL) {
|
|
143
|
+
if (!matcher || mongory_custom_matcher_adapter.match == NULL) {
|
|
156
144
|
return false; // Custom matcher adapter not initialized.
|
|
157
145
|
}
|
|
158
146
|
mongory_custom_matcher *custom_matcher = (mongory_custom_matcher *)matcher;
|
|
@@ -170,30 +158,21 @@ bool mongory_matcher_custom_match(mongory_matcher *matcher, mongory_value *value
|
|
|
170
158
|
* NULL on failure.
|
|
171
159
|
*/
|
|
172
160
|
mongory_matcher *mongory_matcher_custom_new(mongory_memory_pool *pool, char *key, mongory_value *condition, void *extern_ctx) {
|
|
161
|
+
if (!MONGORY_VALIDATE_PTR(pool, key)) {
|
|
162
|
+
return NULL;
|
|
163
|
+
}
|
|
173
164
|
if (mongory_custom_matcher_adapter.build == NULL)
|
|
174
165
|
return NULL; // Custom matcher adapter not initialized.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (matcher
|
|
179
|
-
if (pool) {
|
|
180
|
-
pool->error = &MONGORY_ALLOC_ERROR;
|
|
181
|
-
}
|
|
166
|
+
mongory_custom_matcher *matcher = (mongory_custom_matcher *)mongory_matcher_alloc_init(
|
|
167
|
+
pool, sizeof(mongory_custom_matcher), condition, extern_ctx, mongory_matcher_custom_match,
|
|
168
|
+
mongory_matcher_leaf_traverse, NULL, 20.0);
|
|
169
|
+
if (!matcher) {
|
|
182
170
|
return NULL;
|
|
183
171
|
}
|
|
184
172
|
mongory_matcher_custom_context *context = mongory_custom_matcher_adapter.build(key, condition, extern_ctx);
|
|
185
173
|
if (context == NULL)
|
|
186
174
|
return NULL;
|
|
187
|
-
matcher->base.pool = pool;
|
|
188
|
-
matcher->base.condition = condition;
|
|
189
175
|
matcher->base.name = context->name;
|
|
190
|
-
matcher->base.match = mongory_matcher_custom_match;
|
|
191
|
-
matcher->base.original_match = mongory_matcher_custom_match;
|
|
192
|
-
matcher->base.explain = mongory_matcher_base_explain;
|
|
193
|
-
matcher->base.traverse = mongory_matcher_leaf_traverse;
|
|
194
|
-
matcher->base.extern_ctx = extern_ctx;
|
|
195
176
|
matcher->external_matcher = context->external_matcher;
|
|
196
|
-
matcher->base.priority = 20.0;
|
|
197
|
-
matcher->base.parent = NULL;
|
|
198
177
|
return (mongory_matcher *)matcher;
|
|
199
178
|
}
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
typedef struct mongory_matcher_implicit_array_parse_table_context {
|
|
38
38
|
mongory_table *parsed_table; /**< Stores operator or indexed conditions. */
|
|
39
39
|
mongory_table *elem_match_table; /**< Stores conditions for element matching. */
|
|
40
|
+
bool has_explicit_elem_match; /**< An explicit $elemMatch was present, even if empty. */
|
|
40
41
|
} mongory_matcher_implicit_array_parse_table_context;
|
|
41
42
|
|
|
42
43
|
/**
|
|
@@ -76,8 +77,9 @@ static inline bool mongory_matcher_implicit_array_parse_table_foreach(char *key,
|
|
|
76
77
|
mongory_table *parsed_table_for_operators = context->parsed_table;
|
|
77
78
|
mongory_table *table_for_elem_match_conditions = context->elem_match_table;
|
|
78
79
|
|
|
79
|
-
if (strcmp(key, "$elemMatch") == 0 && value->type == MONGORY_TYPE_TABLE && value->data.t != NULL) {
|
|
80
|
+
if (strcmp(key, "$elemMatch") == 0 && value != NULL && value->type == MONGORY_TYPE_TABLE && value->data.t != NULL) {
|
|
80
81
|
// Explicit $elemMatch: iterate its sub-table and add to elem_match_table
|
|
82
|
+
context->has_explicit_elem_match = true;
|
|
81
83
|
mongory_table_merge(table_for_elem_match_conditions, value->data.t);
|
|
82
84
|
} else if (mongory_is_elem_match_operator(key, value)) {
|
|
83
85
|
// Element-level comparison operators apply to array elements via $elemMatch
|
|
@@ -106,11 +108,7 @@ static inline bool mongory_matcher_implicit_array_parse_table_foreach(char *key,
|
|
|
106
108
|
* condition. Returns NULL if input is not a table or on allocation failure.
|
|
107
109
|
*/
|
|
108
110
|
static inline mongory_value *mongory_matcher_implicit_array_parse_table(mongory_memory_pool *pool, mongory_value *condition) {
|
|
109
|
-
if (!pool) {
|
|
110
|
-
return NULL;
|
|
111
|
-
}
|
|
112
|
-
if (!condition || !condition->data.t) {
|
|
113
|
-
mongory_error_set(pool, MONGORY_ERROR_INVALID_TYPE, "Expected condition to be a table, got a non-table value");
|
|
111
|
+
if (!MONGORY_VALIDATE_TABLE(pool, condition)) {
|
|
114
112
|
return NULL; // Invalid input
|
|
115
113
|
}
|
|
116
114
|
mongory_table *parsed_table = mongory_table_new(pool);
|
|
@@ -120,7 +118,7 @@ static inline mongory_value *mongory_matcher_implicit_array_parse_table(mongory_
|
|
|
120
118
|
return NULL;
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
mongory_matcher_implicit_array_parse_table_context parse_ctx = {parsed_table, elem_match_sub_table};
|
|
121
|
+
mongory_matcher_implicit_array_parse_table_context parse_ctx = {parsed_table, elem_match_sub_table, false};
|
|
124
122
|
mongory_table *original_condition_table = condition->data.t;
|
|
125
123
|
|
|
126
124
|
original_condition_table->each(original_condition_table, &parse_ctx,
|
|
@@ -129,16 +127,16 @@ static inline mongory_value *mongory_matcher_implicit_array_parse_table(mongory_
|
|
|
129
127
|
return NULL;
|
|
130
128
|
}
|
|
131
129
|
|
|
132
|
-
if (elem_match_sub_table->count > 0) {
|
|
133
|
-
// If there were conditions for element matching
|
|
134
|
-
//
|
|
130
|
+
if (elem_match_sub_table->count > 0 || parse_ctx.has_explicit_elem_match) {
|
|
131
|
+
// If there were conditions for element matching (or an explicit, possibly
|
|
132
|
+
// empty $elemMatch, which still needs an element), add them as an
|
|
133
|
+
// $elemMatch clause to the main parsed_table.
|
|
135
134
|
mongory_value *wrapped_elem = mongory_value_wrap_t(pool, elem_match_sub_table);
|
|
136
135
|
if (!wrapped_elem || !parsed_table->set(parsed_table, "$elemMatch", wrapped_elem)) {
|
|
137
136
|
return NULL;
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
|
-
//
|
|
141
|
-
// (which might contain $size etc.) is returned.
|
|
139
|
+
// Otherwise the parsed_table (which might contain $size etc.) is returned as is.
|
|
142
140
|
return mongory_value_wrap_t(pool, parsed_table);
|
|
143
141
|
}
|
|
144
142
|
|
|
@@ -160,9 +158,10 @@ static inline mongory_value *mongory_matcher_implicit_array_parse_table(mongory_
|
|
|
160
158
|
* @return The constructed implicit_array_matcher, or NULL on failure.
|
|
161
159
|
*/
|
|
162
160
|
mongory_matcher *mongory_matcher_implicit_array_new(mongory_memory_pool *pool, mongory_value *condition, void *extern_ctx) {
|
|
163
|
-
if (!condition
|
|
161
|
+
if (!MONGORY_VALIDATE_PTR(pool, condition)) {
|
|
164
162
|
return NULL;
|
|
165
|
-
|
|
163
|
+
}
|
|
164
|
+
mongory_compile_ctx saved = mongory_compile_ctx_begin();
|
|
166
165
|
mongory_matcher *result = NULL;
|
|
167
166
|
switch (condition->type) {
|
|
168
167
|
case MONGORY_TYPE_TABLE: {
|
|
@@ -199,6 +198,6 @@ mongory_matcher *mongory_matcher_implicit_array_new(mongory_memory_pool *pool, m
|
|
|
199
198
|
break;
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
|
-
|
|
201
|
+
mongory_compile_ctx_end(saved);
|
|
203
202
|
return result;
|
|
204
203
|
}
|