-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 problems with local libSQL DB #12089
Conversation
🦋 Changeset detectedLatest commit: c5a5e52 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -451,7 +451,7 @@ async function getDbCurrentSnapshot( | |||
|
|||
return JSON.parse(res.snapshot); | |||
} catch (error: any) { | |||
if (error.code === 'SQLITE_UNKNOWN') { | |||
if (error.code === 'SQLITE_UNKNOWN' || (error.code === 'SQLITE_ERROR' && error.rawCode === 1)) { |
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.
It's worth leaving a comment here and explaining the check. The comment should explain:
- why
SQLITE_ERROR
? - why
rawCode === 1
?
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.
Ok, I went to the source code to understand the error codes. It turns out the rawCode
adds nothing here; it is just the numeric value of the enum while code
is the name of the value. code: 'SQLITE_ERROR'
will always come with rawCode: 1
.
Also, SQLITE_ERROR
is a generic error code used for multiple things. We'll have to check the message to ensure we only capture the error code we care about.
We'll still need to check for both codes because the library throws two errors when reading a non-existing table:
- Connected to a remote DB it throws with the code
SQLITE_UNKNOWN
and messageSQLITE_UNKNOWN: SQLite error: no such table: some_table
- Connected to an in-memory or a local file DB it throws with the code
SQLITE_ERROR
and messageSQLITE_ERROR: no such table: some_table
I'll change the code to properly reflect that.
Changes
Testing
Docs
The new behavior matches the documentation