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 64c5528f
authored
Jan 24, 2014
by
Mathieu Amiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a code style issue in mysql query generator unit tests
Added Postgres and SQLite unit tests
1 parent
9f769203
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
1 deletions
test/mysql/query-generator.test.js
test/postgres/query-generator.test.js
test/sqlite/query-generator.test.js
test/mysql/query-generator.test.js
View file @
64c5528
...
@@ -235,7 +235,7 @@ if (Support.dialectIsMySQL()) {
...
@@ -235,7 +235,7 @@ if (Support.dialectIsMySQL()) {
arguments
:
[
'myTable'
,
{
group
:
"name"
,
order
:
"id DESC"
}],
arguments
:
[
'myTable'
,
{
group
:
"name"
,
order
:
"id DESC"
}],
expectation
:
"SELECT * FROM `myTable` GROUP BY name ORDER BY id DESC;"
,
expectation
:
"SELECT * FROM `myTable` GROUP BY name ORDER BY id DESC;"
,
context
:
QueryGenerator
context
:
QueryGenerator
},{
},
{
title
:
'HAVING clause works with string replacements'
,
title
:
'HAVING clause works with string replacements'
,
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
return
{
return
{
...
...
test/postgres/query-generator.test.js
View file @
64c5528
...
@@ -318,6 +318,30 @@ if (dialect.match(/^postgres/)) {
...
@@ -318,6 +318,30 @@ if (dialect.match(/^postgres/)) {
arguments
:
[
'myTable'
,
{
group
:
[
"name"
,
"title"
]}],
arguments
:
[
'myTable'
,
{
group
:
[
"name"
,
"title"
]}],
expectation
:
"SELECT * FROM \"myTable\" GROUP BY \"name\", \"title\";"
expectation
:
"SELECT * FROM \"myTable\" GROUP BY \"name\", \"title\";"
},
{
},
{
title
:
'HAVING clause works with string replacements'
,
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
return
{
attributes
:
[
'*'
,
[
sequelize
.
fn
(
'YEAR'
,
sequelize
.
col
(
'createdAt'
)),
'creationYear'
]],
group
:
[
'creationYear'
,
'title'
],
having
:
[
'creationYear > ?'
,
2002
]
}
}],
expectation
:
"SELECT *, YEAR(\"createdAt\") as \"creationYear\" FROM \"myTable\" GROUP BY \"creationYear\", \"title\" HAVING creationYear > 2002;"
,
context
:
QueryGenerator
,
needsSequelize
:
true
},
{
title
:
'HAVING clause works with where-like hash'
,
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
return
{
attributes
:
[
'*'
,
[
sequelize
.
fn
(
'YEAR'
,
sequelize
.
col
(
'createdAt'
)),
'creationYear'
]],
group
:
[
'creationYear'
,
'title'
],
having
:
{
creationYear
:
{
gt
:
2002
}
}
}
}],
expectation
:
"SELECT *, YEAR(\"createdAt\") as \"creationYear\" FROM \"myTable\" GROUP BY \"creationYear\", \"title\" HAVING \"creationYear\" > 2002;"
,
context
:
QueryGenerator
,
needsSequelize
:
true
},
{
arguments
:
[
'myTable'
,
{
limit
:
10
}],
arguments
:
[
'myTable'
,
{
limit
:
10
}],
expectation
:
"SELECT * FROM \"myTable\" LIMIT 10;"
expectation
:
"SELECT * FROM \"myTable\" LIMIT 10;"
},
{
},
{
...
...
test/sqlite/query-generator.test.js
View file @
64c5528
...
@@ -223,6 +223,30 @@ if (dialect === 'sqlite') {
...
@@ -223,6 +223,30 @@ if (dialect === 'sqlite') {
expectation
:
"SELECT * FROM `myTable` GROUP BY name ORDER BY id DESC;"
,
expectation
:
"SELECT * FROM `myTable` GROUP BY name ORDER BY id DESC;"
,
context
:
QueryGenerator
context
:
QueryGenerator
},
{
},
{
title
:
'HAVING clause works with string replacements'
,
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
return
{
attributes
:
[
'*'
,
[
sequelize
.
fn
(
'YEAR'
,
sequelize
.
col
(
'createdAt'
)),
'creationYear'
]],
group
:
[
'creationYear'
,
'title'
],
having
:
[
'creationYear > ?'
,
2002
]
}
}],
expectation
:
"SELECT *, YEAR(`createdAt`) as `creationYear` FROM `myTable` GROUP BY `creationYear`, `title` HAVING creationYear > 2002;"
,
context
:
QueryGenerator
,
needsSequelize
:
true
},
{
title
:
'HAVING clause works with where-like hash'
,
arguments
:
[
'myTable'
,
function
(
sequelize
)
{
return
{
attributes
:
[
'*'
,
[
sequelize
.
fn
(
'YEAR'
,
sequelize
.
col
(
'createdAt'
)),
'creationYear'
]],
group
:
[
'creationYear'
,
'title'
],
having
:
{
creationYear
:
{
gt
:
2002
}
}
}
}],
expectation
:
"SELECT *, YEAR(`createdAt`) as `creationYear` FROM `myTable` GROUP BY `creationYear`, `title` HAVING `creationYear` > 2002;"
,
context
:
QueryGenerator
,
needsSequelize
:
true
},
{
arguments
:
[
'myTable'
,
{
limit
:
10
}],
arguments
:
[
'myTable'
,
{
limit
:
10
}],
expectation
:
"SELECT * FROM `myTable` LIMIT 10;"
,
expectation
:
"SELECT * FROM `myTable` LIMIT 10;"
,
context
:
QueryGenerator
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