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

fix: Add MAX_SQL_ROW value to LIMIT_DROPDOWN #12555

Merged
merged 1 commit into from
Jan 15, 2021
Merged
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
10 changes: 6 additions & 4 deletions superset-frontend/src/SqlLab/components/SqlEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,13 @@ class SqlEditor extends React.PureComponent {
}

renderQueryLimit() {
const menuDropdown = (
// Adding SQL_MAX_ROW value to dropdown
const { maxRow } = this.props;
Copy link
Member

Choose a reason for hiding this comment

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

can we add some tests and check if maxRow is undefined? Will it print "undefined" as an option?

LIMIT_DROPDOWN.push(maxRow);

return (
<AntdMenu>
{LIMIT_DROPDOWN.map(limit => (
{[...new Set(LIMIT_DROPDOWN)].map(limit => (
Copy link
Member

Choose a reason for hiding this comment

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

I'm not familiar with Set in Javascript, but in Python they're not ordered. Will this affect the order of the elements?

Copy link
Member

Choose a reason for hiding this comment

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

Set does not order its contents, just makes sure they're unique, and adds them in the order they're added to the set. So this implementation should not affect the order of the contents of LIMIT_DROPDOWN.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, @rusackas!

Copy link
Member

Choose a reason for hiding this comment

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

For the record, JavaScript sets are ordered: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#iteration_methods

Set iterators returns items in insertion order.

<AntdMenu.Item onClick={() => this.setQueryLimit(limit)}>
{/* // eslint-disable-line no-use-before-define */}
<a role="button" styling="link">
Expand All @@ -551,8 +555,6 @@ class SqlEditor extends React.PureComponent {
))}
</AntdMenu>
);

return menuDropdown;
}

renderEditorBottomBar() {
Expand Down