Skip to content

Commit

Permalink
Merge pull request #141 from skyflowapi/release/24.1.2
Browse files Browse the repository at this point in the history
SK-1439 Release/24.1.2 fix unique column name
  • Loading branch information
yaswanth-pula-skyflow authored Jan 25, 2024
2 parents 56a14af + 9355a37 commit 5169650
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "skyflow-node",
"version": "1.13.0",
"version": "1.13.0-dev.afc34c0",
"description": "Skyflow SDK for Node.js",
"main": "./lib/index.js",
"module": "./lib/index.js",
Expand Down
8 changes: 4 additions & 4 deletions src/vault-api/core/Reveal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ const getSkyflowIdRecordsFromVault = (
});

if (options && Object.prototype.hasOwnProperty.call(options, 'encodeURI') && options?.encodeURI === false){
skyflowIdRecord.columnValues?.forEach((column) => {
paramList += `column_name=${skyflowIdRecord.columnName}&column_values=${column}&`;
skyflowIdRecord.columnValues?.forEach((column,index) => {
paramList += `${index === 0 ?`column_name=${skyflowIdRecord.columnName}&`:''}column_values=${column}&`;
});
} else {
skyflowIdRecord.columnValues?.forEach((column) => {
skyflowIdRecord.columnValues?.forEach((column,index) => {
var encode_column_value = encodeURIComponent(column)
paramList += `column_name=${skyflowIdRecord.columnName}&column_values=${encode_column_value}&`;
paramList += `${index === 0 ?`column_name=${skyflowIdRecord.columnName}&`:''}column_values=${encode_column_value}&`;
});
}

Expand Down
83 changes: 83 additions & 0 deletions test/vault-api/Skyflow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,17 @@ const getByIdWithValidUniqColumnOptions= {
],
};

const getByIdWithValidMultipleUniqColumnOptions= {
records: [
{
table: "cards",
columnName: "abc",
columnValues: ["value","value2","value3"],
redaction: "PLAIN_TEXT",
},
],
};

const getByIdRes = {
records: [
{
Expand Down Expand Up @@ -1930,6 +1941,78 @@ describe('get method with options', () => {
});


});

test('get method should send request url with single column name for multiple column value', (done) => {

let reqArg;
const clientReq = jest.fn((arg) => {
reqArg = arg;
return Promise.resolve({data:getByIdRes})
});

const mockClient = {
config: skyflowConfig,
request: clientReq,
metadata: {}
}

clientModule.mockImplementation(() => { return mockClient });
skyflow = Skyflow.init({
vaultID: '<VaultID>',
vaultURL: 'https://www.vaulturl.com',
getBearerToken: () => {
return new Promise((resolve, _) => {
resolve("token")
})
}
});

const response = skyflow.get(getByIdWithValidMultipleUniqColumnOptions);
response.then((res) => {
expect((reqArg.url).match(/column_name=abc/gi)?.length).toBe(1);
done();
}).catch((er) => {
done(er)
});


});

test('get method should send request url with single column name for multiple column value', (done) => {

let reqArg;
const clientReq = jest.fn((arg) => {
reqArg = arg;
return Promise.resolve({data:getByIdRes})
});

const mockClient = {
config: skyflowConfig,
request: clientReq,
metadata: {}
}

clientModule.mockImplementation(() => { return mockClient });
skyflow = Skyflow.init({
vaultID: '<VaultID>',
vaultURL: 'https://www.vaulturl.com',
getBearerToken: () => {
return new Promise((resolve, _) => {
resolve("token")
})
}
});

const response = skyflow.get(getByIdWithValidMultipleUniqColumnOptions,{encodeURI:false});
response.then((res) => {
expect((reqArg.url).match(/column_name=abc/gi)?.length).toBe(1);
done();
}).catch((er) => {
done(er)
});


});


Expand Down

0 comments on commit 5169650

Please sign in to comment.