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 a6cdcdd4
authored
Oct 28, 2014
by
overlookmotel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alter tests for add table name to order/group
1 parent
ed9e98cf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
24 deletions
test/include/findAll.test.js
test/include/schema.test.js
test/mysql/query-generator.test.js
test/postgres/query-generator.test.js
test/sqlite/query-generator.test.js
test/include/findAll.test.js
View file @
a6cdcdd
...
@@ -389,7 +389,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
...
@@ -389,7 +389,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]}
]}
],
],
order
:
[
order
:
[
[
'
User.
id'
,
'ASC'
]
[
'id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
users
)
{
}).
done
(
function
(
err
,
users
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
@@ -780,8 +780,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
...
@@ -780,8 +780,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
{
model
:
Tag
}
{
model
:
Tag
}
],
],
order
:
[
order
:
[
[
'
Product.
id'
,
'ASC'
],
[
'id'
,
'ASC'
],
[
'Tags.
id'
,
'ASC'
]
[
Tag
,
'
id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
products
)
{
}).
done
(
function
(
err
,
products
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
@@ -1460,7 +1460,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
...
@@ -1460,7 +1460,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]}
]}
],
],
order
:
[
order
:
[
[
'
User.
id'
,
'ASC'
]
[
'id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
users
)
{
}).
done
(
function
(
err
,
users
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
@@ -1709,7 +1709,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
...
@@ -1709,7 +1709,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
],
],
limit
:
6
,
limit
:
6
,
order
:
[
order
:
[
[
'
Product.
id'
,
'ASC'
]
[
'id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
products
)
{
}).
done
(
function
(
err
,
products
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
@@ -1739,7 +1739,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
...
@@ -1739,7 +1739,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
],
],
limit
:
10
,
limit
:
10
,
order
:
[
order
:
[
[
'
Product.
id'
,
'ASC'
]
[
'id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
products
)
{
}).
done
(
function
(
err
,
products
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
...
test/include/schema.test.js
View file @
a6cdcdd
...
@@ -680,8 +680,8 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
...
@@ -680,8 +680,8 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
{
model
:
Tag
}
{
model
:
Tag
}
],
],
order
:
[
order
:
[
[
'
Product.
id'
,
'ASC'
],
[
'id'
,
'ASC'
],
[
'Tags.
id'
,
'ASC'
]
[
Tag
,
'
id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
products
)
{
}).
done
(
function
(
err
,
products
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
@@ -1316,7 +1316,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
...
@@ -1316,7 +1316,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
]}
]}
],
],
order
:
[
order
:
[
[
'
User.
id'
,
'ASC'
]
[
'id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
users
)
{
}).
done
(
function
(
err
,
users
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
@@ -1401,7 +1401,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
...
@@ -1401,7 +1401,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
],
],
limit
:
3
,
limit
:
3
,
order
:
[
order
:
[
[
self
.
models
.
Product
.
name
+
'.
id'
,
'ASC'
]
[
'
id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
products
)
{
}).
done
(
function
(
err
,
products
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
@@ -1430,7 +1430,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
...
@@ -1430,7 +1430,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
],
],
limit
:
6
,
limit
:
6
,
order
:
[
order
:
[
[
'
Product.
id'
,
'ASC'
]
[
'id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
products
)
{
}).
done
(
function
(
err
,
products
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
@@ -1460,7 +1460,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
...
@@ -1460,7 +1460,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
],
],
limit
:
10
,
limit
:
10
,
order
:
[
order
:
[
[
'
Product.
id'
,
'ASC'
]
[
'id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
products
)
{
}).
done
(
function
(
err
,
products
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
...
test/mysql/query-generator.test.js
View file @
a6cdcdd
...
@@ -163,9 +163,10 @@ if (Support.dialectIsMySQL()) {
...
@@ -163,9 +163,10 @@ if (Support.dialectIsMySQL()) {
expectation
:
"SELECT * FROM `myTable` ORDER BY `myTable`.`id`;"
,
expectation
:
"SELECT * FROM `myTable` ORDER BY `myTable`.`id`;"
,
context
:
QueryGenerator
context
:
QueryGenerator
},
{
},
{
arguments
:
[
'myTable'
,
{
order
:
[[
"id"
,
'DESC'
]]}],
arguments
:
[
'myTable'
,
{
order
:
[[
"id"
,
'DESC'
]]},
function
(
sequelize
)
{
return
sequelize
.
define
(
'myTable'
,
{});}],
expectation
:
"SELECT * FROM `myTable` ORDER BY `id` DESC;"
,
expectation
:
"SELECT * FROM `myTable` AS `myTable` ORDER BY `myTable`.`id` DESC;"
,
context
:
QueryGenerator
context
:
QueryGenerator
,
needsSequelize
:
true
},
{
},
{
title
:
'raw arguments are neither quoted nor escaped'
,
title
:
'raw arguments are neither quoted nor escaped'
,
arguments
:
[
'myTable'
,
{
order
:
[[{
raw
:
'f1(f2(id))'
},
'DESC'
]]}],
arguments
:
[
'myTable'
,
{
order
:
[[{
raw
:
'f1(f2(id))'
},
'DESC'
]]}],
...
@@ -588,7 +589,8 @@ if (Support.dialectIsMySQL()) {
...
@@ -588,7 +589,8 @@ if (Support.dialectIsMySQL()) {
// Options would normally be set by the query interface that instantiates the query-generator, but here we specify it explicitly
// Options would normally be set by the query interface that instantiates the query-generator, but here we specify it explicitly
var
context
=
test
.
context
||
{
options
:
{}};
var
context
=
test
.
context
||
{
options
:
{}};
if
(
test
.
needsSequelize
)
{
if
(
test
.
needsSequelize
)
{
test
.
arguments
[
1
]
=
test
.
arguments
[
1
](
this
.
sequelize
);
if
(
_
.
isFunction
(
test
.
arguments
[
1
]))
test
.
arguments
[
1
]
=
test
.
arguments
[
1
](
this
.
sequelize
);
if
(
_
.
isFunction
(
test
.
arguments
[
2
]))
test
.
arguments
[
2
]
=
test
.
arguments
[
2
](
this
.
sequelize
);
}
}
QueryGenerator
.
options
=
context
.
options
;
QueryGenerator
.
options
=
context
.
options
;
QueryGenerator
.
_dialect
=
this
.
sequelize
.
dialect
;
QueryGenerator
.
_dialect
=
this
.
sequelize
.
dialect
;
...
...
test/postgres/query-generator.test.js
View file @
a6cdcdd
...
@@ -249,9 +249,10 @@ if (dialect.match(/^postgres/)) {
...
@@ -249,9 +249,10 @@ if (dialect.match(/^postgres/)) {
expectation
:
'SELECT * FROM "myTable" ORDER BY "myTable"."id";'
,
expectation
:
'SELECT * FROM "myTable" ORDER BY "myTable"."id";'
,
context
:
QueryGenerator
context
:
QueryGenerator
},
{
},
{
arguments
:
[
'myTable'
,
{
order
:
[[
"id"
,
'DESC'
]]}],
arguments
:
[
'myTable'
,
{
order
:
[[
"id"
,
'DESC'
]]},
function
(
sequelize
)
{
return
sequelize
.
define
(
'myTable'
,
{});}],
expectation
:
'SELECT * FROM "myTable" ORDER BY "id" DESC;'
,
expectation
:
'SELECT * FROM "myTable" AS "myTable" ORDER BY "myTable"."id" DESC;'
,
context
:
QueryGenerator
context
:
QueryGenerator
,
needsSequelize
:
true
},
{
},
{
title
:
'raw arguments are neither quoted nor escaped'
,
title
:
'raw arguments are neither quoted nor escaped'
,
arguments
:
[
'myTable'
,
{
order
:
[[{
raw
:
'f1(f2(id))'
},
'DESC'
]]}],
arguments
:
[
'myTable'
,
{
order
:
[[{
raw
:
'f1(f2(id))'
},
'DESC'
]]}],
...
@@ -984,7 +985,8 @@ if (dialect.match(/^postgres/)) {
...
@@ -984,7 +985,8 @@ if (dialect.match(/^postgres/)) {
// Options would normally be set by the query interface that instantiates the query-generator, but here we specify it explicitly
// Options would normally be set by the query interface that instantiates the query-generator, but here we specify it explicitly
var
context
=
test
.
context
||
{
options
:
{}};
var
context
=
test
.
context
||
{
options
:
{}};
if
(
test
.
needsSequelize
)
{
if
(
test
.
needsSequelize
)
{
test
.
arguments
[
1
]
=
test
.
arguments
[
1
](
this
.
sequelize
);
if
(
_
.
isFunction
(
test
.
arguments
[
1
]))
test
.
arguments
[
1
]
=
test
.
arguments
[
1
](
this
.
sequelize
);
if
(
_
.
isFunction
(
test
.
arguments
[
2
]))
test
.
arguments
[
2
]
=
test
.
arguments
[
2
](
this
.
sequelize
);
}
}
QueryGenerator
.
options
=
context
.
options
;
QueryGenerator
.
options
=
context
.
options
;
QueryGenerator
.
_dialect
=
this
.
sequelize
.
dialect
;
QueryGenerator
.
_dialect
=
this
.
sequelize
.
dialect
;
...
...
test/sqlite/query-generator.test.js
View file @
a6cdcdd
...
@@ -154,9 +154,10 @@ if (dialect === 'sqlite') {
...
@@ -154,9 +154,10 @@ if (dialect === 'sqlite') {
expectation
:
"SELECT * FROM `myTable` ORDER BY `myTable`.`id`;"
,
expectation
:
"SELECT * FROM `myTable` ORDER BY `myTable`.`id`;"
,
context
:
QueryGenerator
context
:
QueryGenerator
},
{
},
{
arguments
:
[
'myTable'
,
{
order
:
[[
"id"
,
'DESC'
]]}],
arguments
:
[
'myTable'
,
{
order
:
[[
"id"
,
'DESC'
]]},
function
(
sequelize
)
{
return
sequelize
.
define
(
'myTable'
,
{});}],
expectation
:
"SELECT * FROM `myTable` ORDER BY `id` DESC;"
,
expectation
:
"SELECT * FROM `myTable` AS `myTable` ORDER BY `myTable`.`id` DESC;"
,
context
:
QueryGenerator
context
:
QueryGenerator
,
needsSequelize
:
true
},
{
},
{
title
:
'raw arguments are neither quoted nor escaped'
,
title
:
'raw arguments are neither quoted nor escaped'
,
arguments
:
[
'myTable'
,
{
order
:
[[{
raw
:
'f1(f2(id))'
},
'DESC'
]]}],
arguments
:
[
'myTable'
,
{
order
:
[[{
raw
:
'f1(f2(id))'
},
'DESC'
]]}],
...
@@ -536,7 +537,8 @@ if (dialect === 'sqlite') {
...
@@ -536,7 +537,8 @@ if (dialect === 'sqlite') {
// Options would normally be set by the query interface that instantiates the query-generator, but here we specify it explicitly
// Options would normally be set by the query interface that instantiates the query-generator, but here we specify it explicitly
var
context
=
test
.
context
||
{
options
:
{}};
var
context
=
test
.
context
||
{
options
:
{}};
if
(
test
.
needsSequelize
)
{
if
(
test
.
needsSequelize
)
{
test
.
arguments
[
1
]
=
test
.
arguments
[
1
](
this
.
sequelize
);
if
(
_
.
isFunction
(
test
.
arguments
[
1
]))
test
.
arguments
[
1
]
=
test
.
arguments
[
1
](
this
.
sequelize
);
if
(
_
.
isFunction
(
test
.
arguments
[
2
]))
test
.
arguments
[
2
]
=
test
.
arguments
[
2
](
this
.
sequelize
);
}
}
QueryGenerator
.
options
=
context
.
options
;
QueryGenerator
.
options
=
context
.
options
;
QueryGenerator
.
_dialect
=
this
.
sequelize
.
dialect
;
QueryGenerator
.
_dialect
=
this
.
sequelize
.
dialect
;
...
...
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