mongory 0.9.1-aarch64-linux → 2.0.1-aarch64-linux

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.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/README.md +115 -420
  4. data/SUBMODULE_INTEGRATION.md +7 -20
  5. data/docs/clang_bridge.md +28 -63
  6. data/docs/migration.md +17 -0
  7. data/docs/performance.md +14 -51
  8. data/examples/benchmark.rb +10 -26
  9. data/ext/mongory_ext/extconf.rb +1 -1
  10. data/ext/mongory_ext/mongory-core/include/mongory-core/adapters/json.h +62 -0
  11. data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/config.h +31 -0
  12. data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/error.h +3 -0
  13. data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/memory_pool.h +20 -0
  14. data/ext/mongory_ext/mongory-core/include/mongory-core/matchers/matcher.h +31 -4
  15. data/ext/mongory_ext/mongory-core/src/foundations/array.c +48 -6
  16. data/ext/mongory_ext/mongory-core/src/foundations/config.c +30 -2
  17. data/ext/mongory_ext/mongory-core/src/foundations/error.c +10 -0
  18. data/ext/mongory_ext/mongory-core/src/foundations/memory_pool.c +78 -19
  19. data/ext/mongory_ext/mongory-core/src/foundations/string_buffer.c +73 -19
  20. data/ext/mongory_ext/mongory-core/src/foundations/table.c +8 -3
  21. data/ext/mongory_ext/mongory-core/src/foundations/utils.c +44 -55
  22. data/ext/mongory_ext/mongory-core/src/foundations/utils.h +7 -0
  23. data/ext/mongory_ext/mongory-core/src/foundations/value.c +3 -0
  24. data/ext/mongory_ext/mongory-core/src/matchers/base_matcher.c +68 -0
  25. data/ext/mongory_ext/mongory-core/src/matchers/base_matcher.h +14 -0
  26. data/ext/mongory_ext/mongory-core/src/matchers/compare_matcher.c +9 -4
  27. data/ext/mongory_ext/mongory-core/src/matchers/composite_matcher.c +132 -29
  28. data/ext/mongory_ext/mongory-core/src/matchers/composite_matcher.h +1 -1
  29. data/ext/mongory_ext/mongory-core/src/matchers/{existance_matcher.c → existence_matcher.c} +10 -12
  30. data/ext/mongory_ext/mongory-core/src/matchers/{existance_matcher.h → existence_matcher.h} +4 -4
  31. data/ext/mongory_ext/mongory-core/src/matchers/external_matcher.c +18 -6
  32. data/ext/mongory_ext/mongory-core/src/matchers/{array_record_matcher.c → implicit_array_matcher.c} +57 -38
  33. data/ext/mongory_ext/mongory-core/src/matchers/{array_record_matcher.h → implicit_array_matcher.h} +5 -5
  34. data/ext/mongory_ext/mongory-core/src/matchers/inclusion_matcher.c +8 -10
  35. data/ext/mongory_ext/mongory-core/src/matchers/matcher.c +337 -96
  36. data/ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.c +59 -21
  37. data/ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.h +7 -1
  38. data/ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.c +4 -4
  39. data/ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.h +1 -1
  40. data/ext/mongory_ext/mongory-core/src/matchers/{literal_matcher.c → value_matcher.c} +104 -60
  41. data/ext/mongory_ext/mongory-core/src/matchers/{literal_matcher.h → value_matcher.h} +13 -13
  42. data/ext/mongory_ext/mongory_ext.c +2 -2
  43. data/ext/mongory_ext/mongory_ext_internal.h +2 -3
  44. data/ext/mongory_ext/{rb_mongory_cmatcher.c → rb_mongory_matcher.c} +145 -91
  45. data/ext/mongory_ext/rb_mongory_value.c +67 -0
  46. data/lib/core/2.6/mongory_ext.so +0 -0
  47. data/lib/core/2.7/mongory_ext.so +0 -0
  48. data/lib/core/3.0/mongory_ext.so +0 -0
  49. data/lib/core/3.1/mongory_ext.so +0 -0
  50. data/lib/core/3.2/mongory_ext.so +0 -0
  51. data/lib/core/3.3/mongory_ext.so +0 -0
  52. data/lib/core/3.4/mongory_ext.so +0 -0
  53. data/lib/core/4.0/mongory_ext.so +0 -0
  54. data/lib/generators/mongory/install/templates/initializer.rb.erb +0 -5
  55. data/lib/generators/mongory/matcher/templates/matcher.rb.erb +4 -15
  56. data/lib/mongory/converters/condition_converter.rb +1 -1
  57. data/lib/mongory/converters/converted.rb +28 -6
  58. data/lib/mongory/converters/key_converter.rb +2 -0
  59. data/lib/mongory/matcher.rb +50 -0
  60. data/lib/mongory/matchers/abstract_matcher.rb +18 -192
  61. data/lib/mongory/matchers.rb +68 -84
  62. data/lib/mongory/query_builder.rb +29 -42
  63. data/lib/mongory/utils/context.rb +10 -15
  64. data/lib/mongory/utils/tree_renderer.rb +98 -0
  65. data/lib/mongory/utils.rb +2 -67
  66. data/lib/mongory/version.rb +1 -1
  67. data/lib/mongory.rb +9 -59
  68. data/script/bench.rb +54 -0
  69. data/scripts/build_with_core.sh +0 -1
  70. metadata +13 -37
  71. data/lib/mongory/c_matcher.rb +0 -57
  72. data/lib/mongory/c_query_builder.rb +0 -44
  73. data/lib/mongory/matchers/abstract_multi_matcher.rb +0 -150
  74. data/lib/mongory/matchers/and_matcher.rb +0 -73
  75. data/lib/mongory/matchers/array_record_matcher.rb +0 -105
  76. data/lib/mongory/matchers/elem_match_matcher.rb +0 -57
  77. data/lib/mongory/matchers/eq_matcher.rb +0 -48
  78. data/lib/mongory/matchers/every_matcher.rb +0 -56
  79. data/lib/mongory/matchers/exists_matcher.rb +0 -53
  80. data/lib/mongory/matchers/field_matcher.rb +0 -160
  81. data/lib/mongory/matchers/gt_matcher.rb +0 -41
  82. data/lib/mongory/matchers/gte_matcher.rb +0 -41
  83. data/lib/mongory/matchers/hash_condition_matcher.rb +0 -80
  84. data/lib/mongory/matchers/in_matcher.rb +0 -84
  85. data/lib/mongory/matchers/literal_matcher.rb +0 -126
  86. data/lib/mongory/matchers/lt_matcher.rb +0 -41
  87. data/lib/mongory/matchers/lte_matcher.rb +0 -41
  88. data/lib/mongory/matchers/ne_matcher.rb +0 -39
  89. data/lib/mongory/matchers/nin_matcher.rb +0 -64
  90. data/lib/mongory/matchers/not_matcher.rb +0 -40
  91. data/lib/mongory/matchers/or_matcher.rb +0 -69
  92. data/lib/mongory/matchers/present_matcher.rb +0 -55
  93. data/lib/mongory/matchers/regex_matcher.rb +0 -109
  94. data/lib/mongory/matchers/size_matcher.rb +0 -54
  95. data/lib/mongory/query_matcher.rb +0 -93
  96. data/lib/mongory/rails.rb +0 -15
  97. data/lib/mongory/utils/debugger.rb +0 -125
  98. data/lib/mongory/utils/rails_patch.rb +0 -22
