drizzle-team / drizzle-team/drizzle-orm
[BUG]: `libsql`: an ending `--> statement-breakpoint` causes `LibsqlError: SQLITE_OK: not an error` on migration
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
0.44.0
### What version of `drizzle-kit` are you using?
0.31.1
### Other packages
_No response_
### Describe the Bug
Hi!
`drizzle-kit migrate` throws `LibsqlError: SQLITE_OK: not an error` when running the migration against a SQLite database and if a migration file ends with a `--> statement-breakpoint` or if there's two or more consecutive breakpoints in a migration file.
I encountered this when I accidentally added a breakpoint after the last statement in a custom SQL migration file. It wasn't easy to figure out what causes this, to say the least! 😄
Here's a sample migration file to reproduce this behavior (a single statement is enough and the statement itself doesn't matter):
```sql
PRAGMA table_list;--> statement-breakpoint
```
Now running `drizzle-kit migrate` will produce this error:
```
LibsqlError: SQLITE_OK: not an error
at mapSqliteError (file:///home/zsolt/Nodim/Development/subtrakr/node_modules/@libsql/client/lib-esm/sqlite3.js:380:16)
at executeStmt (file:///home/zsolt/Nodim/Development/subtrakr/node_modules/@libsql/client/lib-esm/sqlite3.js:285:15)
at file:///home/zsolt/Nodim/Development/subtrakr/node_modules/@libsql/client/lib-esm/sqlite3.js:116:24
... 3 lines matching cause stack trace ...
at migrate (/home/zsolt/Nodim/Development/subtrakr/node_modules/src/libsql/migrator.ts:46:19) {
code: 'SQLITE_OK',
rawCode: 0,
[cause]: SqliteError: not an error
at convertError (/home/zsolt/Nodim/Development/subtrakr/node_modules/libsql/index.js:59:12)
at Statement.run (/home/zsolt/Nodim/Development/subtrakr/node_modules/libsql/index.js:333:13)
at executeStmt (file:///home/zsolt/Nodim/Development/subtrakr/node_modules/@libsql/client/lib-esm/sqlite3.js:278:34)
at file:///home/zsolt/Nodim/Development/subtrakr/node_modules/@libsql/client/lib-esm/sqlite3.js:116:24
at Array.map ()
at Sqlite3Client.migrate (file:///home/zsolt/Nodim/Development/subtrakr/node_modules/@libsql/client/lib-esm/sqlite3.js:112:38)
at LibSQLSession.migrate (/home/zsolt/Nodim/Development/subtrakr/node_modules/src/libsql/session.ts:104:42)
at migrate (/home/zsolt/Nodim/Development/subtrakr/node_modules/src/libsql/migrator.ts:46:19) {
code: 'SQLITE_OK',
rawCode: 0
}
}
```
Although you could say that technically you just shouldn't end the file with a breakpoint, I believe it should handle this gracefully.
I'm planning to submit a PR to fix this.
Cheers!
Zsolt
Contributor guide
Assessment
This issue has not been assessed yet.