Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

fix: unset row_limit when it's not a number #387

Merged
merged 2 commits into from
Apr 22, 2020
Merged

Conversation

etr2460
Copy link
Contributor

@etr2460 etr2460 commented Apr 22, 2020

🐛 Bug Fix

Recently Superset was changed to not allow row_limit to be null, it can only be unset or a number. This fixes the library to match it

to: @williaster @ktmud @villebro @kristw

@etr2460 etr2460 requested a review from a team as a code owner April 22, 2020 20:10
@vercel
Copy link

vercel bot commented Apr 22, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/superset/superset-ui/hev3g00f1
✅ Preview: https://superset-ui-git-etr2460-patch-1.superset.now.sh

@codecov
Copy link

codecov bot commented Apr 22, 2020

Codecov Report

Merging #387 into master will increase coverage by 0.00%.
The diff coverage is 50.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #387   +/-   ##
=======================================
  Coverage   26.30%   26.31%           
=======================================
  Files         192      192           
  Lines        5291     5293    +2     
  Branches      474      475    +1     
=======================================
+ Hits         1392     1393    +1     
  Misses       3864     3864           
- Partials       35       36    +1     
Impacted Files Coverage Δ
packages/superset-ui-query/src/buildQueryObject.ts 92.30% <50.00%> (-7.70%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a95301f...6ede46d. Read the comment docs.

@@ -42,7 +42,7 @@ export default function buildQueryObject<T extends QueryFormData>(formData: T):
metrics: processMetrics(formData),
order_desc: typeof order_desc === 'undefined' ? true : order_desc,
orderby: [],
row_limit: Number(row_limit),
row_limit: !Number(row_limit) && row_limit !== 0 ? undefined : Number(row_limit),
Copy link
Contributor

@williaster williaster Apr 22, 2020

Choose a reason for hiding this comment

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

if we're converting row_limit to a number, won't row_limit !== 0 always be true?

could this be something like

const numericRowLimit = Number(row_limit);
...
row_limit: row_limit == null || isNaN(numericRowLimit) ? undefined : numericRowLimit,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm catching the case where if row_limit = 0, we don't want to set it to undefined.

!Number(0) is true, but we don't want row_limit to be undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe this should be Number(row_limit) though...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i see your point, updated

Copy link
Contributor

@williaster williaster left a comment

Choose a reason for hiding this comment

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

💯

@etr2460 etr2460 merged commit 98b6117 into master Apr 22, 2020
@delete-merged-branch delete-merged-branch bot deleted the etr2460-patch-1 branch April 22, 2020 20:40
@villebro
Copy link
Contributor

My apologies, apparently one of my changes caused this problem. I'll try not to make breaking changes to QueryContext/QueryObject going forward without including all central stakeholders in the review process. Who would be the right person(s) to tag when making changes to these classes?

@williaster
Copy link
Contributor

thanks @villebro. I think tagging @kristw or myself or @ktmud would be good 👍 (apologies for not keeping a close pulse on the refactoring, I think you may already be tagging Krist + Jesse)

@williaster
Copy link
Contributor

I think ideally there would be some integration tests between the main repo + these packages, but I think that's likely easiest once the API is refactored and the app itself is using these client calls.

@@ -42,7 +43,7 @@ export default function buildQueryObject<T extends QueryFormData>(formData: T):
metrics: processMetrics(formData),
order_desc: typeof order_desc === 'undefined' ? true : order_desc,
orderby: [],
row_limit: Number(row_limit),
row_limit: row_limit == null || isNaN(numericRowLimit) ? undefined : numericRowLimit,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use Number.isNaN, instead of isNaN 

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!

ktmud added a commit to ktmud/superset-ui that referenced this pull request Apr 27, 2020
ktmud added a commit to ktmud/superset-ui that referenced this pull request Apr 27, 2020
ktmud added a commit to ktmud/superset-ui that referenced this pull request Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants