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
Empty get/all results in process termination #1
Comments
Current workaround: using 'query' instead |
@yoavain can you present a single case where using |
There are 2 reason I don't use
My use case is using the DB as cache. |
I don't understand this statement ... this project uses
And that's exactly what you get here. In few words, Until that, neither issues would be worked on as there's no issue to fix and no example to test to me. |
I have tried using try {
const row = await get`SELECT * from ${schema}.${lyricsTable} WHERE artist=${artist} AND title=${title}`;
return row && row.lyrics;
}
catch (e) {
return null;
} (artist+title is the primary key) The problem is that if the row does not exist in the DB, and you use JSON.parse() on it, the child process sends a terminates event, which terminate the NodeJS process. (The try/catch doesn't help since the crash is from a child process) |
@yoavain beside the fact I have just published a fix, because indeed no results throws errors, watch out you cannot write this: get`SELECT * from ${schema}.${lyricsTable} WHERE artist=${artist} AND title=${title}`
// ^^^^^^^^^^^^^^^^^^^^^^^^ that's a SQL injection hazard ... you need to use the Anyway, this bug has been fixed, next one please write a test case right away to save time to ourselves ;-) |
When get/all returns with 0 rows,
result
equals "".The parse in the next line then throws an error, which I think is still part of the spawned process and can't be caught by the caller.
Maybe should just return an empty result instead of exit the process.
The text was updated successfully, but these errors were encountered: