Skip to content

Commit

Permalink
RSDK-9504: accept bson queries in mql function (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
purplenicole730 authored Dec 18, 2024
1 parent 60f9df8 commit a0540ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/data-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe('DataClient tests', () => {

it('get tabular data from MQL', async () => {
const promise = await subject().tabularDataByMQL('some_org_id', [
new TextEncoder().encode('some_mql_query'),
{ query: 'some_mql_query' },
]);
const result = promise as typeof data;
expect(result[0]?.key1).toBeInstanceOf(Date);
Expand Down
11 changes: 9 additions & 2 deletions src/app/data-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,17 @@ export class DataClient {
* @param query The MQL query to run as a list of BSON documents
* @returns An array of data objects
*/
async tabularDataByMQL(organizationId: string, query: Uint8Array[]) {
async tabularDataByMQL(
organizationId: string,
query: Uint8Array[] | Record<string, Date | JsonValue>[]
) {
const binary: Uint8Array[] =
query[0] instanceof Uint8Array
? (query as Uint8Array[])
: query.map((value) => BSON.serialize(value));
const resp = await this.dataClient.tabularDataByMQL({
organizationId,
mqlBinary: query,
mqlBinary: binary,
});
return resp.rawData.map((value) => BSON.deserialize(value));
}
Expand Down

0 comments on commit a0540ee

Please sign in to comment.