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

Grouper doesn't always return correct result #2

Closed
radedespo opened this issue Mar 10, 2014 · 2 comments
Closed

Grouper doesn't always return correct result #2

radedespo opened this issue Mar 10, 2014 · 2 comments
Labels

Comments

@radedespo
Copy link
Member

Fail test scenario

/*

User database rows:

id(integer)     metadata(json)
1               [{'a':1},{'a':2}]
2               [{'b':5},{'b':8}]

*/

var user = db.define({
    name: 'user',
    columns: {
        'id': {primaryKey: true}, 
        'metadata':{}
    }
});

t.test('get user metadata', function(t) {
        user.from(user)
                .where(user.id.equals(1))
                .selectDeep(user)
                .all(function(err,user){
                        t.notOk(user.metadata instanceof Array == false, "The metadata should be an Array object");
                        t.end();
                });
});
@radedespo radedespo added the bug label Mar 10, 2014
@spion
Copy link
Contributor

spion commented Mar 10, 2014

Figured it out - this happens in the cleaner. The reason is - the cleaner doesn't know that metadata is supposed to have an array type (thats unaccounted for in column types).

To fix this we will need to special-case JSON columns.

Edit: no, just special-casing has properties that are not of type many worked pretty well.

@spion
Copy link
Contributor

spion commented Mar 10, 2014

fixed in v0.6.12

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

No branches or pull requests

2 participants