Skip to content
Snippets Groups Projects
Commit cc107251 authored by Leonardo's avatar Leonardo
Browse files

fix(cypher): equals to an empty string use like op

parent a05aa099
No related branches found
Tags v1.18.0
No related merge requests found
Pipeline #144775 failed
import type { AnyStatement } from 'ts-common/src/model/query/logic/general'; import type { AnyStatement } from 'ts-common/src/model/query/logic/general';
import type { QueryCacheData } from './model'; import type { QueryCacheData } from './model';
import { log } from 'ts-common/src/logger/logger';
export function createWhereLogic(op: string, left: string, whereLogic: string, cacheData: QueryCacheData): [string, string] { export function createWhereLogic(op: string, left: string, whereLogic: string, cacheData: QueryCacheData): [string, string] {
const newWhereLogic = `${left.replace('.', '_')}_${op}`; const newWhereLogic = `${left.replace('.', '_')}_${op}`;
...@@ -32,6 +33,7 @@ export function extractLogicCypher(logicQuery: AnyStatement, cacheData: QueryCac ...@@ -32,6 +33,7 @@ export function extractLogicCypher(logicQuery: AnyStatement, cacheData: QueryCac
case 'object': case 'object':
if (Array.isArray(logicQuery)) { if (Array.isArray(logicQuery)) {
let op = logicQuery[0].replace('_', '').toLowerCase(); let op = logicQuery[0].replace('_', '').toLowerCase();
const right = logicQuery?.[2];
const [left, whereLogic] = extractLogicCypher(logicQuery[1], cacheData); const [left, whereLogic] = extractLogicCypher(logicQuery[1], cacheData);
let whereLogicMutable = whereLogic; let whereLogicMutable = whereLogic;
...@@ -40,7 +42,8 @@ export function extractLogicCypher(logicQuery: AnyStatement, cacheData: QueryCac ...@@ -40,7 +42,8 @@ export function extractLogicCypher(logicQuery: AnyStatement, cacheData: QueryCac
op = '<>'; op = '<>';
break; break;
case '==': case '==':
op = '='; if (right === '".*"') op = '=~'; // in case "equals to <empty string>", this is what happens
else op = '=';
break; break;
case 'like': case 'like':
op = '=~'; op = '=~';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment