-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Aggregation match doesn't seem to work with date value #4678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for reporting. I'll have a look. |
I have been facing the same issue and it is related to only Date fields , number works fine. |
Any updates on this? TIA |
Same here |
extracting databaseController adapter is my workaround. Parse.Cloud.define("testMongoAggregate", function(request, response) { const schema = { const start = moment.utc().startOf('day'); // Start of day const pipeline = [ app.databaseController.adapter |
Sorry guys been off the grid. I'll submit a PR sometime this week. |
FWIW, in my debugging last night (if I remember correctly) |
Yes, this was definitely it. When I converted the strings to src/Adapters/Storage/Mongo/MongoStorageAdapter.js
|
Go ahead with the PR! That sound like a good fiz |
PR is GH-4743 let me know if you have any other improvements. |
Same bug for me. |
#4743) * #4678: Converting strings to Date when schema.type is Date within aggregate function * Added test cases to test new date match aggregate query * Added function to parse match aggregate arguments and convert necessary values to Date objects * Added missing return value * Improved code quality based on suggestions and figured out why tests were failing * Added tests from @dplewis * Supporting project aggregation as well as exists operator * Excluding exists match for postgres * Handling the $group operator similar to $match and $project * Added more tests for better code coverage * Excluding certain tests from being run on postgres * Excluding one more test from postgres * clean up
Closed via #4743 |
#4743) * #4678: Converting strings to Date when schema.type is Date within aggregate function * Added test cases to test new date match aggregate query * Added function to parse match aggregate arguments and convert necessary values to Date objects * Added missing return value * Improved code quality based on suggestions and figured out why tests were failing * Added tests from @dplewis * Supporting project aggregation as well as exists operator * Excluding exists match for postgres * Handling the $group operator similar to $match and $project * Added more tests for better code coverage * Excluding certain tests from being run on postgres * Excluding one more test from postgres * clean up
#4743) * #4678: Converting strings to Date when schema.type is Date within aggregate function * Added test cases to test new date match aggregate query * Added function to parse match aggregate arguments and convert necessary values to Date objects * Added missing return value * Improved code quality based on suggestions and figured out why tests were failing * Added tests from @dplewis * Supporting project aggregation as well as exists operator * Excluding exists match for postgres * Handling the $group operator similar to $match and $project * Added more tests for better code coverage * Excluding certain tests from being run on postgres * Excluding one more test from postgres * clean up
It's still have a bug with this code:
I have edited the source code of MongoStorageAdapter.js to debug
And what I received are: |
I have the same problem as @anhnhv2812. Could you please create a new bug so we can track and try and get this fixed, or do you want me to do it? |
I have the same issue, and with custom fields that are created by the aggregation pipeline, and not in the base Schema, the dates are not detected.
condition before the Anyway, testing the schema in all the pipeline is weird as all the fields can be changed/removed/added at every stage, so the schema is not coherent anymore. |
…Date within agg… (parse-community#4743) * parse-community#4678: Converting strings to Date when schema.type is Date within aggregate function * Added test cases to test new date match aggregate query * Added function to parse match aggregate arguments and convert necessary values to Date objects * Added missing return value * Improved code quality based on suggestions and figured out why tests were failing * Added tests from @dplewis * Supporting project aggregation as well as exists operator * Excluding exists match for postgres * Handling the $group operator similar to $match and $project * Added more tests for better code coverage * Excluding certain tests from being run on postgres * Excluding one more test from postgres * clean up
There is another work-around :
Where "2020-09-09T00:00:00.000Z" can be used as string. |
Thanks for the workaround @adrianaxente |
Here is the new syntax for Parse v6 +
Not that unlike in previous versions you use _id instead of objectId, and you must prefix the stages with $ just like directtly in MongoDB |
Issue Description
When using the new aggregate options with a match pipeline on a Date value, it silently fails with empty result.
By the way, to match a
createdAt
or aupdatedAt
field, we have to use the db form_created_at
/_updated_at
, and I'm not sure it's on purpose. Either way, we can't query them with the standard$lt
or$gt
operator.Steps to reproduce
query.aggregate([{match: {_created_at:{$lt:new Date()}}}])
always returns[]
whereas
query.aggregate([{match: {_created_at:{$exists:true}}}])
works perfectly.Expected Results
Both results should be the same
Server
Database
The text was updated successfully, but these errors were encountered: