You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Maybe) A flag that disables the validations completely
I've closed the issues linked here, since they all relate to the same basic problem.
Important: I don't think we should roll back the validation function - it still has its merits. For affected users, either roll back to 3.4.1, or remove the validte function DataTypes.INTEGER.validate = function () { return true };
As mentioned, at least some validators should only be run on update / insert. My suggestion would be to add a context parameter to the validate function, so for example uuids are only validated when inserted / updated. We might also add a context like nested, to show the the value comes from a $like { $any or similar, and might be an array, object etc.
One way to check that the string is a valid number is to just coerce it to one. IMO this is a better check than more complex ones which become more expensive as well.
(Maybe) A flag that disables the validations completely
Yes please. If I don't care about client side validation in my app and am happy to let the db handle it, I can avoid poorly defined validation code and having it run every time.
I'm leaning towards @defunctzombie's argument here, we might need to rollback the validations untill they are working properly (i too was bitten by the fact that i knew my DB could handle a certain value but the Sequelize codebase claimed otherwise).
I have also noticed a change to the id field support. If I specify the id field as just a type, then I get not an integer errors but if I use the longer form specification type: ... , primaryKey: ... then it works. Not as much of an issue as I find the longer form to be more explicit and better but it is some additional breakage to possibly look into. Tangentially related to the validators.
I will add that the validators did help me catch some poorly defined types for my models (don't know how that affects dependent code in practice since the types were mis-defined to integer but were really strings) so having some way to enable them so I can use them in testing and development certainly could be a win.
(great work with this library, btw, incredibly usefull and great performing)
In my humble opinion; validations would be better off by default, and let the user decide if he/she wants an early validation or a DB error. And regarding the case at hand; validations should be performed after type casting (and type casting is paramount here, as missmatches will occur between the diferent data type catalogs of DBMS and js types).
I think the current biggest issue with this is the broken Numeric (or large
number) support from what my early attempts to upgrade revealed. Any word
on turning this off or providing an option?
I agree, something needs to be done. An option to disable all validation would be ideal.
I really don't like that I've had to limit all my projects to 3.4 in package.json
I agree, an option it is then - I still believe this is a good feature, but if the consensus against it is strong I would not be completely against removing it? However, I think that with a few adjustments we could make it nice :)
A lot of people voicing their opinion - so there should be someone here to take on the work and provide a PR as well :)
The biggest issue I have with the feature is the broken numeric data type support especially around large numbers. My vote is disabled by default (while it is hashed out) and allow folks to enable it for their test suites (which is a great place to catch some of these things).
I don't feel as strongly that this feature is a huge win mostly because some databases are more flexible in their data type acceptance than others leading to corner cases catching users off guard (like the Numeric case).
Yeah agree with @defunctzombie and @Julusian . Disable (default or not doesn't bother me), but this would at least allow us to insert the values we need until this is properly implemented.
then ER_BAD_FIELD_ERROR: Unknown column 'NaN' in 'field list' throws.
Why not Validator.isDecimal?
(APPEND: Sorry about NaN, i have checked postgres/query-generator.js line 880, any NOT TRUE value will not call validate at all.)
I've noticed this specifically with defined primary keys & migrations (ie. no sync()):
{ [SequelizeValidationError: 1 is not a valid string]
name: 'SequelizeValidationError',
message: '1 is not a valid string',
errors: [] } 'SequelizeValidationError: 1 is not a valid string
Confirmed that this error relates to my id column:
Activity
Gedzis commentedon Aug 18, 2015
For
Similarly, numbers are valid stringsvalidation function could be updated tojanmeier commentedon Aug 18, 2015
@Gedzis however, we don't want to allow all strings - only strings that are actually numbers :)
Add default validation based on attribute type
defunctzombie commentedon Aug 19, 2015
One way to check that the string is a valid number is to just coerce it to one. IMO this is a better check than more complex ones which become more expensive as well.
Note: scientific notation is automatically handled so if the db dialect being used doesn't like that, it needs to handle that separately.
defunctzombie commentedon Aug 19, 2015
Yes please. If I don't care about client side validation in my app and am happy to let the db handle it, I can avoid poorly defined validation code and having it run every time.
defunctzombie commentedon Aug 19, 2015
Also, adding the the DECIMAL type validation is currently completely broken as it will not support numbers outside of the js number range.
Can you roll a version that disables these validators by default so a more gradual tested rollout of validation can happen?
mickhansen commentedon Aug 19, 2015
I'm leaning towards @defunctzombie's argument here, we might need to rollback the validations untill they are working properly (i too was bitten by the fact that i knew my DB could handle a certain value but the Sequelize codebase claimed otherwise).
defunctzombie commentedon Aug 19, 2015
I have also noticed a change to the
idfield support. If I specify the id field as just a type, then I getnot an integer errorsbut if I use the longer form specificationtype: ... , primaryKey: ...then it works. Not as much of an issue as I find the longer form to be more explicit and better but it is some additional breakage to possibly look into. Tangentially related to the validators.I will add that the validators did help me catch some poorly defined types for my models (don't know how that affects dependent code in practice since the types were mis-defined to integer but were really strings) so having some way to enable them so I can use them in testing and development certainly could be a win.
Julusian commentedon Aug 26, 2015
I assume this is causing the following error when doing a DATE_SUB inside sequelize.literal
janmeier commentedon Aug 27, 2015
@Julusian Yep
beeant commentedon Aug 30, 2015
I'm having the same issue...
Error: { [SequelizeValidationError: 60 is not a valid string]mainakae commentedon Sep 3, 2015
one more affected :)
(great work with this library, btw, incredibly usefull and great performing)
In my humble opinion; validations would be better off by default, and let the user decide if he/she wants an early validation or a DB error. And regarding the case at hand; validations should be performed after type casting (and type casting is paramount here, as missmatches will occur between the diferent data type catalogs of DBMS and js types).
SBero commentedon Sep 9, 2015
Anybody know what's the newest version not affected by the validation issues?
janmeier commentedon Sep 9, 2015
@SBero , as mentioned in the top post, 3.4.1 ;)
SBero commentedon Sep 9, 2015
Ah missed that. Thanks!
wilsoncook commentedon Sep 14, 2015
Very eager for this being resolved, i'm stucked by upgrading from v2.0.x to v3.7
defunctzombie commentedon Sep 14, 2015
I think the current biggest issue with this is the broken Numeric (or large
number) support from what my early attempts to upgrade revealed. Any word
on turning this off or providing an option?
On Monday, September 14, 2015, Wilson Zeng [email protected] wrote:
mickhansen commentedon Sep 14, 2015
I'm still voting for a rollback untill we can implement a flag for this or better fixes.
It's mostly @janmeier's work so i'll defer to him.
Julusian commentedon Sep 14, 2015
I agree, something needs to be done. An option to disable all validation would be ideal.
I really don't like that I've had to limit all my projects to 3.4 in package.json
janmeier commentedon Sep 14, 2015
I agree, an option it is then - I still believe this is a good feature, but if the consensus against it is strong I would not be completely against removing it? However, I think that with a few adjustments we could make it nice :)
A lot of people voicing their opinion - so there should be someone here to take on the work and provide a PR as well :)
Julusian commentedon Sep 14, 2015
I think it is a good feature and shouldnt be removed, but some work is needed to make it less strict, along with a disable option/flag
janmeier commentedon Sep 14, 2015
@Julusian +1 :)
defunctzombie commentedon Sep 14, 2015
The biggest issue I have with the feature is the broken numeric data type support especially around large numbers. My vote is disabled by default (while it is hashed out) and allow folks to enable it for their test suites (which is a great place to catch some of these things).
I don't feel as strongly that this feature is a huge win mostly because some databases are more flexible in their data type acceptance than others leading to corner cases catching users off guard (like the Numeric case).
benkaiser commentedon Sep 14, 2015
Yeah agree with @defunctzombie and @Julusian . Disable (default or not doesn't bother me), but this would at least allow us to insert the values we need until this is properly implemented.
wilsoncook commentedon Sep 15, 2015
also noticed, the DECIMAL use
_.isNumber()to doing an validation, but it will allowInfinity/NaN, so this sql can be happened:then
ER_BAD_FIELD_ERROR: Unknown column 'NaN' in 'field list'throws.Why not
Validator.isDecimal?(APPEND: Sorry about NaN, i have checked postgres/query-generator.js line 880, any NOT TRUE value will not call
validateat all.)sterlingwes commentedon Oct 8, 2015
I've noticed this specifically with defined primary keys & migrations (ie. no sync()):
Confirmed that this error relates to my id column:
The actual insert was formatted correctly and the column is the right data type in postgres.