CSNW / sql-bricks

Transparent, Schemaless SQL Generation
http://csnw.github.io/sql-bricks
MIT License
204 stars 25 forks source link

Incorrect Value Order For Multiple Inserts #82

Closed bendytree closed 7 years ago

bendytree commented 8 years ago

I've reproduced this on node 0.10.26 and Google Chrome:

sql.insert('thing', [{name:"A",age:21},{age:30,name:"B"}]).toString()

> "INSERT INTO thing (name, age) VALUES ('A', 21), (30, 'B')"

Same with insertInto:

sql.insertInto('thing').values([{name:"A",age:21},{age:30,name:"B"}]).toString()

> "INSERT INTO thing (name, age) VALUES ('A', 21), (30, 'B')"
prust commented 8 years ago

Thanks for the report & for reproducing on both node and Chrome @bendytree! I'm under a couple of deadlines right now, but should be able to take a look over the weekend.

bendytree commented 8 years ago

Thanks - I've already worked around it so no rush.

I also notice a problem if a nullable field is omitted on the first object:

sql.insert('thing', [{name:"A"},{name:"B",age:30}]).toString()

> "INSERT INTO thing (name) VALUES ('A'), ('B', 30)"