@@ -83,17 +83,23 @@ char *mongory_string_cpy(mongory_memory_pool *pool, char *str) {
83
83
  }
84
84
 
85
85
  char *mongory_string_cpyf(mongory_memory_pool *pool, char *format, ...) {
86
+ if (!pool || !format) {
87
+ return NULL;
88
+ }
86
89
  va_list args;
87
90
  va_start(args, format);
88
91
  int len = vsnprintf(NULL, 0, format, args);
89
92
  va_end(args);
90
- char *new_str = (char *)MG_ALLOC(pool, len + 1);
93
+ if (len < 0) {
94
+ return NULL;
95
+ }
96
+ char *new_str = (char *)MG_ALLOC(pool, (size_t)len + 1);
91
97
  if (new_str == NULL) {
92
98
  pool->error = &MONGORY_ALLOC_ERROR;
93
99
  return NULL;
94
100
  }
95
101
  va_start(args, format);
96
- vsnprintf(new_str, len + 1, format, args);
102
+ vsnprintf(new_str, (size_t)len + 1, format, args);
97
103
  va_end(args);
98
104
  new_str[len] = '\0';
99
105
  return new_str;
@@ -103,15 +109,29 @@ double mongory_log(double x, double base) {
103
109
  return log(x) / log(base);
104
110
  }
105
111
 
112
+ void mongory_error_set(mongory_memory_pool *pool, mongory_error_type type, const char *message) {
113
+ if (!pool || pool->error != NULL) {
114
+ return;
115
+ }
116
+ mongory_error *error = MG_ALLOC_PTR(pool, mongory_error);
117
+ if (error == NULL) {
118
+ pool->error = &MONGORY_ALLOC_ERROR;
119
+ return;
120
+ }
121
+ error->type = type;
122
+ error->message = message;
123
+ pool->error = error;
124
+ }
125
+
106
126
  bool mongory_validate_ptr(mongory_memory_pool *pool, char *name, void *ptr, char *file, int line) {
107
- if (pool->error != NULL) {
127
+ if (!pool || pool->error != NULL) {
108
128
  return false;
109
129
  }
110
130
  if (ptr == NULL) {
111
- mongory_error *error = MG_ALLOC_PTR(pool, mongory_error);
112
- error->type = MONGORY_ERROR_INVALID_ARGUMENT;
113
- error->message = mongory_string_cpyf(pool, "Null pointer: %s (at %s:%d)", name, file, line);
114
- pool->error = error;
131
+ char *msg = mongory_string_cpyf(pool, "Null pointer: %s (at %s:%d)", name, file, line);
132
+ if (pool->error == NULL) {
133
+ mongory_error_set(pool, MONGORY_ERROR_INVALID_ARGUMENT, msg ? msg : "Null pointer");
134
+ }
115
135
  return false;
116
136
  }
117
137
  return true;
@@ -122,94 +142,63 @@ static char *error_format =
122
142
  "%s needs %s, got %s\n"
123
143
  "(%s:%d)\n";
124
144
 
145
+ static bool mongory_validate_type_error(mongory_memory_pool *pool, char *name, const char *expected,
146
+ mongory_value *value, char *file, int line) {
147
+ char *msg = mongory_string_cpyf(pool, error_format, name, expected, mongory_type_to_string(value), file, line);
148
+ if (pool->error == NULL) {
149
+ mongory_error_set(pool, MONGORY_ERROR_INVALID_ARGUMENT, msg ? msg : "Invalid argument type");
150
+ }
151
+ return false;
152
+ }
153
+
125
154
  bool mongory_validate_table(mongory_memory_pool *pool, char *name, mongory_value *value, char *file, int line) {
126
- if (pool->error != NULL) {
155
+ if (!pool || pool->error != NULL) {
127
156
  return false;
128
157
  }
129
158
  if (!mongory_validate_ptr(pool, name, value, file, line)) {
130
159
  return false;
131
160
  }
132
161
  if (value->type != MONGORY_TYPE_TABLE) {
133
- mongory_error *error = MG_ALLOC_PTR(pool, mongory_error);
134
- error->type = MONGORY_ERROR_INVALID_ARGUMENT;
135
- error->message = mongory_string_cpyf(pool, error_format,
136
- name,
137
- "Table",
138
- mongory_type_to_string(value),
139
- file,
140
- line
141
- );
142
- pool->error = error;
143
- return false;
162
+ return mongory_validate_type_error(pool, name, "Table", value, file, line);
144
163
  }
145
164
  return true;
146
165
  }
147
166
 
148
167
  bool mongory_validate_array(mongory_memory_pool *pool, char *name, mongory_value *value, char *file, int line) {
149
- if (pool->error != NULL) {
168
+ if (!pool || pool->error != NULL) {
150
169
  return false;
151
170
  }
152
171
  if (!mongory_validate_ptr(pool, name, value, file, line)) {
153
172
  return false;
154
173
  }
155
174
  if (value->type != MONGORY_TYPE_ARRAY) {
156
- mongory_error *error = MG_ALLOC_PTR(pool, mongory_error);
157
- error->type = MONGORY_ERROR_INVALID_ARGUMENT;
158
- error->message = mongory_string_cpyf(pool, error_format,
159
- name,
160
- "Array",
161
- mongory_type_to_string(value),
162
- file,
163
- line
164
- );
165
- pool->error = error;
166
- return false;
175
+ return mongory_validate_type_error(pool, name, "Array", value, file, line);
167
176
  }
168
177
  return true;
169
178
  }
170
179
 
171
180
  bool mongory_validate_string(mongory_memory_pool *pool, char *name, mongory_value *value, char *file, int line) {
172
- if (pool->error != NULL) {
181
+ if (!pool || pool->error != NULL) {
173
182
  return false;
174
183
  }
175
184
  if (!mongory_validate_ptr(pool, name, value, file, line)) {
176
185
  return false;
177
186
  }
178
187
  if (value->type != MONGORY_TYPE_STRING) {
179
- mongory_error *error = MG_ALLOC_PTR(pool, mongory_error);
180
- error->type = MONGORY_ERROR_INVALID_ARGUMENT;
181
- error->message = mongory_string_cpyf(pool, error_format,
182
- name,
183
- "String",
184
- mongory_type_to_string(value),
185
- file,
186
- line
187
- );
188
- pool->error = error;
189
- return false;
188
+ return mongory_validate_type_error(pool, name, "String", value, file, line);
190
189
  }
191
190
  return true;
192
191
  }
193
192
 
194
193
  bool mongory_validate_number(mongory_memory_pool *pool, char *name, mongory_value *value, char *file, int line) {
195
- if (pool->error != NULL) {
194
+ if (!pool || pool->error != NULL) {
196
195
  return false;
197
196
  }
198
197
  if (!mongory_validate_ptr(pool, name, value, file, line)) {
199
198
  return false;
200
199
  }
201
200
  if (value->type != MONGORY_TYPE_INT && value->type != MONGORY_TYPE_DOUBLE) {
202
- mongory_error *error = MG_ALLOC_PTR(pool, mongory_error);
203
- error->type = MONGORY_ERROR_INVALID_ARGUMENT;
204
- error->message = mongory_string_cpyf(pool, error_format,
205
- name,
206
- "Number",
207
- mongory_type_to_string(value),
208
- file,
209
- line
210
- );
211
- pool->error = error;
212
- return false;
201
+ return mongory_validate_type_error(pool, name, "Number", value, file, line);
213
202
  }
214
203
  return true;
215
204
  }
@@ -52,6 +52,13 @@ char *mongory_string_cpyf(mongory_memory_pool *pool, char *format, ...);
52
52
 
53
53
  double mongory_log(double x, double base);
54
54
 
55
+ /**
56
+ * @brief Sets `pool->error` safely without dereferencing NULL on OOM.
57
+ * If allocating `mongory_error` from `pool` fails, falls back to the static
58
+ * `&MONGORY_ALLOC_ERROR`. Does not overwrite an already-set `pool->error`.
59
+ */
60
+ void mongory_error_set(mongory_memory_pool *pool, mongory_error_type type, const char *message);
61
+
55
62
  bool mongory_validate_ptr(mongory_memory_pool *pool, char *name, void *ptr, char *file, int line);
56
63
  #define MONGORY_VALIDATE_PTR(pool, ptr) mongory_validate_ptr(pool, #ptr, ptr, __FILE__, __LINE__)
57
64
 
@@ -240,6 +240,9 @@ mongory_value *mongory_value_wrap_s(mongory_memory_pool *pool, char *s_val) {
240
240
  // when `s_val` was not NULL, but this requires a more complex error handling
241
241
  // strategy with the memory pool.
242
242
  value->data.s = mongory_string_cpy(pool, s_val);
243
+ if (s_val != NULL && value->data.s == NULL) {
244
+ return NULL;
245
+ }
243
246
  value->comp = mongory_value_string_compare;
244
247
  value->to_str = mongory_value_string_to_str;
245
248
  return value;
@@ -15,6 +15,65 @@
15
15
  #include "matcher_traversable.h"
16
16
  #include "../foundations/utils.h"
17
17
 
18
+ #if defined(_MSC_VER)
19
+ # define MONGORY_THREAD_LOCAL __declspec(thread)
20
+ #else
21
+ # define MONGORY_THREAD_LOCAL __thread
22
+ #endif
23
+
24
+ static MONGORY_THREAD_LOCAL mongory_compile_budget mongory_tls_compile_budget = {0};
25
+
26
+ mongory_compile_budget mongory_compile_budget_begin(void) {
27
+ mongory_compile_budget saved = mongory_tls_compile_budget;
28
+ mongory_tls_compile_budget.active = true;
29
+ mongory_tls_compile_budget.depth = 0;
30
+ mongory_tls_compile_budget.nodes = 0;
31
+ mongory_tls_compile_budget.max_depth = mongory_max_depth_get();
32
+ mongory_tls_compile_budget.max_nodes = mongory_max_nodes_get();
33
+ return saved;
34
+ }
35
+
36
+ void mongory_compile_budget_end(mongory_compile_budget saved) {
37
+ mongory_tls_compile_budget = saved;
38
+ }
39
+
40
+ bool mongory_compile_budget_enter_depth(mongory_memory_pool *pool) {
41
+ if (!mongory_tls_compile_budget.active) {
42
+ return true;
43
+ }
44
+ mongory_tls_compile_budget.depth++;
45
+ if (mongory_tls_compile_budget.max_depth > 0 &&
46
+ mongory_tls_compile_budget.depth > mongory_tls_compile_budget.max_depth) {
47
+ mongory_tls_compile_budget.depth--;
48
+ if (pool && pool->error == NULL) {
49
+ pool->error = &MONGORY_DEPTH_LIMIT_ERROR;
50
+ }
51
+ return false;
52
+ }
53
+ return true;
54
+ }
55
+
56
+ void mongory_compile_budget_leave_depth(void) {
57
+ if (mongory_tls_compile_budget.active && mongory_tls_compile_budget.depth > 0) {
58
+ mongory_tls_compile_budget.depth--;
59
+ }
60
+ }
61
+
62
+ bool mongory_compile_budget_count_node(mongory_memory_pool *pool) {
63
+ if (!mongory_tls_compile_budget.active) {
64
+ return true;
65
+ }
66
+ mongory_tls_compile_budget.nodes++;
67
+ if (mongory_tls_compile_budget.max_nodes > 0 &&
68
+ mongory_tls_compile_budget.nodes > mongory_tls_compile_budget.max_nodes) {
69
+ if (pool && pool->error == NULL) {
70
+ pool->error = &MONGORY_NODE_LIMIT_ERROR;
71
+ }
72
+ return false;
73
+ }
74
+ return true;
75
+ }
76
+
18
77
  /**
19
78
  * @brief Allocates and initializes common fields of a `mongory_matcher`.
20
79
  *
@@ -35,6 +94,9 @@ mongory_matcher *mongory_matcher_base_new(mongory_memory_pool *pool, mongory_val
35
94
  if (!pool || !pool->alloc) {
36
95
  return NULL; // Invalid memory pool.
37
96
  }
97
+ if (!mongory_compile_budget_count_node(pool)) {
98
+ return NULL;
99
+ }
38
100
  mongory_matcher *matcher = MG_ALLOC_PTR(pool, mongory_matcher);
39
101
  if (matcher == NULL) {
40
102
  // Allocation failed, pool->alloc might set pool->error.
@@ -86,6 +148,9 @@ mongory_matcher *mongory_matcher_always_true_new(mongory_memory_pool *pool, mong
86
148
  matcher->match = mongory_matcher_always_true_match;
87
149
  matcher->original_match = mongory_matcher_always_true_match;
88
150
  matcher->name = mongory_string_cpy(pool, "Always True");
151
+ if (!matcher->name) {
152
+ return NULL;
153
+ }
89
154
  matcher->explain = mongory_matcher_base_explain;
90
155
  // Optionally set original_match as well if it's a strict policy
91
156
  // matcher->context.original_match = mongory_matcher_always_true_match;
@@ -119,6 +184,9 @@ mongory_matcher *mongory_matcher_always_false_new(mongory_memory_pool *pool, mon
119
184
  matcher->match = mongory_matcher_always_false_match;
120
185
  matcher->original_match = mongory_matcher_always_false_match;
121
186
  matcher->name = mongory_string_cpy(pool, "Always False");
187
+ if (!matcher->name) {
188
+ return NULL;
189
+ }
122
190
  matcher->explain = mongory_matcher_base_explain;
123
191
  // matcher->context.original_match = mongory_matcher_always_false_match;
124
192
  return matcher;
@@ -100,4 +100,18 @@ mongory_matcher *mongory_matcher_always_false_new(mongory_memory_pool *pool, mon
100
100
 
101
101
  void mongory_matcher_enable_trace_at(mongory_matcher *matcher, mongory_array *trace_stack, int level);
102
102
 
103
+ typedef struct mongory_compile_budget {
104
+ bool active;
105
+ size_t depth;
106
+ size_t nodes;
107
+ size_t max_depth;
108
+ size_t max_nodes;
109
+ } mongory_compile_budget;
110
+
111
+ mongory_compile_budget mongory_compile_budget_begin(void);
112
+ void mongory_compile_budget_end(mongory_compile_budget saved);
113
+ bool mongory_compile_budget_enter_depth(mongory_memory_pool *pool);
114
+ void mongory_compile_budget_leave_depth(void);
115
+ bool mongory_compile_budget_count_node(mongory_memory_pool *pool);
116
+
103
117
  #endif /* MONGORY_MATCHER_BASE_H */
@@ -127,6 +127,11 @@ mongory_matcher *mongory_matcher_not_equal_new(mongory_memory_pool *pool, mongor
127
127
  return matcher;
128
128
  }
129
129
 
130
+ static inline bool mongory_value_is_orderable(const mongory_value *value) {
131
+ return value != NULL &&
132
+ (value->type == MONGORY_TYPE_INT || value->type == MONGORY_TYPE_DOUBLE || value->type == MONGORY_TYPE_STRING);
133
+ }
134
+
130
135
  /**
131
136
  * @brief Match function for "greater than" ($gt).
132
137
  * @param matcher The $gt matcher instance.
@@ -135,7 +140,7 @@ mongory_matcher *mongory_matcher_not_equal_new(mongory_memory_pool *pool, mongor
135
140
  * otherwise or on comparison failure.
136
141
  */
137
142
  static inline bool mongory_matcher_greater_than_match(mongory_matcher *matcher, mongory_value *value) {
138
- if (!value || !value->comp || !matcher->condition)
143
+ if (!mongory_value_is_orderable(value) || !mongory_value_is_orderable(matcher->condition) || !value->comp)
139
144
  return false;
140
145
  int result = value->comp(value, matcher->condition);
141
146
  if (result == mongory_value_compare_fail) {
@@ -162,7 +167,7 @@ mongory_matcher *mongory_matcher_greater_than_new(mongory_memory_pool *pool, mon
162
167
  * on comparison failure.
163
168
  */
164
169
  static inline bool mongory_matcher_less_than_match(mongory_matcher *matcher, mongory_value *value) {
165
- if (!value || !value->comp || !matcher->condition)
170
+ if (!mongory_value_is_orderable(value) || !mongory_value_is_orderable(matcher->condition) || !value->comp)
166
171
  return false;
167
172
  int result = value->comp(value, matcher->condition);
168
173
  if (result == mongory_value_compare_fail) {
@@ -189,7 +194,7 @@ mongory_matcher *mongory_matcher_less_than_new(mongory_memory_pool *pool, mongor
189
194
  * comparison failure.
190
195
  */
191
196
  static inline bool mongory_matcher_greater_than_or_equal_match(mongory_matcher *matcher, mongory_value *value) {
192
- if (!value || !value->comp || !matcher->condition)
197
+ if (!mongory_value_is_orderable(value) || !mongory_value_is_orderable(matcher->condition) || !value->comp)
193
198
  return false;
194
199
  int result = value->comp(value, matcher->condition);
195
200
  if (result == mongory_value_compare_fail) {
@@ -216,7 +221,7 @@ mongory_matcher *mongory_matcher_greater_than_or_equal_new(mongory_memory_pool *
216
221
  * comparison failure.
217
222
  */
218
223
  static inline bool mongory_matcher_less_than_or_equal_match(mongory_matcher *matcher, mongory_value *value) {
219
- if (!value || !value->comp || !matcher->condition)
224
+ if (!mongory_value_is_orderable(value) || !mongory_value_is_orderable(matcher->condition) || !value->comp)
220
225
  return false;
221
226
  int result = value->comp(value, matcher->condition);
222
227
  if (result == mongory_value_compare_fail) {