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

SQL adapter select queries #214

Open
troyastorino opened this issue Jun 17, 2014 · 4 comments
Open

SQL adapter select queries #214

troyastorino opened this issue Jun 17, 2014 · 4 comments

Comments

@troyastorino
Copy link
Contributor

It seems like the SQL adapter doesn't check for types before executing a query. For example, I have a column that is of type 'number', and some data coming in that is assigned to that column isn't a valid number (it is a string 'Normal'). The generated select query trusts that it is a number, and so the generated query has it unquoted. For this case, SQL thinks 'normal' is a column name, doesn't find it, and errors out.

@ben-ng
Copy link

ben-ng commented Jun 17, 2014

Yes, we should definitely fix this. Can you add a failing test for us? Should be fairly simple, this test is a good template.

@mde
Copy link
Contributor

mde commented Jun 17, 2014

The validation process for a number property on a model item should coerce string values to number/int if possible, and add an error to the 'errors' property on the instance if it's not possible. In that case, isValid for that instance will be false.

We have a bunch of tests for this: https://github.com/geddy/model/blob/master/test/unit/datatypes.js#L23

Are you not going through the normal item-creation process?

@mde
Copy link
Contributor

mde commented Jun 17, 2014

Ah, when you say "assigned to that column," are you talking about the filter values in the query object?

@troyastorino
Copy link
Contributor Author

This wasn't in creation of a item; it was in querying for items. Ya I meant a filter value in the query object. I'll put a test together tonight or tomorrow.

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

No branches or pull requests

3 participants