不要怂,就是干,撸起袖子干!

Commit 05059632 by Mick Hansen

feat(where): automatic double precision and timezonetz casting for JSON comparison

1 parent dc090b5c
...@@ -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')*/));
......
...@@ -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: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!