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 44ad6bab
authored
Oct 14, 2017
by
Sushant
Committed by
GitHub
Oct 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(where): show inspected value for incorrect where conditions (#8481)
1 parent
4ff64088
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
17 deletions
lib/sql-string.js
test/unit/dialects/abstract/query-generator.test.js
lib/sql-string.js
View file @
44ad6ba
'use strict'
;
'use strict'
;
const
dataTypes
=
require
(
'./data-types'
);
const
dataTypes
=
require
(
'./data-types'
);
const
util
=
require
(
'util'
);
const
_
=
require
(
'lodash'
);
const
_
=
require
(
'lodash'
);
function
escape
(
val
,
timeZone
,
dialect
,
format
)
{
function
escape
(
val
,
timeZone
,
dialect
,
format
)
{
...
@@ -47,7 +48,7 @@ function escape(val, timeZone, dialect, format) {
...
@@ -47,7 +48,7 @@ function escape(val, timeZone, dialect, format) {
}
}
if
(
!
val
.
replace
)
{
if
(
!
val
.
replace
)
{
throw
new
Error
(
'Invalid value '
+
val
);
throw
new
Error
(
'Invalid value '
+
util
.
inspect
(
val
)
);
}
}
if
(
dialect
===
'postgres'
||
dialect
===
'sqlite'
||
dialect
===
'mssql'
)
{
if
(
dialect
===
'postgres'
||
dialect
===
'sqlite'
||
dialect
===
'mssql'
)
{
...
...
test/unit/dialects/abstract/query-generator.test.js
View file @
44ad6ba
...
@@ -19,25 +19,25 @@ describe('QueryGenerator', () => {
...
@@ -19,25 +19,25 @@ describe('QueryGenerator', () => {
it
(
'should not parse any strings as aliases operators'
,
function
()
{
it
(
'should not parse any strings as aliases operators'
,
function
()
{
const
QG
=
getAbstractQueryGenerator
(
this
.
sequelize
);
const
QG
=
getAbstractQueryGenerator
(
this
.
sequelize
);
expect
(()
=>
QG
.
whereItemQuery
(
'$or'
,
[{
test
:
5
},
{
test
:
3
}]))
expect
(()
=>
QG
.
whereItemQuery
(
'$or'
,
[{
test
:
5
},
{
test
:
3
}]))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ test: 5 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'$and'
,
[{
test
:
5
},
{
test
:
3
}]))
expect
(()
=>
QG
.
whereItemQuery
(
'$and'
,
[{
test
:
5
},
{
test
:
3
}]))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ test: 5 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$gt
:
5
}))
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$gt
:
5
}))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$gt\': 5 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$between
:
[
2
,
5
]}))
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$between
:
[
2
,
5
]}))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$between\': [ 2, 5 ] }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$ne
:
3
}))
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$ne
:
3
}))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$ne\': 3 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$not
:
3
}))
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$not
:
3
}))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$not\': 3 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$in
:
[
4
]}))
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$in
:
[
4
]}))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$in\': [ 4 ] }
'
);
});
});
it
(
'should parse set aliases strings as operators'
,
function
()
{
it
(
'should parse set aliases strings as operators'
,
function
()
{
...
@@ -57,31 +57,31 @@ describe('QueryGenerator', () => {
...
@@ -57,31 +57,31 @@ describe('QueryGenerator', () => {
.
should
.
be
.
equal
(
'(test BETWEEN 2 AND 5 AND test != 3 AND test > 4)'
);
.
should
.
be
.
equal
(
'(test BETWEEN 2 AND 5 AND test != 3 AND test > 4)'
);
expect
(()
=>
QG
.
whereItemQuery
(
'OR'
,
[{
test
:
{
'^^'
:
5
}},
{
test
:
{
$not
:
3
}},
{
test
:
{[
Op
.
in
]:
[
4
]}}]))
expect
(()
=>
QG
.
whereItemQuery
(
'OR'
,
[{
test
:
{
'^^'
:
5
}},
{
test
:
{
$not
:
3
}},
{
test
:
{[
Op
.
in
]:
[
4
]}}]))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$not\': 3 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'OR'
,
[{
test
:
{
$gt
:
5
}},
{
test
:
{
'!'
:
3
}},
{
test
:
{[
Op
.
in
]:
[
4
]}}]))
expect
(()
=>
QG
.
whereItemQuery
(
'OR'
,
[{
test
:
{
$gt
:
5
}},
{
test
:
{
'!'
:
3
}},
{
test
:
{[
Op
.
in
]:
[
4
]}}]))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$gt\': 5 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'$or'
,
[{
test
:
5
},
{
test
:
3
}]))
expect
(()
=>
QG
.
whereItemQuery
(
'$or'
,
[{
test
:
5
},
{
test
:
3
}]))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ test: 5 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'$and'
,
[{
test
:
5
},
{
test
:
3
}]))
expect
(()
=>
QG
.
whereItemQuery
(
'$and'
,
[{
test
:
5
},
{
test
:
3
}]))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ test: 5 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$gt
:
5
}))
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$gt
:
5
}))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$gt\': 5 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$between
:
[
2
,
5
]}))
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$between
:
[
2
,
5
]}))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$between\': [ 2, 5 ] }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$ne
:
3
}))
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$ne
:
3
}))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$ne\': 3 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$not
:
3
}))
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$not
:
3
}))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$not\': 3 }
'
);
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$in
:
[
4
]}))
expect
(()
=>
QG
.
whereItemQuery
(
'test'
,
{
$in
:
[
4
]}))
.
to
.
throw
(
'Invalid value
[object Object]
'
);
.
to
.
throw
(
'Invalid value
{ \'$in\': [ 4 ] }
'
);
});
});
});
});
...
...
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