不要怂,就是干,撸起袖子干!

Commit 4d17304a by Michael Schonfeld

add insert pr ignore support for sqlite + tests

1 parent 3b9faacf
......@@ -172,8 +172,8 @@ module.exports = (function() {
return "SELECT name FROM sqlite_master WHERE type='table' and name!='sqlite_sequence';"
},
bulkInsertQuery: function(tableName, attrValueHashes) {
var query = "INSERT INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %>;"
bulkInsertQuery: function(tableName, attrValueHashes, options) {
var query = "INSERT<%= ignore %> INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %>;"
, tuples = []
, allAttributes = []
......@@ -192,6 +192,7 @@ module.exports = (function() {
}.bind(this))
var replacements = {
ignore: options && options.ignore ? ' OR IGNORE' : '',
table: this.quoteIdentifier(tableName),
attributes: allAttributes.map(function(attr){
return this.quoteIdentifier(attr)
......
......@@ -385,6 +385,9 @@ if (dialect === 'sqlite') {
arguments: ['myTable', [{name: 'foo', foo: 1, nullValue: null}, {name: 'bar', foo: 2, nullValue: null}]],
expectation: "INSERT INTO `myTable` (`name`,`foo`,`nullValue`) VALUES ('foo',1,NULL),('bar',2,NULL);",
context: {options: {omitNull: true}} // Note: As above
}, {
arguments: ['myTable', [{name: 'foo'}, {name: 'bar'}], {ignore: true}],
expectation: "INSERT OR IGNORE INTO `myTable` (`name`) VALUES ('foo'),('bar');"
}
],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!