diff --git a/.idea/prettier.xml b/.idea/prettier.xml
index 727b8b53..005b475f 100644
--- a/.idea/prettier.xml
+++ b/.idea/prettier.xml
@@ -1,7 +1,9 @@
+
+
\ No newline at end of file
diff --git a/.idea/watcherTasks.xml b/.idea/watcherTasks.xml
index b80cf2cd..c806ef47 100644
--- a/.idea/watcherTasks.xml
+++ b/.idea/watcherTasks.xml
@@ -47,7 +47,7 @@
-
+
diff --git a/src/expressions/notExpression.ts b/src/expressions/notExpression.ts
index 6023751b..b4cd9fd3 100644
--- a/src/expressions/notExpression.ts
+++ b/src/expressions/notExpression.ts
@@ -37,7 +37,7 @@ export class NotExpression extends ChainableExpression {
}
protected _getSQLChainableHelper(dialect: SQLDialect, operandSQL: string): string {
- return `NOT(${operandSQL})`;
+ return `(${operandSQL}) IS NOT TRUE`;
}
protected specialSimplify(): Expression {
diff --git a/test/functional/druidSqlFunctional.mocha.js b/test/functional/druidSqlFunctional.mocha.js
index 86133c87..ab427ac5 100644
--- a/test/functional/druidSqlFunctional.mocha.js
+++ b/test/functional/druidSqlFunctional.mocha.js
@@ -366,6 +366,45 @@ describe('DruidSQL Functional', function () {
});
});
+ it('works with negation', () => {
+ const ex = $('wiki')
+ .filter($('cityName').isnt('Tokyo'))
+ .split($('cityName'), 'City')
+ .apply('Count', $('wiki').sum('$count'))
+ .sort('$Count', 'descending')
+ .limit(3);
+
+ return basicExecutor(ex).then(result => {
+ expect(result.toJS()).to.deep.equal({
+ attributes: [
+ {
+ name: 'City',
+ type: 'STRING',
+ },
+ {
+ name: 'Count',
+ type: 'NUMBER',
+ },
+ ],
+ data: [
+ {
+ City: null,
+ Count: 371151,
+ },
+ {
+ City: 'Central District',
+ Count: 425,
+ },
+ {
+ City: 'Moscow',
+ Count: 330,
+ },
+ ],
+ keys: ['City'],
+ });
+ });
+ });
+
it('can do compare column', () => {
const prevRange = TimeRange.fromJS({
start: new Date('2015-09-12T00:00:00Z'),
diff --git a/test/functional/mySqlFunctional.mocha.js b/test/functional/mySqlFunctional.mocha.js
index d136e5cb..13c3ed4b 100644
--- a/test/functional/mySqlFunctional.mocha.js
+++ b/test/functional/mySqlFunctional.mocha.js
@@ -385,6 +385,45 @@ describe('MySQL Functional', function () {
});
});
+ it('works with negation', () => {
+ const ex = $('wiki')
+ .filter($('cityName').isnt('Tokyo'))
+ .split($('cityName'), 'City')
+ .apply('Count', $('wiki').sum('$count'))
+ .sort('$Count', 'descending')
+ .limit(3);
+
+ return basicExecutor(ex).then(result => {
+ expect(result.toJS()).to.deep.equal({
+ attributes: [
+ {
+ name: 'City',
+ type: 'STRING',
+ },
+ {
+ name: 'Count',
+ type: 'NUMBER',
+ },
+ ],
+ data: [
+ {
+ City: null,
+ Count: 371151,
+ },
+ {
+ City: 'Central District',
+ Count: 425,
+ },
+ {
+ City: 'Moscow',
+ Count: 330,
+ },
+ ],
+ keys: ['City'],
+ });
+ });
+ });
+
it('works with boolean GROUP BYs', () => {
const ex = $('wiki')
.split($('channel').is('en'), 'ChannelIsEn')
diff --git a/test/info.js b/test/info.js
index 12862a5c..b73ec566 100644
--- a/test/info.js
+++ b/test/info.js
@@ -22,7 +22,7 @@ exports.druidContext = {
populateCache: false,
};
-exports.mySqlVersion = '5.7.29';
+exports.mySqlVersion = '5.7.41';
exports.mySqlHost = `localhost:3306`;
exports.mySqlDatabase = 'datazoo';
exports.mySqlUser = 'datazoo';
diff --git a/test/simulate/simulateDruidSql.mocha.js b/test/simulate/simulateDruidSql.mocha.js
index db292bff..0700045c 100644
--- a/test/simulate/simulateDruidSql.mocha.js
+++ b/test/simulate/simulateDruidSql.mocha.js
@@ -223,7 +223,7 @@ describe('simulate DruidSql', () => {
sqlTimeZone: 'Etc/UTC',
},
query:
- 'SELECT\n"tags" AS "Tag"\nFROM "dia.monds" AS t\nWHERE (NOT((("pugs" IS NULL) OR "pugs" IN (\'pugA\',\'pugB\',\'null\'))) AND (("tags" IS NULL) OR "tags" IN (\'tagA\',\'tagB\',\'null\')))\nGROUP BY 1',
+ 'SELECT\n"tags" AS "Tag"\nFROM "dia.monds" AS t\nWHERE (((("pugs" IS NULL) OR "pugs" IN (\'pugA\',\'pugB\',\'null\'))) IS NOT TRUE AND (("tags" IS NULL) OR "tags" IN (\'tagA\',\'tagB\',\'null\')))\nGROUP BY 1',
},
],
]);
@@ -256,7 +256,7 @@ describe('simulate DruidSql', () => {
sqlTimeZone: 'Etc/UTC',
},
query:
- 'SELECT\n"tags" AS "Tag"\nFROM "dia.monds" AS t\nWHERE (NOT((("pugs" IS NULL) OR "pugs" IN (\'pugA\',\'pugB\',\'\'))) AND (("tags" IS NULL) OR "tags" IN (\'tagA\',\'tagB\',\'null\',\'\')))\nGROUP BY 1',
+ 'SELECT\n"tags" AS "Tag"\nFROM "dia.monds" AS t\nWHERE (((("pugs" IS NULL) OR "pugs" IN (\'pugA\',\'pugB\',\'\'))) IS NOT TRUE AND (("tags" IS NULL) OR "tags" IN (\'tagA\',\'tagB\',\'null\',\'\')))\nGROUP BY 1',
},
],
]);