Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-9504: accept bson queries in mql function #431

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading