Skip to content
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

Any filter condition including a dot (.) in the property name is stripped #38

Closed
fra967 opened this issue Mar 15, 2016 · 3 comments
Closed
Assignees
Milestone

Comments

@fra967
Copy link

fra967 commented Mar 15, 2016

Expected behavior

Any query targeting a Mixed field to be passed to the database

Actual behavior

Queries including a valid path are stripped

For example

localhost:3000/1.0/articles/celebrity?page=1&count=1&filter={"subtitle":"test","editor.editor_name":"test"}

is passed to Mongo as

        "query" : {
                "subtitle" : /^test$/i,
                "apiVersion" : "1.0"
        },

Note that editor.editor_name is not present

Steps to reproduce the problem

It seems that API queries are validated against the schema, and if they include an invalid reference they are stripped. However editor in this case is Mixed, and contains other subdocuments, which are individually validated in the schema
https://github.com/dadiplus/bauer-lifestyle-serama/blob/dev/workspace/collections/1.0/articles/collection.celebrity.json

It didn't seem possible to enforce validation on a subelement in the previous API version, but it had to be written at root level. The document in the sample request above includes this field

        "editor" : {
                "editor_id" : "566f8a14975babee0989528c",
                "editor_name" : "Francesco Iannuzzelli"
        },

In any case, validation shouldn't be enforced on queries targeting a Mixed field, as that could contain anything. This is particularly applicable to dates that are stored as Mongo dates, for example

        "publicationDate" : {
                "sec" : 1462119300,
                "usec" : 0
        },

(this is actually the origin of this issue, as queries targeting the publicationDate.sec timestamp fail in Bauer Lifestyle)

Package details

1.3.0

@jimlambie jimlambie self-assigned this Mar 16, 2016
@jimlambie jimlambie added this to the 1.4.0 milestone Mar 16, 2016
@fra967 fra967 reopened this Apr 6, 2016
@fra967
Copy link
Author

fra967 commented Apr 6, 2016

I would expect the same to happen in an Object field (that is, being able to query a sub-element)

eduardoboucas pushed a commit that referenced this issue Apr 6, 2016
@eduardoboucas
Copy link
Contributor

I believe this fixes it. Can you have a look @jimlambie?

Thanks!

@jimlambie
Copy link
Contributor

Closed by commit 7270f94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants