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

MongoIds pass integer validation whether you are using mongo or not #4659

Closed
kevinburkeshyp opened this issue Dec 12, 2015 · 5 comments
Closed
Labels
bug orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc.

Comments

@kevinburkeshyp
Copy link

Relevant code in core/validations.js

    // If type is integer and the value matches a mongoID let it validate
    if(hasOwnProperty(self.validations[validation], 'type') && self.validations[validation].type === 'integer') {
      if(utils.matchMongoId(value)) return cb();
    }

So it seems like if I am using Postgres but I pass something like "4cdfb11e1f3c000000007822" as an integer value, Waterline will pass it to the database without applying the normal validation.

@devinivy
Copy link

I agree that this is smelly. We need to rip out some mongo-specific references within waterline, including this. Adapters currently do have the ability to set their own primary key type.

@johnabrams7 johnabrams7 transferred this issue from balderdashy/waterline Mar 6, 2019
@johnabrams7 johnabrams7 added orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc. patched bug labels Mar 6, 2019
@johnabrams7
Copy link
Contributor

johnabrams7 commented Mar 6, 2019

@kevinburke @devinivy Hey, we moved this Mongolds issue to our main Sails hub with the label "orm." It appears to have been patched in a newer version of Waterline. Thanks for sharing this info and hope it's working for everyone now.

@kevinburke
Copy link
Contributor

Great! Thanks!

@raqem
Copy link
Contributor

raqem commented Apr 10, 2019

Hi @kevinburke @devinivy we are further cleaning up the Sails issues by closing old ones and issues that have been patched with newer versions.

@raqem raqem closed this as completed Apr 10, 2019
@johnabrams7
Copy link
Contributor

This has been published.

@balderdashy balderdashy locked as resolved and limited conversation to collaborators Apr 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc.
Development

No branches or pull requests

5 participants