Skip to content

Passing undefined variable to a selector returns all records in the model #3

@misham

Description

@misham

Assuming there's a model Foo that looks like this:

var Schema = require('decaf-mysql').Schema;

Schema.add({
    name       : 'Foo',
    primaryKey : 'fooId',
    fields     : [
        { name : 'fooId', type : 'int', autoIncrement : true },
        { name : 'name', type : 'varchar', size : 255 },
        { name : 'categoryId', type : 'int', defaultValue : 0 }
    ]
});

Running the following selector returns all values:

var id = undefined;
var result = Schema.find('Foo', {fooId: id});

result contains all rows in Foo.

A better approach would be to throw an error that the selector is undefined or return empty perhaps?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions