Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 4d17304a
authored
Jan 28, 2014
by
Michael Schonfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add insert pr ignore support for sqlite + tests
1 parent
3b9faacf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
lib/dialects/sqlite/query-generator.js
test/sqlite/query-generator.test.js
lib/dialects/sqlite/query-generator.js
View file @
4d17304
...
@@ -172,8 +172,8 @@ module.exports = (function() {
...
@@ -172,8 +172,8 @@ module.exports = (function() {
return
"SELECT name FROM sqlite_master WHERE type='table' and name!='sqlite_sequence';"
return
"SELECT name FROM sqlite_master WHERE type='table' and name!='sqlite_sequence';"
},
},
bulkInsertQuery
:
function
(
tableName
,
attrValueHashes
)
{
bulkInsertQuery
:
function
(
tableName
,
attrValueHashes
,
options
)
{
var
query
=
"INSERT INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %>;"
var
query
=
"INSERT
<%= ignore %>
INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %>;"
,
tuples
=
[]
,
tuples
=
[]
,
allAttributes
=
[]
,
allAttributes
=
[]
...
@@ -192,6 +192,7 @@ module.exports = (function() {
...
@@ -192,6 +192,7 @@ module.exports = (function() {
}.
bind
(
this
))
}.
bind
(
this
))
var
replacements
=
{
var
replacements
=
{
ignore
:
options
&&
options
.
ignore
?
' OR IGNORE'
:
''
,
table
:
this
.
quoteIdentifier
(
tableName
),
table
:
this
.
quoteIdentifier
(
tableName
),
attributes
:
allAttributes
.
map
(
function
(
attr
){
attributes
:
allAttributes
.
map
(
function
(
attr
){
return
this
.
quoteIdentifier
(
attr
)
return
this
.
quoteIdentifier
(
attr
)
...
...
test/sqlite/query-generator.test.js
View file @
4d17304
...
@@ -385,6 +385,9 @@ if (dialect === 'sqlite') {
...
@@ -385,6 +385,9 @@ if (dialect === 'sqlite') {
arguments
:
[
'myTable'
,
[{
name
:
'foo'
,
foo
:
1
,
nullValue
:
null
},
{
name
:
'bar'
,
foo
:
2
,
nullValue
:
null
}]],
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);"
,
expectation
:
"INSERT INTO `myTable` (`name`,`foo`,`nullValue`) VALUES ('foo',1,NULL),('bar',2,NULL);"
,
context
:
{
options
:
{
omitNull
:
true
}}
// Note: As above
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');"
}
}
],
],
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment