-
Notifications
You must be signed in to change notification settings - Fork 272
feat(core): add extra form data fields for native filters #992
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,41 @@ describe('buildQueryObject', () => { | |
expect(query.metrics).toEqual(['sum__num', 'avg__num']); | ||
}); | ||
|
||
it('should merge original and append filters', () => { | ||
query = buildQueryObject({ | ||
datasource: '5__table', | ||
granularity_sqla: 'ds', | ||
viz_type: 'table', | ||
extra_filters: [{ col: 'abc', op: '==', val: 'qwerty' }], | ||
adhoc_filters: [ | ||
{ | ||
expressionType: 'SIMPLE', | ||
clause: 'WHERE', | ||
subject: 'foo', | ||
operator: '!=', | ||
comparator: 'bar', | ||
}, | ||
], | ||
where: 'a = b', | ||
extra_form_data: { | ||
append_form_data: { | ||
adhoc_filters: [ | ||
{ | ||
expressionType: 'SQL', | ||
clause: 'WHERE', | ||
sqlExpression: '(1 = 1)', | ||
}, | ||
], | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question about I'm a little confused why do we need to allow appending and overriding both It seems to me the original design of an Not sure if this is the direction of future refactoring, but we probably shouldn't add extra stuff that are not configurable by chart controls to buildQueryObject(formData, {
queryFields: ... // configured in chart metatada,
extraFormData: {
append: {
adhoc_filter: [...],
},
override: {
}
} // collected from dashboard state
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably:
|
||
}, | ||
}); | ||
expect(query.filters).toEqual([ | ||
{ col: 'abc', op: '==', val: 'qwerty' }, | ||
{ col: 'foo', op: '!=', val: 'bar' }, | ||
]); | ||
expect(query.extras?.where).toEqual('(a = b) AND ((1 = 1))'); | ||
}); | ||
|
||
it('should group custom metric control', () => { | ||
query = buildQueryObject( | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 questions:
extractExtras
?filters and adhoc_filters
fromcustom_form_data and override_form_data
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extractExtras
andprocessFilters
probably need to be slightly refactored now that there's more stuff going on here, but since this code is slightly convoluted I prefer to keep these changes as small as possible for now. Let's do a proper refactor soon when we know the full scope of changes required by native and cross filters.custom_form_data
probably shouldn't includefilters
andadhoc_filters
, as those are already defined inQueryFormData
andQueryObject
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About 2. For example what will be behavior for a case:
I have table with server pagination and cross filtering:
Page 2
we have incustom_form_data
data about server paginationresetDashboard
so we need reset it toPage 1
or stuff like that