Skipping parse of empty array response (#14502)

- When we get a response from API, the data can be either null, undefined, not an array and an array but with no data
- We had handled for everything else except the case of empty array
- This commit fixes that

- We run a query which will return an empty array as response
- We check if application is crashing because of this
This commit is contained in:
Ayush Pahwa 2022-06-15 10:59:57 +05:30 committed by GitHub
parent f475f3236e
commit d220ed428a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -331,7 +331,17 @@ describe("Validate CRUD queries for Postgres along with UI flow verifications",
cy.deleteQueryUsingContext();
});
it("12. Deletes the datasource", () => {
it("12. Bug 14493: The application is breaking when user runs the query with result as empty array", function() {
cy.NavigateToActiveDSQueryPane(datasourceName);
cy.get(queryLocators.templateMenu).click({ force: true });
cy.typeValueNValidate(
"select * from public.users where name='Ayush1234' ORDER BY id LIMIT 10",
);
cy.runQuery();
cy.deleteQueryUsingContext();
});
it("13. Deletes the datasource", () => {
cy.NavigateToQueryEditor();
cy.NavigateToActiveTab();
cy.contains(".t--datasource-name", datasourceName).click({ force: true });

View File

@ -202,7 +202,7 @@ function Table(props: TableProps) {
const data = React.useMemo(() => {
const emptyString = "";
/* Check for length greater than 0 of rows returned from the query for mappings keys */
if (isArray(props.data)) {
if (!!props.data && isArray(props.data) && props.data.length > 0) {
const keys = Object.keys(props.data[0]);
keys.forEach((key) => {
if (key === emptyString) {