Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eaa3b3e619 | ||
|
|
d845b9e9b7 |
No files matched your search
@@ -3647,7 +3647,16 @@ export class EditorComponent
|
||||
if (clauses.length === 0) return false
|
||||
|
||||
try {
|
||||
const res: any = await this.sasStoreService.saveQuery(libds, clauses)
|
||||
// A `va_parmap` entry is a column the report author typed, so this
|
||||
// request can legitimately fail: the table may not have that column, and
|
||||
// validatefilter aborts on an unknown variable (dc/dc#404). Attempting it
|
||||
// is still worth it - when the mapping is right the very first getdata is
|
||||
// already filtered - but the failure must not stop the page. An abort
|
||||
// modal here covers an editor that is about to load fine; the mapping
|
||||
// banner names the bad entry once the real metadata arrives.
|
||||
const res: any = await this.sasStoreService.saveQuery(libds, clauses, {
|
||||
suppressErrorAbortModal: true
|
||||
})
|
||||
const id = res?.result?.[0]?.FILTER_RK
|
||||
const table = res?.result?.[0]?.FILTER_TABLE
|
||||
if (id === undefined || table === undefined) return false
|
||||
|
||||
@@ -116,6 +116,53 @@ describe('SasStoreService', () => {
|
||||
expect(seen.length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('saveQuery', () => {
|
||||
const capture = (adapterResponse: any = { result: [] }) => {
|
||||
const calls: any[][] = []
|
||||
const store = new SasStoreService(
|
||||
{
|
||||
request: (...args: any[]) => {
|
||||
calls.push(args)
|
||||
return Promise.resolve({ adapterResponse })
|
||||
}
|
||||
} as any,
|
||||
{} as any,
|
||||
{} as any
|
||||
)
|
||||
return { store, calls }
|
||||
}
|
||||
|
||||
it('posts the filter to public/validatefilter', async () => {
|
||||
const { store, calls } = capture()
|
||||
await store.saveQuery('DC.MY_TABLE', [
|
||||
{ VARIABLE_NM: 'A', OPERATOR_NM: '=', RAW_VALUE: "'x'" } as any
|
||||
])
|
||||
|
||||
expect(calls[0][0]).toBe('public/validatefilter')
|
||||
expect(calls[0][1].iwant[0].filter_table).toBe('DC.MY_TABLE')
|
||||
expect(calls[0][1].filterquery.length).toBe(1)
|
||||
})
|
||||
|
||||
it('passes wrapper options through, so a rejected filter can stay quiet', async () => {
|
||||
// The VA deferred load attempts a filter built from a va_parmap entry the
|
||||
// table may not have, and must not cover a page that loads fine with an
|
||||
// abort modal (dc/dc#404).
|
||||
const { store, calls } = capture()
|
||||
await store.saveQuery('DC.MY_TABLE', [], {
|
||||
suppressErrorAbortModal: true
|
||||
})
|
||||
|
||||
expect(calls[0][3]).toEqual({ suppressErrorAbortModal: true })
|
||||
})
|
||||
|
||||
it('sends no wrapper options when the caller gives none', async () => {
|
||||
const { store, calls } = capture()
|
||||
await store.saveQuery('DC.MY_TABLE', [])
|
||||
|
||||
expect(calls[0][3]).toBeUndefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ import { HelperService } from './helper.service'
|
||||
import { QueryClause } from '../models/TableData'
|
||||
import { globals } from '../_globals'
|
||||
import { FilterClause, FilterGroup, FilterQuery } from '../models/FilterQuery'
|
||||
import { RequestWrapperOptions } from '../models/request-wrapper/RequestWrapperOptions'
|
||||
import {
|
||||
$DataFormats,
|
||||
EditorsGetDataSASResponse,
|
||||
@@ -395,13 +396,30 @@ export class SasStoreService {
|
||||
).adapterResponse
|
||||
}
|
||||
|
||||
public async saveQuery(libds: string, filterQuery: QueryClause[]) {
|
||||
/**
|
||||
* Persists a filter and returns its FILTER_RK.
|
||||
*
|
||||
* `wrapperOptions` reaches the request wrapper, so a caller that can live with
|
||||
* a rejected filter (the VA deferred load, whose `va_parmap` entry may name a
|
||||
* column the table does not have) can suppress the abort modal that would
|
||||
* otherwise cover a page which is about to load perfectly well.
|
||||
*/
|
||||
public async saveQuery(
|
||||
libds: string,
|
||||
filterQuery: QueryClause[],
|
||||
wrapperOptions?: RequestWrapperOptions
|
||||
) {
|
||||
let tables = {
|
||||
iwant: [{ filter_table: libds }],
|
||||
filterquery: filterQuery
|
||||
}
|
||||
|
||||
const res = await this.sasService.request('public/validatefilter', tables)
|
||||
const res = await this.sasService.request(
|
||||
'public/validatefilter',
|
||||
tables,
|
||||
undefined,
|
||||
wrapperOptions
|
||||
)
|
||||
|
||||
this.filter.next(res)
|
||||
|
||||
|
||||
Reference in new issue
Block a user