|
@@ -1977,7 +1977,23 @@ uint64_t MemoryStore::currentTimeFor(const std::string& collection) const {
|
|
|
|
|
|
|
|
bool MemoryStore::matchesFilters(const Document& doc, const std::vector<Filter>& filters) const {
|
|
bool MemoryStore::matchesFilters(const Document& doc, const std::vector<Filter>& filters) const {
|
|
|
for (const auto& filter : filters) {
|
|
for (const auto& filter : filters) {
|
|
|
- auto value = getJsonPath(doc.data, filter.field);
|
|
|
|
|
|
|
+ // DB-system fields live on the Document protobuf, not inside doc.data.
|
|
|
|
|
+ // The sort path already special-cases them (see line ~847); the filter
|
|
|
|
|
+ // path needs the same treatment, otherwise clients can sort by
|
|
|
|
|
+ // `_created_at` but never filter by it (cursor-based pagination
|
|
|
|
|
+ // breaks — every `_created_at < X` probe returns empty).
|
|
|
|
|
+ std::optional<nlohmann::json> value;
|
|
|
|
|
+ if (filter.field == "_created_at") {
|
|
|
|
|
+ value = nlohmann::json(doc.createdAt);
|
|
|
|
|
+ } else if (filter.field == "_updated_at") {
|
|
|
|
|
+ value = nlohmann::json(doc.updatedAt);
|
|
|
|
|
+ } else if (filter.field == "_id") {
|
|
|
|
|
+ value = nlohmann::json(doc.id);
|
|
|
|
|
+ } else if (filter.field == "_version") {
|
|
|
|
|
+ value = nlohmann::json(doc.version);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ value = getJsonPath(doc.data, filter.field);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
switch (filter.op) {
|
|
switch (filter.op) {
|
|
|
case FilterOp::EXISTS:
|
|
case FilterOp::EXISTS:
|