mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 23:30:10 +00:00
refactor: Improve JSON filter handling in StatementGenerator.ts
This commit is contained in:
parent
164e6062c9
commit
b6adf3fb40
@ -429,7 +429,7 @@ export default class StatementGenerator<TBaseModel extends AnalyticsBaseModel> {
|
||||
) {
|
||||
whereStatement.append(
|
||||
SQL`AND JSONExtractString(${key}, ${{
|
||||
value: key,
|
||||
value: objKey,
|
||||
type: TableColumnType.Text,
|
||||
}}) = ${{
|
||||
value: flatValue[objKey] as string,
|
||||
@ -445,7 +445,7 @@ export default class StatementGenerator<TBaseModel extends AnalyticsBaseModel> {
|
||||
) {
|
||||
whereStatement.append(
|
||||
SQL`AND JSONExtractInt(${key}, ${{
|
||||
value: key,
|
||||
value: objKey,
|
||||
type: TableColumnType.Text,
|
||||
}}) = ${{
|
||||
value: flatValue[objKey] as number,
|
||||
@ -454,9 +454,23 @@ export default class StatementGenerator<TBaseModel extends AnalyticsBaseModel> {
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (
|
||||
flatValue[objKey] &&
|
||||
typeof flatValue[objKey] === 'boolean'
|
||||
) {
|
||||
whereStatement.append(
|
||||
SQL`AND JSONExtractBool(${key}, ${{
|
||||
value: objKey,
|
||||
type: TableColumnType.Text,
|
||||
}}) = ${{
|
||||
value: flatValue[objKey] as number,
|
||||
type: TableColumnType.Boolean,
|
||||
}}`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
whereStatement.append(
|
||||
SQL`AND ${key} = ${{ value, type: tableColumn.type }}`
|
||||
|
@ -55,6 +55,13 @@ const ServiceDelete: FunctionComponent<PageComponentProps> = (
|
||||
title: 'Name',
|
||||
type: FieldType.Text,
|
||||
},
|
||||
{
|
||||
field: {
|
||||
attributes: true,
|
||||
},
|
||||
type: FieldType.JSON,
|
||||
title: 'Attributes',
|
||||
},
|
||||
]}
|
||||
columns={[
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user