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 05059632
authored
Apr 23, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(where): automatic double precision and timezonetz casting for JSON comparison
1 parent
dc090b5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
lib/dialects/abstract/query-generator.js
test/unit/sql/where.test.js
lib/dialects/abstract/query-generator.js
View file @
0505963
...
@@ -1778,7 +1778,11 @@ module.exports = (function() {
...
@@ -1778,7 +1778,11 @@ module.exports = (function() {
$key
=
$baseKey
;
$key
=
$baseKey
;
if
(
typeof
$item
===
'number'
)
{
if
(
typeof
$item
===
'number'
)
{
$key
+=
'::integer'
;
$key
+=
'::double precision'
;
}
if
(
$item
instanceof
Date
)
{
$key
+=
'::timestamptz'
;
}
}
$items
.
push
(
self
.
whereItemQuery
(
new
Utils
.
literal
(
$key
),
$where
/*, _.pick(options, 'prefix')*/
));
$items
.
push
(
self
.
whereItemQuery
(
new
Utils
.
literal
(
$key
),
$where
/*, _.pick(options, 'prefix')*/
));
...
...
test/unit/sql/where.test.js
View file @
0505963
...
@@ -545,9 +545,22 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
...
@@ -545,9 +545,22 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
type
:
new
DataTypes
.
JSONB
()
type
:
new
DataTypes
.
JSONB
()
}
}
},
{
},
{
default
:
"([data]#>>'{nested, attribute}')::
integer
> 2"
default
:
"([data]#>>'{nested, attribute}')::
double precision
> 2"
});
});
testsql
(
'data'
,
{
nested
:
{
attribute
:
{
$gt
:
new
Date
()
}
}
},
{
field
:
{
type
:
new
DataTypes
.
JSONB
()
}
},
{
default
:
"([data]#>>'{nested, attribute}')::timestamptz > "
+
sql
.
escape
(
new
Date
())
});
testsql
(
'data'
,
{
testsql
(
'data'
,
{
$contains
:
{
$contains
:
{
...
...
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