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 65cc93eb
authored
Jan 10, 2014
by
Steffen Persch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tests for postgres and sqlite
1 parent
48e3b6b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
test/postgres/query-generator.test.js
test/sqlite/query-generator.test.js
test/postgres/query-generator.test.js
View file @
65cc93e
...
@@ -268,8 +268,8 @@ if (dialect.match(/^postgres/)) {
...
@@ -268,8 +268,8 @@ if (dialect.match(/^postgres/)) {
},
{
},
{
title
:
'functions can take functions as arguments'
,
title
:
'functions can take functions as arguments'
,
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
return
{
return
{
order
:
[[
sequelize
.
fn
(
'f1'
,
sequelize
.
fn
(
'f2'
,
sequelize
.
col
(
'id'
))),
'DESC'
]]
order
:
[[
sequelize
.
fn
(
'f1'
,
sequelize
.
fn
(
'f2'
,
sequelize
.
col
(
'id'
))),
'DESC'
]]
}
}
}],
}],
expectation
:
'SELECT * FROM "myTable" ORDER BY f1(f2("id")) DESC;'
,
expectation
:
'SELECT * FROM "myTable" ORDER BY f1(f2("id")) DESC;'
,
...
@@ -280,7 +280,7 @@ if (dialect.match(/^postgres/)) {
...
@@ -280,7 +280,7 @@ if (dialect.match(/^postgres/)) {
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
return
{
return
{
order
:
[
order
:
[
[
sequelize
.
fn
(
'f1'
,
sequelize
.
col
(
'myTable.id'
)),
'DESC'
],
[
sequelize
.
fn
(
'f1'
,
sequelize
.
col
(
'myTable.id'
)),
'DESC'
],
[
sequelize
.
fn
(
'f2'
,
12
,
'lalala'
,
new
Date
(
Date
.
UTC
(
2011
,
2
,
27
,
10
,
1
,
55
))),
'ASC'
]
[
sequelize
.
fn
(
'f2'
,
12
,
'lalala'
,
new
Date
(
Date
.
UTC
(
2011
,
2
,
27
,
10
,
1
,
55
))),
'ASC'
]
]
]
}
}
...
@@ -410,6 +410,16 @@ if (dialect.match(/^postgres/)) {
...
@@ -410,6 +410,16 @@ if (dialect.match(/^postgres/)) {
arguments
:
[
'mySchema.myTable'
,
{
where
:
{
name
:
"foo';DROP TABLE mySchema.myTable;"
}}],
arguments
:
[
'mySchema.myTable'
,
{
where
:
{
name
:
"foo';DROP TABLE mySchema.myTable;"
}}],
expectation
:
"SELECT * FROM mySchema.myTable WHERE mySchema.myTable.name='foo'';DROP TABLE mySchema.myTable;';"
,
expectation
:
"SELECT * FROM mySchema.myTable WHERE mySchema.myTable.name='foo'';DROP TABLE mySchema.myTable;';"
,
context
:
{
options
:
{
quoteIdentifiers
:
false
}}
context
:
{
options
:
{
quoteIdentifiers
:
false
}}
},
{
title
:
'use != if ne !== null'
,
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
ne
:
0
}}}],
expectation
:
"SELECT * FROM myTable WHERE myTable.field != 0;"
,
context
:
QueryGenerator
},
{
title
:
'use IS NOT if ne === null'
,
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
ne
:
null
}}}],
expectation
:
"SELECT * FROM myTable WHERE myTable.field IS NOT NULL;"
,
context
:
QueryGenerator
}
}
],
],
...
...
test/sqlite/query-generator.test.js
View file @
65cc93e
...
@@ -165,8 +165,8 @@ if (dialect === 'sqlite') {
...
@@ -165,8 +165,8 @@ if (dialect === 'sqlite') {
},
{
},
{
title
:
'functions can take functions as arguments'
,
title
:
'functions can take functions as arguments'
,
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
return
{
return
{
order
:
[[
sequelize
.
fn
(
'f1'
,
sequelize
.
fn
(
'f2'
,
sequelize
.
col
(
'id'
))),
'DESC'
]]
order
:
[[
sequelize
.
fn
(
'f1'
,
sequelize
.
fn
(
'f2'
,
sequelize
.
col
(
'id'
))),
'DESC'
]]
}
}
}],
}],
expectation
:
"SELECT * FROM `myTable` ORDER BY f1(f2(`id`)) DESC;"
,
expectation
:
"SELECT * FROM `myTable` ORDER BY f1(f2(`id`)) DESC;"
,
...
@@ -177,7 +177,7 @@ if (dialect === 'sqlite') {
...
@@ -177,7 +177,7 @@ if (dialect === 'sqlite') {
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
return
{
return
{
order
:
[
order
:
[
[
sequelize
.
fn
(
'f1'
,
sequelize
.
col
(
'myTable.id'
)),
'DESC'
],
[
sequelize
.
fn
(
'f1'
,
sequelize
.
col
(
'myTable.id'
)),
'DESC'
],
[
sequelize
.
fn
(
'f2'
,
12
,
'lalala'
,
new
Date
(
Date
.
UTC
(
2011
,
2
,
27
,
10
,
1
,
55
))),
'ASC'
]
[
sequelize
.
fn
(
'f2'
,
12
,
'lalala'
,
new
Date
(
Date
.
UTC
(
2011
,
2
,
27
,
10
,
1
,
55
))),
'ASC'
]
]
]
}
}
...
@@ -260,6 +260,16 @@ if (dialect === 'sqlite') {
...
@@ -260,6 +260,16 @@ if (dialect === 'sqlite') {
arguments
:
[
'myTable'
,
{
where
:
{
field
:
new
Buffer
(
"Sequelize"
)}}],
arguments
:
[
'myTable'
,
{
where
:
{
field
:
new
Buffer
(
"Sequelize"
)}}],
expectation
:
"SELECT * FROM `myTable` WHERE `myTable`.`field`=X'53657175656c697a65';"
,
expectation
:
"SELECT * FROM `myTable` WHERE `myTable`.`field`=X'53657175656c697a65';"
,
context
:
QueryGenerator
context
:
QueryGenerator
},
{
title
:
'use != if ne !== null'
,
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
ne
:
0
}}}],
expectation
:
"SELECT * FROM `myTable` WHERE `myTable`.`field` != 0;"
,
context
:
QueryGenerator
},
{
title
:
'use IS NOT if ne === null'
,
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
ne
:
null
}}}],
expectation
:
"SELECT * FROM `myTable` WHERE `myTable`.`field` IS NOT NULL;"
,
context
:
QueryGenerator
}
}
],
],
...
...
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