Skip to content

Bug: 'Insert' statement turns into 'Select' statement in some scenarios #180

@sidazhang

Description

@sidazhang
var sql = require('sql')
var model = sql.define({
  name: 'test',
  columns: ['c1', 'c2']
})

console.log(model.insert([]).toQuery())
/*
This should throw an error as I am trying to insert nothing.
Clearly a mistake on the programmer's side

Instead, it fails silently:
-> { text: 'SELECT * FROM "test"', values: [] }

This means that the programmer won't be alerted to the mistake.
Because the query will not throw an error.
*/

This scenario should throw an error and alert the programmer. In any case, it should not turn into a select

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions