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

integration test for sqlite3, referencing non-existent column in the query #2104

Merged
merged 2 commits into from Jun 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions test/integration/schema/index.js
Expand Up @@ -630,5 +630,49 @@ module.exports = function(knex) {
});
});


describe('invalid field', function() {
describe('sqlite3 only', function() {
var tableName = 'invalid_field_test_sqlite3';
var fieldName = 'field_foo';
if(!knex || !knex.client || (!(/sqlite3/i.test(knex.client.dialect)))) {
return Promise.resolve();
}

before(function() {
return knex.schema.createTable(tableName, function (tbl) {
tbl.integer(fieldName);
});
});

after(function() {
return knex.schema.dropTable(tableName);
});

it('should return empty resultset when referencing an existent column', function() {

return knex(tableName).select().where(fieldName, "something").then(function(rows){
expect(rows.length).to.equal(0);
})

});

it('should throw when referencing a non-existent column', function() {

return knex(tableName).select().where(fieldName+"foo", "something")
.then(function(){
throw new Error("should have failed");
})
.catch(function(err){
expect(err.code).to.equal("SQLITE_ERROR");
})

});


});
});


});
};