-
Notifications
You must be signed in to change notification settings - Fork 361
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: loading of duckdb every query #4903
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Just a few relatively minor comments.
const data = results.toArray() | ||
setData(data) | ||
setError(null) | ||
|
||
}).catch(e => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're mixing paradigms. .catch
is Promise syntax and async-await
is a different approach. If you're using async-await
, you should use plain old try-catch-finally
. That's the idea of async-await
- writing sync-style code, and abstracting away all of the Promise handling, continuation, error handling, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
let content; | ||
let button = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO something along these lines would be cleaner and more readable.
let button = ( | |
const button = ( | |
<Button type="submit" variant="success" disabled={loading}> | |
<DatabaseIcon /> {" "} | |
{ loading ? "Executing..." : "Execute" } | |
</Button> | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! used.
e.preventDefault() | ||
setShouldSubmit(!shouldSubmit) | ||
}}> | ||
<Form onSubmit={handleSubmit}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like! 🤩
<Form.Control as="textarea" className="object-viewer-sql-input" rows={5} value={query} spellCheck={false} onChange={e => { | ||
setQuery(e.target.value) | ||
}} /> | ||
<Form.Control as="textarea" className="object-viewer-sql-input" rows={5} defaultValue={initialQuery} spellCheck={false} ref={sql} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's something you want, but maybe add autocomplete={false}
, so the native browser autocomplete thing doesn't pop up (unless you want. that, of course)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added!
</Form> | ||
<div className={"mt-3 object-viewer-sql-results"}> | ||
<div className={"mt-3"}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure there's a need for the curly braces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix the duckDB wasm package being downloaded on every query (as well as a few minor tweaks to the UX of running said queries)