@quillsql/react 2.13.35 → 2.13.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Chart.d.ts +0 -1
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +17 -14
- package/dist/cjs/ChartBuilder.d.ts +1 -0
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +178 -96
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +6 -8
- package/dist/cjs/Dashboard.d.ts +2 -1
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +18 -8
- package/dist/cjs/ReportBuilder.d.ts +2 -0
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +398 -271
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +33 -11
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +17 -1
- package/dist/cjs/components/Chart/InternalChart.d.ts +0 -1
- package/dist/cjs/components/Chart/InternalChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/InternalChart.js +6 -7
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +75 -30
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +98 -106
- package/dist/cjs/components/QuillMultiSelectSectionList.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectSectionList.js +21 -16
- package/dist/cjs/components/QuillMultiSelectWithCombo.js +18 -8
- package/dist/cjs/components/QuillSelectWithCombo.js +17 -7
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +2 -2
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +16 -4
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +9 -18
- package/dist/cjs/components/UiComponents.d.ts +2 -1
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +44 -28
- package/dist/cjs/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useAskQuill.js +28 -4
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +9 -1
- package/dist/cjs/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/cjs/hooks/useVirtualTables.js +11 -35
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.js +14 -2
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +12 -11
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +63 -18
- package/dist/cjs/models/Client.d.ts +4 -5
- package/dist/cjs/models/Client.d.ts.map +1 -1
- package/dist/cjs/models/Pivot.d.ts +10 -0
- package/dist/cjs/models/Pivot.d.ts.map +1 -1
- package/dist/cjs/models/Report.d.ts +13 -1
- package/dist/cjs/models/Report.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.d.ts +1 -1
- package/dist/cjs/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.js +799 -64
- package/dist/cjs/utils/astProcessing.d.ts +4 -1
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.js +2 -2
- package/dist/cjs/utils/client.d.ts.map +1 -1
- package/dist/cjs/utils/client.js +6 -3
- package/dist/cjs/utils/columnProcessing.d.ts +1 -0
- package/dist/cjs/utils/columnProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/columnProcessing.js +1 -0
- package/dist/cjs/utils/dashboard.d.ts +2 -1
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +38 -10
- package/dist/cjs/utils/filterProcessing.d.ts +1 -1
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/merge.d.ts +16 -0
- package/dist/cjs/utils/merge.d.ts.map +1 -1
- package/dist/cjs/utils/merge.js +210 -0
- package/dist/cjs/utils/paginationProcessing.d.ts +1 -1
- package/dist/cjs/utils/paginationProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/paginationProcessing.js +3 -2
- package/dist/cjs/utils/pivotConstructor.d.ts +19 -9
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +90 -34
- package/dist/cjs/utils/queryConstructor.d.ts +8 -1
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +276 -310
- package/dist/cjs/utils/report.d.ts +25 -12
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +13 -7
- package/dist/cjs/utils/schema.d.ts +1 -1
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +3 -32
- package/dist/cjs/utils/tableProcessing.d.ts +43 -13
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +140 -75
- package/dist/cjs/utils/textProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/textProcessing.js +10 -1
- package/dist/cjs/utils/valueFormatter.d.ts +2 -1
- package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
- package/dist/cjs/utils/valueFormatter.js +18 -14
- package/dist/esm/Chart.d.ts +0 -1
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +0 -6
- package/dist/esm/ChartBuilder.d.ts +1 -0
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +179 -97
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +7 -9
- package/dist/esm/Dashboard.d.ts +2 -1
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +1 -1
- package/dist/esm/ReportBuilder.d.ts +2 -0
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +399 -272
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +33 -11
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +17 -1
- package/dist/esm/components/Chart/InternalChart.d.ts +0 -1
- package/dist/esm/components/Chart/InternalChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/InternalChart.js +6 -6
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +75 -30
- package/dist/esm/components/Dashboard/MetricComponent.d.ts +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +98 -106
- package/dist/esm/components/QuillMultiSelectSectionList.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectSectionList.js +5 -12
- package/dist/esm/components/QuillMultiSelectWithCombo.js +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +2 -2
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +16 -4
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +9 -18
- package/dist/esm/components/UiComponents.d.ts +2 -1
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +27 -21
- package/dist/esm/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useAskQuill.js +28 -4
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +10 -2
- package/dist/esm/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/esm/hooks/useVirtualTables.js +12 -36
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.js +14 -2
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +12 -11
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +63 -18
- package/dist/esm/models/Client.d.ts +4 -5
- package/dist/esm/models/Client.d.ts.map +1 -1
- package/dist/esm/models/Pivot.d.ts +10 -0
- package/dist/esm/models/Pivot.d.ts.map +1 -1
- package/dist/esm/models/Report.d.ts +13 -1
- package/dist/esm/models/Report.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.d.ts +1 -1
- package/dist/esm/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.js +799 -64
- package/dist/esm/utils/astProcessing.d.ts +4 -1
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.js +2 -2
- package/dist/esm/utils/client.d.ts.map +1 -1
- package/dist/esm/utils/client.js +6 -3
- package/dist/esm/utils/columnProcessing.d.ts +1 -0
- package/dist/esm/utils/columnProcessing.d.ts.map +1 -1
- package/dist/esm/utils/columnProcessing.js +1 -1
- package/dist/esm/utils/dashboard.d.ts +2 -1
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +39 -11
- package/dist/esm/utils/filterProcessing.d.ts +1 -1
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/merge.d.ts +16 -0
- package/dist/esm/utils/merge.d.ts.map +1 -1
- package/dist/esm/utils/merge.js +207 -0
- package/dist/esm/utils/paginationProcessing.d.ts +1 -1
- package/dist/esm/utils/paginationProcessing.d.ts.map +1 -1
- package/dist/esm/utils/paginationProcessing.js +3 -2
- package/dist/esm/utils/pivotConstructor.d.ts +19 -9
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +91 -35
- package/dist/esm/utils/queryConstructor.d.ts +8 -1
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +274 -314
- package/dist/esm/utils/report.d.ts +25 -12
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +13 -7
- package/dist/esm/utils/schema.d.ts +1 -1
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +1 -30
- package/dist/esm/utils/tableProcessing.d.ts +43 -13
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +140 -75
- package/dist/esm/utils/textProcessing.d.ts.map +1 -1
- package/dist/esm/utils/textProcessing.js +10 -1
- package/dist/esm/utils/valueFormatter.d.ts +2 -1
- package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
- package/dist/esm/utils/valueFormatter.js +18 -14
- package/package.json +1 -1
|
@@ -612,7 +612,8 @@ const queryPatterns = [
|
|
|
612
612
|
},
|
|
613
613
|
unit: function (astWhere) {
|
|
614
614
|
return (astWhere.right?.args?.value[0]?.column?.expr?.value?.toLowerCase() ??
|
|
615
|
-
astWhere.right?.args?.value[0]?.column
|
|
615
|
+
astWhere.right?.args?.value[0]?.column?.toLowerCase() ??
|
|
616
|
+
astWhere.right?.args?.value[0]?.value?.toLowerCase() ??
|
|
616
617
|
null);
|
|
617
618
|
},
|
|
618
619
|
ast: {
|
|
@@ -724,7 +725,7 @@ const queryPatterns = [
|
|
|
724
725
|
if (unit === '') {
|
|
725
726
|
return stripTimeS(astWhere.left?.right?.right?.expr?.value
|
|
726
727
|
?.split(' ')[1]
|
|
727
|
-
|
|
728
|
+
?.toLowerCase());
|
|
728
729
|
}
|
|
729
730
|
else {
|
|
730
731
|
return unit;
|
|
@@ -3032,6 +3033,114 @@ const queryPatterns = [
|
|
|
3032
3033
|
},
|
|
3033
3034
|
},
|
|
3034
3035
|
],
|
|
3036
|
+
mssql: [
|
|
3037
|
+
{
|
|
3038
|
+
query: `
|
|
3039
|
+
SELECT * FROM transactions
|
|
3040
|
+
WHERE transaction_date >= DATEADD(DAY, -90, GETDATE())
|
|
3041
|
+
`,
|
|
3042
|
+
value: function (astWhere) {
|
|
3043
|
+
return astWhere.right?.args?.value[1]?.value
|
|
3044
|
+
? -astWhere.right?.args?.value[1]?.value
|
|
3045
|
+
: null;
|
|
3046
|
+
},
|
|
3047
|
+
unit: function (astWhere) {
|
|
3048
|
+
return (astWhere.right?.args?.value[0]?.column?.toLowerCase() ?? null);
|
|
3049
|
+
},
|
|
3050
|
+
ast: {
|
|
3051
|
+
with: null,
|
|
3052
|
+
type: 'select',
|
|
3053
|
+
options: null,
|
|
3054
|
+
distinct: null,
|
|
3055
|
+
columns: [
|
|
3056
|
+
{
|
|
3057
|
+
expr: {
|
|
3058
|
+
type: 'column_ref',
|
|
3059
|
+
table: null,
|
|
3060
|
+
column: '*',
|
|
3061
|
+
},
|
|
3062
|
+
as: null,
|
|
3063
|
+
},
|
|
3064
|
+
],
|
|
3065
|
+
into: {
|
|
3066
|
+
position: null,
|
|
3067
|
+
},
|
|
3068
|
+
from: [
|
|
3069
|
+
{
|
|
3070
|
+
db: null,
|
|
3071
|
+
table: 'transactions',
|
|
3072
|
+
as: null,
|
|
3073
|
+
table_hint: null,
|
|
3074
|
+
temporal_table: null,
|
|
3075
|
+
operator: null,
|
|
3076
|
+
},
|
|
3077
|
+
],
|
|
3078
|
+
for: null,
|
|
3079
|
+
where: {
|
|
3080
|
+
type: 'binary_expr',
|
|
3081
|
+
operator: '>=',
|
|
3082
|
+
left: {
|
|
3083
|
+
type: 'column_ref',
|
|
3084
|
+
table: null,
|
|
3085
|
+
db: null,
|
|
3086
|
+
schema: null,
|
|
3087
|
+
column: 'transaction_date',
|
|
3088
|
+
collate: null,
|
|
3089
|
+
},
|
|
3090
|
+
right: {
|
|
3091
|
+
type: 'function',
|
|
3092
|
+
name: {
|
|
3093
|
+
name: [
|
|
3094
|
+
{
|
|
3095
|
+
type: 'default',
|
|
3096
|
+
value: 'DATEADD',
|
|
3097
|
+
},
|
|
3098
|
+
],
|
|
3099
|
+
},
|
|
3100
|
+
args: {
|
|
3101
|
+
type: 'expr_list',
|
|
3102
|
+
value: [
|
|
3103
|
+
{
|
|
3104
|
+
type: 'column_ref',
|
|
3105
|
+
table: null,
|
|
3106
|
+
db: null,
|
|
3107
|
+
schema: null,
|
|
3108
|
+
column: 'DAY',
|
|
3109
|
+
collate: null,
|
|
3110
|
+
},
|
|
3111
|
+
{
|
|
3112
|
+
type: 'number',
|
|
3113
|
+
value: -90,
|
|
3114
|
+
},
|
|
3115
|
+
{
|
|
3116
|
+
type: 'function',
|
|
3117
|
+
name: {
|
|
3118
|
+
name: [
|
|
3119
|
+
{
|
|
3120
|
+
type: 'default',
|
|
3121
|
+
value: 'GETDATE',
|
|
3122
|
+
},
|
|
3123
|
+
],
|
|
3124
|
+
},
|
|
3125
|
+
args: {
|
|
3126
|
+
type: 'expr_list',
|
|
3127
|
+
value: [],
|
|
3128
|
+
},
|
|
3129
|
+
over: null,
|
|
3130
|
+
},
|
|
3131
|
+
],
|
|
3132
|
+
},
|
|
3133
|
+
over: null,
|
|
3134
|
+
},
|
|
3135
|
+
},
|
|
3136
|
+
groupby: null,
|
|
3137
|
+
having: null,
|
|
3138
|
+
top: null,
|
|
3139
|
+
orderby: null,
|
|
3140
|
+
limit: null,
|
|
3141
|
+
},
|
|
3142
|
+
},
|
|
3143
|
+
],
|
|
3035
3144
|
},
|
|
3036
3145
|
},
|
|
3037
3146
|
{
|
|
@@ -5958,6 +6067,133 @@ const queryPatterns = [
|
|
|
5958
6067
|
},
|
|
5959
6068
|
},
|
|
5960
6069
|
],
|
|
6070
|
+
mssql: [
|
|
6071
|
+
{
|
|
6072
|
+
query: `
|
|
6073
|
+
SELECT * FROM transactions
|
|
6074
|
+
WHERE DATETRUNC(MONTH, transaction_date) = DATETRUNC(MONTH, GETDATE());
|
|
6075
|
+
`,
|
|
6076
|
+
value: function () {
|
|
6077
|
+
return 0;
|
|
6078
|
+
},
|
|
6079
|
+
unit: function (astWhere) {
|
|
6080
|
+
return astWhere.left?.args?.value[0]?.column ?? null;
|
|
6081
|
+
},
|
|
6082
|
+
ast: {
|
|
6083
|
+
with: null,
|
|
6084
|
+
type: 'select',
|
|
6085
|
+
options: null,
|
|
6086
|
+
distinct: null,
|
|
6087
|
+
columns: [
|
|
6088
|
+
{
|
|
6089
|
+
expr: {
|
|
6090
|
+
type: 'column_ref',
|
|
6091
|
+
table: null,
|
|
6092
|
+
column: '*',
|
|
6093
|
+
},
|
|
6094
|
+
as: null,
|
|
6095
|
+
},
|
|
6096
|
+
],
|
|
6097
|
+
into: {
|
|
6098
|
+
position: null,
|
|
6099
|
+
},
|
|
6100
|
+
from: [
|
|
6101
|
+
{
|
|
6102
|
+
db: null,
|
|
6103
|
+
table: 'transactions',
|
|
6104
|
+
as: null,
|
|
6105
|
+
table_hint: null,
|
|
6106
|
+
temporal_table: null,
|
|
6107
|
+
operator: null,
|
|
6108
|
+
},
|
|
6109
|
+
],
|
|
6110
|
+
for: null,
|
|
6111
|
+
where: {
|
|
6112
|
+
type: 'binary_expr',
|
|
6113
|
+
operator: '=',
|
|
6114
|
+
left: {
|
|
6115
|
+
type: 'function',
|
|
6116
|
+
name: {
|
|
6117
|
+
name: [
|
|
6118
|
+
{
|
|
6119
|
+
type: 'default',
|
|
6120
|
+
value: 'DATETRUNC',
|
|
6121
|
+
},
|
|
6122
|
+
],
|
|
6123
|
+
},
|
|
6124
|
+
args: {
|
|
6125
|
+
type: 'expr_list',
|
|
6126
|
+
value: [
|
|
6127
|
+
{
|
|
6128
|
+
type: 'column_ref',
|
|
6129
|
+
table: null,
|
|
6130
|
+
db: null,
|
|
6131
|
+
schema: null,
|
|
6132
|
+
column: 'MONTH',
|
|
6133
|
+
collate: null,
|
|
6134
|
+
},
|
|
6135
|
+
{
|
|
6136
|
+
type: 'column_ref',
|
|
6137
|
+
table: null,
|
|
6138
|
+
db: null,
|
|
6139
|
+
schema: null,
|
|
6140
|
+
column: 'transaction_date',
|
|
6141
|
+
collate: null,
|
|
6142
|
+
},
|
|
6143
|
+
],
|
|
6144
|
+
},
|
|
6145
|
+
over: null,
|
|
6146
|
+
},
|
|
6147
|
+
right: {
|
|
6148
|
+
type: 'function',
|
|
6149
|
+
name: {
|
|
6150
|
+
name: [
|
|
6151
|
+
{
|
|
6152
|
+
type: 'default',
|
|
6153
|
+
value: 'DATETRUNC',
|
|
6154
|
+
},
|
|
6155
|
+
],
|
|
6156
|
+
},
|
|
6157
|
+
args: {
|
|
6158
|
+
type: 'expr_list',
|
|
6159
|
+
value: [
|
|
6160
|
+
{
|
|
6161
|
+
type: 'column_ref',
|
|
6162
|
+
table: null,
|
|
6163
|
+
db: null,
|
|
6164
|
+
schema: null,
|
|
6165
|
+
column: 'MONTH',
|
|
6166
|
+
collate: null,
|
|
6167
|
+
},
|
|
6168
|
+
{
|
|
6169
|
+
type: 'function',
|
|
6170
|
+
name: {
|
|
6171
|
+
name: [
|
|
6172
|
+
{
|
|
6173
|
+
type: 'default',
|
|
6174
|
+
value: 'GETDATE',
|
|
6175
|
+
},
|
|
6176
|
+
],
|
|
6177
|
+
},
|
|
6178
|
+
args: {
|
|
6179
|
+
type: 'expr_list',
|
|
6180
|
+
value: [],
|
|
6181
|
+
},
|
|
6182
|
+
over: null,
|
|
6183
|
+
},
|
|
6184
|
+
],
|
|
6185
|
+
},
|
|
6186
|
+
over: null,
|
|
6187
|
+
},
|
|
6188
|
+
},
|
|
6189
|
+
groupby: null,
|
|
6190
|
+
having: null,
|
|
6191
|
+
top: null,
|
|
6192
|
+
orderby: null,
|
|
6193
|
+
limit: null,
|
|
6194
|
+
},
|
|
6195
|
+
},
|
|
6196
|
+
],
|
|
5961
6197
|
},
|
|
5962
6198
|
},
|
|
5963
6199
|
{
|
|
@@ -7622,57 +7858,263 @@ const queryPatterns = [
|
|
|
7622
7858
|
},
|
|
7623
7859
|
},
|
|
7624
7860
|
],
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
function
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7861
|
+
mssql: [
|
|
7862
|
+
{
|
|
7863
|
+
query: `
|
|
7864
|
+
SELECT * FROM transactions
|
|
7865
|
+
WHERE transaction_date >= DATEADD(YEAR, -2, GETDATE())
|
|
7866
|
+
AND transaction_date < DATEADD(YEAR, -1, GETDATE());
|
|
7867
|
+
`,
|
|
7868
|
+
value: function (astWhere) {
|
|
7869
|
+
if (astWhere.right.operator === 'AND') {
|
|
7870
|
+
// Avoid AND chains
|
|
7871
|
+
return -1;
|
|
7872
|
+
}
|
|
7873
|
+
const operatorLeft = astWhere.left.operator;
|
|
7874
|
+
const operatorRight = astWhere.right.operator;
|
|
7875
|
+
const valueLeft = astWhere.left.right?.args?.value[1]?.value
|
|
7876
|
+
? -astWhere.left.right?.args?.value[1]?.value
|
|
7877
|
+
: null;
|
|
7878
|
+
const valueRight = astWhere.right.right?.args?.value[1]?.value
|
|
7879
|
+
? -astWhere.right.right?.args?.value[1]?.value
|
|
7880
|
+
: null;
|
|
7881
|
+
if (!valueLeft || !valueRight) {
|
|
7882
|
+
return null;
|
|
7883
|
+
}
|
|
7884
|
+
if (operatorLeft === '>=' &&
|
|
7885
|
+
operatorRight === '<' &&
|
|
7886
|
+
valueLeft == valueRight * 2) {
|
|
7887
|
+
return valueRight;
|
|
7888
|
+
}
|
|
7889
|
+
else if (operatorLeft === '<' &&
|
|
7890
|
+
operatorRight === '>=' &&
|
|
7891
|
+
valueLeft * 2 == valueRight) {
|
|
7892
|
+
return valueLeft;
|
|
7893
|
+
}
|
|
7894
|
+
else {
|
|
7895
|
+
const unitLeft = astWhere.left?.right?.args?.value[0]?.column?.toLowerCase() ??
|
|
7896
|
+
null;
|
|
7897
|
+
const unitRight = astWhere.right?.right?.args?.value[0]?.column?.toLowerCase() ??
|
|
7898
|
+
null;
|
|
7899
|
+
return parseStartEndDate(operatorLeft, operatorRight, valueLeft, valueRight, stripTimeS(unitLeft.toLowerCase()), stripTimeS(unitRight.toLowerCase()));
|
|
7900
|
+
}
|
|
7901
|
+
},
|
|
7902
|
+
unit: function (astWhere) {
|
|
7903
|
+
const unitLeft = astWhere.left?.right?.args?.value[0]?.column?.toLowerCase() ??
|
|
7904
|
+
null;
|
|
7905
|
+
const unitRight = astWhere.right?.right?.args?.value[0]?.column?.toLowerCase() ??
|
|
7906
|
+
null;
|
|
7907
|
+
return stripTimeS(unitLeft.toLowerCase()) ===
|
|
7908
|
+
stripTimeS(unitRight.toLowerCase())
|
|
7909
|
+
? stripTimeS(unitLeft.toLowerCase())
|
|
7910
|
+
: null;
|
|
7911
|
+
},
|
|
7912
|
+
ast: {
|
|
7913
|
+
with: null,
|
|
7914
|
+
type: 'select',
|
|
7915
|
+
options: null,
|
|
7916
|
+
distinct: null,
|
|
7917
|
+
columns: [
|
|
7918
|
+
{
|
|
7919
|
+
expr: {
|
|
7920
|
+
type: 'column_ref',
|
|
7921
|
+
table: null,
|
|
7922
|
+
column: '*',
|
|
7923
|
+
},
|
|
7924
|
+
as: null,
|
|
7925
|
+
},
|
|
7926
|
+
],
|
|
7927
|
+
into: {
|
|
7928
|
+
position: null,
|
|
7929
|
+
},
|
|
7930
|
+
from: [
|
|
7931
|
+
{
|
|
7932
|
+
db: null,
|
|
7933
|
+
table: 'transactions',
|
|
7934
|
+
as: null,
|
|
7935
|
+
table_hint: null,
|
|
7936
|
+
temporal_table: null,
|
|
7937
|
+
operator: null,
|
|
7938
|
+
},
|
|
7939
|
+
],
|
|
7940
|
+
for: null,
|
|
7941
|
+
where: {
|
|
7942
|
+
type: 'binary_expr',
|
|
7943
|
+
operator: 'AND',
|
|
7944
|
+
left: {
|
|
7945
|
+
type: 'binary_expr',
|
|
7946
|
+
operator: '>=',
|
|
7947
|
+
left: {
|
|
7948
|
+
type: 'column_ref',
|
|
7949
|
+
table: null,
|
|
7950
|
+
db: null,
|
|
7951
|
+
schema: null,
|
|
7952
|
+
column: 'transaction_date',
|
|
7953
|
+
collate: null,
|
|
7954
|
+
},
|
|
7955
|
+
right: {
|
|
7956
|
+
type: 'function',
|
|
7957
|
+
name: {
|
|
7958
|
+
name: [
|
|
7959
|
+
{
|
|
7960
|
+
type: 'default',
|
|
7961
|
+
value: 'DATEADD',
|
|
7962
|
+
},
|
|
7963
|
+
],
|
|
7964
|
+
},
|
|
7965
|
+
args: {
|
|
7966
|
+
type: 'expr_list',
|
|
7967
|
+
value: [
|
|
7968
|
+
{
|
|
7969
|
+
type: 'column_ref',
|
|
7970
|
+
table: null,
|
|
7971
|
+
db: null,
|
|
7972
|
+
schema: null,
|
|
7973
|
+
column: 'YEAR',
|
|
7974
|
+
collate: null,
|
|
7975
|
+
},
|
|
7976
|
+
{
|
|
7977
|
+
type: 'number',
|
|
7978
|
+
value: -2,
|
|
7979
|
+
},
|
|
7980
|
+
{
|
|
7981
|
+
type: 'function',
|
|
7982
|
+
name: {
|
|
7983
|
+
name: [
|
|
7984
|
+
{
|
|
7985
|
+
type: 'default',
|
|
7986
|
+
value: 'GETDATE',
|
|
7987
|
+
},
|
|
7988
|
+
],
|
|
7989
|
+
},
|
|
7990
|
+
args: {
|
|
7991
|
+
type: 'expr_list',
|
|
7992
|
+
value: [],
|
|
7993
|
+
},
|
|
7994
|
+
over: null,
|
|
7995
|
+
},
|
|
7996
|
+
],
|
|
7997
|
+
},
|
|
7998
|
+
over: null,
|
|
7999
|
+
},
|
|
8000
|
+
},
|
|
8001
|
+
right: {
|
|
8002
|
+
type: 'binary_expr',
|
|
8003
|
+
operator: '<',
|
|
8004
|
+
left: {
|
|
8005
|
+
type: 'column_ref',
|
|
8006
|
+
table: null,
|
|
8007
|
+
db: null,
|
|
8008
|
+
schema: null,
|
|
8009
|
+
column: 'transaction_date',
|
|
8010
|
+
collate: null,
|
|
8011
|
+
},
|
|
8012
|
+
right: {
|
|
8013
|
+
type: 'function',
|
|
8014
|
+
name: {
|
|
8015
|
+
name: [
|
|
8016
|
+
{
|
|
8017
|
+
type: 'default',
|
|
8018
|
+
value: 'DATEADD',
|
|
8019
|
+
},
|
|
8020
|
+
],
|
|
8021
|
+
},
|
|
8022
|
+
args: {
|
|
8023
|
+
type: 'expr_list',
|
|
8024
|
+
value: [
|
|
8025
|
+
{
|
|
8026
|
+
type: 'column_ref',
|
|
8027
|
+
table: null,
|
|
8028
|
+
db: null,
|
|
8029
|
+
schema: null,
|
|
8030
|
+
column: 'YEAR',
|
|
8031
|
+
collate: null,
|
|
8032
|
+
},
|
|
8033
|
+
{
|
|
8034
|
+
type: 'number',
|
|
8035
|
+
value: -1,
|
|
8036
|
+
},
|
|
8037
|
+
{
|
|
8038
|
+
type: 'function',
|
|
8039
|
+
name: {
|
|
8040
|
+
name: [
|
|
8041
|
+
{
|
|
8042
|
+
type: 'default',
|
|
8043
|
+
value: 'GETDATE',
|
|
8044
|
+
},
|
|
8045
|
+
],
|
|
8046
|
+
},
|
|
8047
|
+
args: {
|
|
8048
|
+
type: 'expr_list',
|
|
8049
|
+
value: [],
|
|
8050
|
+
},
|
|
8051
|
+
over: null,
|
|
8052
|
+
},
|
|
8053
|
+
],
|
|
8054
|
+
},
|
|
8055
|
+
over: null,
|
|
8056
|
+
},
|
|
8057
|
+
},
|
|
8058
|
+
},
|
|
8059
|
+
groupby: null,
|
|
8060
|
+
having: null,
|
|
8061
|
+
top: null,
|
|
8062
|
+
orderby: null,
|
|
8063
|
+
limit: null,
|
|
8064
|
+
},
|
|
8065
|
+
},
|
|
8066
|
+
],
|
|
8067
|
+
},
|
|
8068
|
+
},
|
|
8069
|
+
];
|
|
8070
|
+
/**
|
|
8071
|
+
* A function generator for functions that checks whether an ast pattern (testWhere) is
|
|
8072
|
+
* equivalent to a predetermined ast pattern (where)
|
|
8073
|
+
*/
|
|
8074
|
+
function generateWhereChecker(astWhere) {
|
|
8075
|
+
function generateCheckFunction(where) {
|
|
8076
|
+
let resultString = `testWhere.type === '${where.type}'`;
|
|
8077
|
+
function recurseNode(node, testWhereNode) {
|
|
8078
|
+
switch (node.type) {
|
|
8079
|
+
case 'binary_expr':
|
|
8080
|
+
resultString = resultString.concat(` && (!${testWhereNode}.operator || ${testWhereNode}.operator === '${node.operator}' || (['<=', '<'].includes(${testWhereNode}.operator) && ['<=', '<'].includes('${node.operator}')) || (['>=', '>'].includes(${testWhereNode}.operator) && ['>=', '>'].includes('${node.operator}')))`);
|
|
8081
|
+
resultString = resultString.concat(` && (!${testWhereNode}?.left?.type || ${testWhereNode}?.left?.type === '${node.left.type}' || (['column_ref', 'double_quote_string', 'single_quote_string'].includes(${testWhereNode}?.left?.type) && ['column_ref', 'double_quote_string', 'single_quote_string'].includes('${node.left.type}')))`);
|
|
8082
|
+
resultString = resultString.concat(` && (!${testWhereNode}?.right?.type || ${testWhereNode}?.right?.type === '${node.right.type}' || (['column_ref', 'double_quote_string', 'single_quote_string'].includes(${testWhereNode}?.right?.type) && ['column_ref', 'double_quote_string', 'single_quote_string'].includes('${node.right.type}')))`);
|
|
8083
|
+
if (node.operator === 'AND' &&
|
|
8084
|
+
node.left?.left?.type !== 'extract' &&
|
|
8085
|
+
!(node.left?.left?.type === 'function' &&
|
|
8086
|
+
['hour', 'day', 'week', 'month', 'year'].includes(node.left?.left?.name?.name?.[0]?.value?.toLowerCase()))) {
|
|
8087
|
+
recurseNode(node.left, testWhereNode.concat(`?.left`));
|
|
8088
|
+
}
|
|
8089
|
+
recurseNode(node.right, testWhereNode.concat(`?.right`));
|
|
8090
|
+
break;
|
|
8091
|
+
case 'function':
|
|
8092
|
+
if (node?.name && typeof node.name === 'string') {
|
|
8093
|
+
resultString = resultString.concat(` && (${testWhereNode}?.name?.toLowerCase() === '${node.name.toLowerCase()} ` +
|
|
8094
|
+
`|| (['CURRENT_DATE', 'CURRENT_TIMESTAMP', 'now', 'today'].includes(${testWhereNode}?.name)) ` +
|
|
8095
|
+
`&& ['CURRENT_DATE', 'CURRENT_TIMESTAMP', 'now', 'today'].includes('${node.name}')) ` +
|
|
8096
|
+
`|| (['year', 'month', 'quarter', 'day', 'week', 'hour'].includes(${testWhereNode}?.name?.toLowerCase()) ` +
|
|
8097
|
+
`&& ['year', 'month', 'quarter', 'day', 'week', 'hour'].includes('${node.name.toLowerCase()}')) ` +
|
|
8098
|
+
`|| (['toyear', 'tomonth', 'toquarter', 'tohour'].includes(${testWhereNode}?.name?.toLowerCase()) ` +
|
|
8099
|
+
`&& ['toyear', 'tomonth', 'toquarter', 'tohour'].includes('${node.name.toLowerCase()}')) ` +
|
|
8100
|
+
`|| (['tostartofyear', 'tostartofmonth', 'tostartofquarter', 'tostartofday', 'tostartofweek', 'tostartofhour'].includes(${testWhereNode}?.name?.toLowerCase()) ` +
|
|
8101
|
+
`&& ['tostartofyear', 'tostartofmonth', 'tostartofquarter', 'tostartofday', 'tostartofweek', 'tostartofhour'].includes('${node.name.toLowerCase()}'))` +
|
|
8102
|
+
`|| (['truncyear', 'truncquarter', 'truncmonth', 'truncweek', 'truncday', 'trunchour'].includes(${testWhereNode}?.name?.toLowerCase()) ` +
|
|
8103
|
+
`&& ['truncyear', 'truncquarter', 'truncmonth', 'truncweek', 'truncday', 'trunchour'].includes('${node.name.toLowerCase()}')) ` +
|
|
8104
|
+
`|| (['tointervalyear', 'tointervalmonth', 'tointervalday', 'tointervalquarter', 'tointervalweek', 'tointervalhour'].includes(${testWhereNode}?.name?.toLowerCase()) ` +
|
|
8105
|
+
`&& ['tointervalyear', 'tointervalmonth', 'tointervalday', 'tointervalquarter', 'tointervalweek', 'tointervalhour'].includes('${node.name.toLowerCase()}')))`);
|
|
8106
|
+
}
|
|
8107
|
+
else if (node?.name?.name?.length > 0) {
|
|
8108
|
+
resultString = resultString.concat(` && (${testWhereNode}?.name?.name[0]?.value === '${node.name.name[0].value}' ` +
|
|
8109
|
+
`|| (['CURRENT_DATE', 'CURRENT_TIMESTAMP', 'now', 'today'].includes(${testWhereNode}?.name?.name[0]?.value) ` +
|
|
8110
|
+
`&& ['CURRENT_DATE', 'CURRENT_TIMESTAMP', 'now', 'today'].includes('${node.name.name[0].value}')) ` +
|
|
8111
|
+
`|| (['year', 'month', 'quarter', 'day', 'week', 'hour'].includes(${testWhereNode}?.name?.name[0]?.value?.toLowerCase()) ` +
|
|
8112
|
+
`&& ['year', 'month', 'quarter', 'day', 'week', 'hour'].includes('${node.name.name[0].value.toLowerCase()}'))` +
|
|
8113
|
+
`|| (['toyear', 'tomonth', 'toquarter', 'tohour'].includes(${testWhereNode}?.name?.name[0]?.value?.toLowerCase()) ` +
|
|
8114
|
+
`&& ['toyear', 'tomonth', 'toquarter', 'tohour'].includes('${node.name.name[0].value.toLowerCase()}'))` +
|
|
8115
|
+
`|| (['tostartofyear', 'tostartofmonth', 'tostartofquarter', 'tostartofday', 'tostartofweek', 'tostartofhour'].includes(${testWhereNode}?.name?.name[0]?.value?.toLowerCase()) ` +
|
|
8116
|
+
`&& ['tostartofyear', 'tostartofmonth', 'tostartofquarter', 'tostartofday', 'tostartofweek', 'tostartofhour'].includes('${node.name.name[0].value.toLowerCase()}'))` +
|
|
8117
|
+
`|| (['truncyear', 'truncquarter', 'truncmonth', 'truncweek', 'truncday', 'trunchour'].includes(${testWhereNode}?.name?.name[0]?.value?.toLowerCase()) ` +
|
|
7676
8118
|
`&& ['truncyear', 'truncquarter', 'truncmonth', 'truncweek', 'truncday', 'trunchour'].includes('${node.name.name[0].value.toLowerCase()}')) ` +
|
|
7677
8119
|
`|| (['tointervalyear', 'tointervalmonth', 'tointervalday', 'tointervalquarter', 'tointervalweek', 'tointervalhour'].includes(${testWhereNode}?.name?.name[0]?.value?.toLowerCase()) ` +
|
|
7678
8120
|
`&& ['tointervalyear', 'tointervalmonth', 'tointervalday', 'tointervalquarter', 'tointervalweek', 'tointervalhour'].includes('${node.name.name[0].value.toLowerCase()}')))`);
|
|
@@ -7825,6 +8267,37 @@ function fieldColumnToLowerCaseAst(field, db, isColumnRef) {
|
|
|
7825
8267
|
},
|
|
7826
8268
|
over: null,
|
|
7827
8269
|
};
|
|
8270
|
+
case 'mssql':
|
|
8271
|
+
return {
|
|
8272
|
+
type: 'function',
|
|
8273
|
+
name: {
|
|
8274
|
+
name: [
|
|
8275
|
+
{
|
|
8276
|
+
type: 'default',
|
|
8277
|
+
value: 'LOWER',
|
|
8278
|
+
},
|
|
8279
|
+
],
|
|
8280
|
+
},
|
|
8281
|
+
args: {
|
|
8282
|
+
type: 'expr_list',
|
|
8283
|
+
value: [
|
|
8284
|
+
isColumnRef
|
|
8285
|
+
? {
|
|
8286
|
+
type: 'column_ref',
|
|
8287
|
+
table: null,
|
|
8288
|
+
db: null,
|
|
8289
|
+
schema: null,
|
|
8290
|
+
column: field,
|
|
8291
|
+
collate: null,
|
|
8292
|
+
}
|
|
8293
|
+
: {
|
|
8294
|
+
type: 'single_quote_string',
|
|
8295
|
+
value: field,
|
|
8296
|
+
},
|
|
8297
|
+
],
|
|
8298
|
+
},
|
|
8299
|
+
over: null,
|
|
8300
|
+
};
|
|
7828
8301
|
case 'postgresql':
|
|
7829
8302
|
case 'clickhouse':
|
|
7830
8303
|
default:
|
|
@@ -7876,7 +8349,7 @@ function lowerFunctionToField(lower, db) {
|
|
|
7876
8349
|
lower.name.toLowerCase() === 'lower') ||
|
|
7877
8350
|
lower.name?.name[0]?.value?.toLowerCase() === 'lower' ||
|
|
7878
8351
|
lower.name?.schema?.value?.toLowerCase() === 'lower'))) {
|
|
7879
|
-
return
|
|
8352
|
+
return null;
|
|
7880
8353
|
}
|
|
7881
8354
|
switch (db) {
|
|
7882
8355
|
case 'redshift':
|
|
@@ -7885,18 +8358,22 @@ function lowerFunctionToField(lower, db) {
|
|
|
7885
8358
|
case 'mysql':
|
|
7886
8359
|
case 'postgresql':
|
|
7887
8360
|
case 'clickhouse':
|
|
7888
|
-
|
|
8361
|
+
case 'mssql':
|
|
8362
|
+
return getFieldFromExpression(lower, db) ?? '';
|
|
7889
8363
|
default:
|
|
7890
|
-
return
|
|
8364
|
+
return null;
|
|
7891
8365
|
}
|
|
7892
8366
|
}
|
|
7893
8367
|
/**
|
|
7894
8368
|
* Function that extracts a field value
|
|
7895
8369
|
*/
|
|
7896
|
-
function getFieldFromExpression(expr) {
|
|
8370
|
+
function getFieldFromExpression(expr, databaseType) {
|
|
7897
8371
|
return (expr.column?.expr?.value ||
|
|
7898
8372
|
expr.column ||
|
|
7899
8373
|
expr.args?.value?.[1]?.expr?.column ||
|
|
8374
|
+
(databaseType === 'mssql'
|
|
8375
|
+
? (expr.args?.value?.[1]?.column ?? expr.args.value?.[0]?.column)
|
|
8376
|
+
: null) ||
|
|
7900
8377
|
expr.args?.value?.[1]?.args?.value?.[0]?.column?.expr?.value ||
|
|
7901
8378
|
expr.args?.value?.[0]?.value?.expr?.value ||
|
|
7902
8379
|
expr.args?.value?.[1]?.column?.expr?.value ||
|
|
@@ -8034,6 +8511,7 @@ const astToFilter = (ast, db, columns) => {
|
|
|
8034
8511
|
case 'redshift':
|
|
8035
8512
|
case 'postgresql':
|
|
8036
8513
|
case 'clickhouse':
|
|
8514
|
+
case 'mssql':
|
|
8037
8515
|
leftExpr = left;
|
|
8038
8516
|
while (leftExpr.type === 'binary_expr') {
|
|
8039
8517
|
leftExpr = leftExpr.left;
|
|
@@ -8044,10 +8522,10 @@ const astToFilter = (ast, db, columns) => {
|
|
|
8044
8522
|
leftExpr.args?.value[1]?.column?.expr?.value ??
|
|
8045
8523
|
leftExpr.args?.value[0]?.column?.expr?.value ??
|
|
8046
8524
|
lowerFunctionToField(leftExpr, db) ??
|
|
8047
|
-
getFieldFromExpression(leftExpr);
|
|
8525
|
+
getFieldFromExpression(leftExpr, db);
|
|
8048
8526
|
break;
|
|
8049
8527
|
default:
|
|
8050
|
-
field = getFieldFromExpression(leftExpr);
|
|
8528
|
+
field = getFieldFromExpression(leftExpr, db);
|
|
8051
8529
|
if (!field) {
|
|
8052
8530
|
console.error('Could not determine field: ', leftExpr);
|
|
8053
8531
|
return null;
|
|
@@ -8061,7 +8539,7 @@ const astToFilter = (ast, db, columns) => {
|
|
|
8061
8539
|
while (leftExpr.type === 'binary_expr') {
|
|
8062
8540
|
leftExpr = leftExpr.left;
|
|
8063
8541
|
}
|
|
8064
|
-
field = getFieldFromExpression(leftExpr);
|
|
8542
|
+
field = getFieldFromExpression(leftExpr, db);
|
|
8065
8543
|
if (!field) {
|
|
8066
8544
|
console.error('Could not determine field: ', leftExpr);
|
|
8067
8545
|
return null;
|
|
@@ -8229,19 +8707,19 @@ const astToFilter = (ast, db, columns) => {
|
|
|
8229
8707
|
switch (filterName) {
|
|
8230
8708
|
case Filter_1.FilterType.StringFilter:
|
|
8231
8709
|
return {
|
|
8232
|
-
field: lowerFunctionToField(field, db).replaceAll('%', ''),
|
|
8710
|
+
field: (lowerFunctionToField(field, db) ?? '').replaceAll('%', ''),
|
|
8233
8711
|
filterType: filterName,
|
|
8234
8712
|
fieldType: Filter_1.FieldType.String,
|
|
8235
8713
|
operator: mappedOperator,
|
|
8236
|
-
value: lowerFunctionToField(right, db).replaceAll('%', ''),
|
|
8714
|
+
value: (lowerFunctionToField(right, db) ?? '').replaceAll('%', ''),
|
|
8237
8715
|
};
|
|
8238
8716
|
case Filter_1.FilterType.StringInFilter:
|
|
8239
8717
|
return {
|
|
8240
|
-
field: lowerFunctionToField(field, db).replaceAll('%', ''),
|
|
8718
|
+
field: (lowerFunctionToField(field, db) ?? '').replaceAll('%', ''),
|
|
8241
8719
|
filterType: filterName,
|
|
8242
8720
|
fieldType: Filter_1.FieldType.String,
|
|
8243
8721
|
operator: mappedOperator,
|
|
8244
|
-
value: right.value.map((v) => lowerFunctionToField(v, db).replaceAll('%', '')),
|
|
8722
|
+
value: right.value.map((v) => (lowerFunctionToField(v, db) ?? '').replaceAll('%', '')),
|
|
8245
8723
|
};
|
|
8246
8724
|
case Filter_1.FilterType.NumericFilter:
|
|
8247
8725
|
return {
|
|
@@ -8764,6 +9242,64 @@ const filterToAst = (filter, db) => {
|
|
|
8764
9242
|
},
|
|
8765
9243
|
},
|
|
8766
9244
|
};
|
|
9245
|
+
case 'mssql':
|
|
9246
|
+
return {
|
|
9247
|
+
type: 'binary_expr',
|
|
9248
|
+
operator: '>=',
|
|
9249
|
+
left: {
|
|
9250
|
+
type: 'column_ref',
|
|
9251
|
+
table: null,
|
|
9252
|
+
db: null,
|
|
9253
|
+
schema: null,
|
|
9254
|
+
column: field,
|
|
9255
|
+
collate: null,
|
|
9256
|
+
},
|
|
9257
|
+
right: {
|
|
9258
|
+
type: 'function',
|
|
9259
|
+
name: {
|
|
9260
|
+
name: [
|
|
9261
|
+
{
|
|
9262
|
+
type: 'default',
|
|
9263
|
+
value: 'DATEADD',
|
|
9264
|
+
},
|
|
9265
|
+
],
|
|
9266
|
+
},
|
|
9267
|
+
args: {
|
|
9268
|
+
type: 'expr_list',
|
|
9269
|
+
value: [
|
|
9270
|
+
{
|
|
9271
|
+
type: 'column_ref',
|
|
9272
|
+
table: null,
|
|
9273
|
+
db: null,
|
|
9274
|
+
schema: null,
|
|
9275
|
+
column: filter.value.unit,
|
|
9276
|
+
collate: null,
|
|
9277
|
+
},
|
|
9278
|
+
{
|
|
9279
|
+
type: 'number',
|
|
9280
|
+
value: -filter.value.value,
|
|
9281
|
+
},
|
|
9282
|
+
{
|
|
9283
|
+
type: 'function',
|
|
9284
|
+
name: {
|
|
9285
|
+
name: [
|
|
9286
|
+
{
|
|
9287
|
+
type: 'default',
|
|
9288
|
+
value: 'GETDATE',
|
|
9289
|
+
},
|
|
9290
|
+
],
|
|
9291
|
+
},
|
|
9292
|
+
args: {
|
|
9293
|
+
type: 'expr_list',
|
|
9294
|
+
value: [],
|
|
9295
|
+
},
|
|
9296
|
+
over: null,
|
|
9297
|
+
},
|
|
9298
|
+
],
|
|
9299
|
+
},
|
|
9300
|
+
over: null,
|
|
9301
|
+
},
|
|
9302
|
+
};
|
|
8767
9303
|
default:
|
|
8768
9304
|
console.error('Unknown database source: ', db);
|
|
8769
9305
|
return null;
|
|
@@ -9451,6 +9987,85 @@ const filterToAst = (filter, db) => {
|
|
|
9451
9987
|
},
|
|
9452
9988
|
},
|
|
9453
9989
|
};
|
|
9990
|
+
case 'mssql':
|
|
9991
|
+
return {
|
|
9992
|
+
type: 'binary_expr',
|
|
9993
|
+
operator: '=',
|
|
9994
|
+
left: {
|
|
9995
|
+
type: 'function',
|
|
9996
|
+
name: {
|
|
9997
|
+
name: [
|
|
9998
|
+
{
|
|
9999
|
+
type: 'default',
|
|
10000
|
+
value: 'DATETRUNC',
|
|
10001
|
+
},
|
|
10002
|
+
],
|
|
10003
|
+
},
|
|
10004
|
+
args: {
|
|
10005
|
+
type: 'expr_list',
|
|
10006
|
+
value: [
|
|
10007
|
+
{
|
|
10008
|
+
type: 'column_ref',
|
|
10009
|
+
table: null,
|
|
10010
|
+
db: null,
|
|
10011
|
+
schema: null,
|
|
10012
|
+
column: filter.value.unit,
|
|
10013
|
+
collate: null,
|
|
10014
|
+
},
|
|
10015
|
+
{
|
|
10016
|
+
type: 'column_ref',
|
|
10017
|
+
table: null,
|
|
10018
|
+
db: null,
|
|
10019
|
+
schema: null,
|
|
10020
|
+
column: field,
|
|
10021
|
+
collate: null,
|
|
10022
|
+
},
|
|
10023
|
+
],
|
|
10024
|
+
},
|
|
10025
|
+
over: null,
|
|
10026
|
+
},
|
|
10027
|
+
right: {
|
|
10028
|
+
type: 'function',
|
|
10029
|
+
name: {
|
|
10030
|
+
name: [
|
|
10031
|
+
{
|
|
10032
|
+
type: 'default',
|
|
10033
|
+
value: 'DATETRUNC',
|
|
10034
|
+
},
|
|
10035
|
+
],
|
|
10036
|
+
},
|
|
10037
|
+
args: {
|
|
10038
|
+
type: 'expr_list',
|
|
10039
|
+
value: [
|
|
10040
|
+
{
|
|
10041
|
+
type: 'column_ref',
|
|
10042
|
+
table: null,
|
|
10043
|
+
db: null,
|
|
10044
|
+
schema: null,
|
|
10045
|
+
column: filter.value.unit,
|
|
10046
|
+
collate: null,
|
|
10047
|
+
},
|
|
10048
|
+
{
|
|
10049
|
+
type: 'function',
|
|
10050
|
+
name: {
|
|
10051
|
+
name: [
|
|
10052
|
+
{
|
|
10053
|
+
type: 'default',
|
|
10054
|
+
value: 'GETDATE',
|
|
10055
|
+
},
|
|
10056
|
+
],
|
|
10057
|
+
},
|
|
10058
|
+
args: {
|
|
10059
|
+
type: 'expr_list',
|
|
10060
|
+
value: [],
|
|
10061
|
+
},
|
|
10062
|
+
over: null,
|
|
10063
|
+
},
|
|
10064
|
+
],
|
|
10065
|
+
},
|
|
10066
|
+
over: null,
|
|
10067
|
+
},
|
|
10068
|
+
};
|
|
9454
10069
|
default:
|
|
9455
10070
|
console.error('Unknown database source: ', db);
|
|
9456
10071
|
return null;
|
|
@@ -10061,6 +10676,126 @@ const filterToAst = (filter, db) => {
|
|
|
10061
10676
|
},
|
|
10062
10677
|
parentheses: true,
|
|
10063
10678
|
};
|
|
10679
|
+
case 'mssql':
|
|
10680
|
+
return {
|
|
10681
|
+
type: 'binary_expr',
|
|
10682
|
+
operator: 'AND',
|
|
10683
|
+
left: {
|
|
10684
|
+
type: 'binary_expr',
|
|
10685
|
+
operator: '>=',
|
|
10686
|
+
left: {
|
|
10687
|
+
type: 'column_ref',
|
|
10688
|
+
table: null,
|
|
10689
|
+
db: null,
|
|
10690
|
+
schema: null,
|
|
10691
|
+
column: field,
|
|
10692
|
+
collate: null,
|
|
10693
|
+
},
|
|
10694
|
+
right: {
|
|
10695
|
+
type: 'function',
|
|
10696
|
+
name: {
|
|
10697
|
+
name: [
|
|
10698
|
+
{
|
|
10699
|
+
type: 'default',
|
|
10700
|
+
value: 'DATEADD',
|
|
10701
|
+
},
|
|
10702
|
+
],
|
|
10703
|
+
},
|
|
10704
|
+
args: {
|
|
10705
|
+
type: 'expr_list',
|
|
10706
|
+
value: [
|
|
10707
|
+
{
|
|
10708
|
+
type: 'column_ref',
|
|
10709
|
+
table: null,
|
|
10710
|
+
db: null,
|
|
10711
|
+
schema: null,
|
|
10712
|
+
column: filter.value.unit,
|
|
10713
|
+
collate: null,
|
|
10714
|
+
},
|
|
10715
|
+
{
|
|
10716
|
+
type: 'number',
|
|
10717
|
+
value: -filter.value.value * 2,
|
|
10718
|
+
},
|
|
10719
|
+
{
|
|
10720
|
+
type: 'function',
|
|
10721
|
+
name: {
|
|
10722
|
+
name: [
|
|
10723
|
+
{
|
|
10724
|
+
type: 'default',
|
|
10725
|
+
value: 'GETDATE',
|
|
10726
|
+
},
|
|
10727
|
+
],
|
|
10728
|
+
},
|
|
10729
|
+
args: {
|
|
10730
|
+
type: 'expr_list',
|
|
10731
|
+
value: [],
|
|
10732
|
+
},
|
|
10733
|
+
over: null,
|
|
10734
|
+
},
|
|
10735
|
+
],
|
|
10736
|
+
},
|
|
10737
|
+
over: null,
|
|
10738
|
+
},
|
|
10739
|
+
},
|
|
10740
|
+
right: {
|
|
10741
|
+
type: 'binary_expr',
|
|
10742
|
+
operator: '<',
|
|
10743
|
+
left: {
|
|
10744
|
+
type: 'column_ref',
|
|
10745
|
+
table: null,
|
|
10746
|
+
db: null,
|
|
10747
|
+
schema: null,
|
|
10748
|
+
column: field,
|
|
10749
|
+
collate: null,
|
|
10750
|
+
},
|
|
10751
|
+
right: {
|
|
10752
|
+
type: 'function',
|
|
10753
|
+
name: {
|
|
10754
|
+
name: [
|
|
10755
|
+
{
|
|
10756
|
+
type: 'default',
|
|
10757
|
+
value: 'DATEADD',
|
|
10758
|
+
},
|
|
10759
|
+
],
|
|
10760
|
+
},
|
|
10761
|
+
args: {
|
|
10762
|
+
type: 'expr_list',
|
|
10763
|
+
value: [
|
|
10764
|
+
{
|
|
10765
|
+
type: 'column_ref',
|
|
10766
|
+
table: null,
|
|
10767
|
+
db: null,
|
|
10768
|
+
schema: null,
|
|
10769
|
+
column: filter.value.unit,
|
|
10770
|
+
collate: null,
|
|
10771
|
+
},
|
|
10772
|
+
{
|
|
10773
|
+
type: 'number',
|
|
10774
|
+
value: -filter.value.value,
|
|
10775
|
+
},
|
|
10776
|
+
{
|
|
10777
|
+
type: 'function',
|
|
10778
|
+
name: {
|
|
10779
|
+
name: [
|
|
10780
|
+
{
|
|
10781
|
+
type: 'default',
|
|
10782
|
+
value: 'GETDATE',
|
|
10783
|
+
},
|
|
10784
|
+
],
|
|
10785
|
+
},
|
|
10786
|
+
args: {
|
|
10787
|
+
type: 'expr_list',
|
|
10788
|
+
value: [],
|
|
10789
|
+
},
|
|
10790
|
+
over: null,
|
|
10791
|
+
},
|
|
10792
|
+
],
|
|
10793
|
+
},
|
|
10794
|
+
over: null,
|
|
10795
|
+
},
|
|
10796
|
+
},
|
|
10797
|
+
parentheses: true,
|
|
10798
|
+
};
|
|
10064
10799
|
default:
|
|
10065
10800
|
console.error('Unknown database source: ', db);
|
|
10066
10801
|
return null;
|