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

Ensure tables response is always a string #965

Merged
merged 1 commit into from
Oct 16, 2023
Merged

Ensure tables response is always a string #965

merged 1 commit into from
Oct 16, 2023

Conversation

simon-leech
Copy link
Contributor

In the location.get get, it is currently getting the first table in the tables object that is not null. However, null is converted to an empty object in XYZ, so presently this returns an error.
This PR simply adds a check to ensure that the response has to be a string, ensuring objects and null are omitted.

Example here


// example 
const layer2 = {
    "tables": {
    "10": {},
    "11": "schema.table"
  }
}

//  CURRENT METHOD
const layer2table = layer2.table || Object.values(layer2.tables).find(table => !!table)
console.log(layer2table);

// PR CHANGE
const layer2tableNEW = layer2.table ??= 
    Object.values(layer2.tables).find(table => typeof table === 'string')

console.log(layer2tableNEW);

@simon-leech simon-leech requested review from RobAndrewHurst and dbauszus-glx and removed request for RobAndrewHurst October 16, 2023 14:18
@simon-leech simon-leech added the Bug A genuine bug. There must be some form of error exception to work with. label Oct 16, 2023
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@dbauszus-glx dbauszus-glx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dbauszus-glx dbauszus-glx merged commit 74e0188 into GEOLYTIX:main Oct 16, 2023
6 checks passed
@simon-leech simon-leech deleted the custom-view-tables branch February 9, 2024 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A genuine bug. There must be some form of error exception to work with.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants