fix mapfilter / rawquery for relational

This commit is contained in:
Francis Cao 2023-08-16 13:47:43 -07:00
parent 7df142b02b
commit d6c8f3aa18
2 changed files with 5 additions and 5 deletions

View File

@ -66,7 +66,7 @@ function getDateFormat(date) {
function mapFilter(column, operator, name, type = 'String') {
switch (operator) {
case OPERATORS.equals:
return `${column} = {${name}:${type}`;
return `${column} = {${name}:${type}}`;
case OPERATORS.notEquals:
return `${column} != {${name}:${type}}`;
default:

View File

@ -92,12 +92,12 @@ function getTimestampIntervalQuery(field: string): string {
}
}
function mapFilter(column, operator, name, type = 'String') {
function mapFilter(column, operator, name, type = 'varchar') {
switch (operator) {
case OPERATORS.equals:
return `${column} = {${name}:${type}`;
return `${column} = {{${name}::${type}}}`;
case OPERATORS.notEquals:
return `${column} != {${name}:${type}}`;
return `${column} != {{${name}::${type}}}`;
default:
return '';
}
@ -161,7 +161,7 @@ async function rawQuery(sql: string, data: object): Promise<any> {
return Promise.reject(new Error('Unknown database.'));
}
const query = sql?.replaceAll(/\{\{\s*(\w+)(::\w+)?\s*}}/g, (...args) => {
const query = sql?.replaceAll(/\{\{\s*(\w+)(::\w+)?\s*\}\}/g, (...args) => {
const [, name, type] = args;
params.push(data[name]);