mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-09 17:23:22 +03:00
[PR #530] [MERGED] refactor: switch SQLite driver to pure-Go implementation #748
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/pocket-id/pocket-id/pull/530
Author: @ItalyPaleAle
Created: 5/14/2025
Status: ✅ Merged
Merged: 5/14/2025
Merged by: @stonith404
Base:
main← Head:sqlite-pure-go📝 Commits (3)
794bc0crefactor: switch SQLite driver to pure-Go implementation7a50f1bDisable CGO4534fa6Update scan📊 Changes
8 files changed (+248 additions, -23 deletions)
View changed files
📝
Dockerfile(+1 -1)📝
backend/go.mod(+13 -5)📝
backend/go.sum(+46 -8)📝
backend/internal/bootstrap/db_bootstrap.go(+54 -4)➕
backend/internal/bootstrap/db_bootstrap_test.go(+121 -0)📝
backend/internal/common/env_config.go(+1 -1)📝
backend/internal/model/types/date_time.go(+11 -3)📝
backend/internal/service/app_config_service_test.go(+1 -1)📄 Description
This PR changes the driver used to connect to SQLite to
github.com/glebarez/sqlite.The main difference with the previous driver (
gorm.io/driver/sqlite) is that the new one uses a pure-Go implementation of SQLite based onmodernc.org/sqlite.There are three main benefits with making this change:
The pure-Go driver is slightly slower, more noticeable with very large databases, larger than Pocket ID users are expected to have.
The
modernc.org/sqlitepackage is built by "transpiling" the C library into Go code, and they have extensive test suites to ensure the behavior is consistent. The same package is used by many apps successfully in production, so stability shouldn't be a concern.The "biggest" user-facing change is that
github.com/mattn/go-sqlite3supports some additional args in the query string which need to be converted to PRAGMA statements with themodernc.org/sqlitepackage. To avoid confusing users (and potentially introducing yet another breaking change), I've added a function that converts the common query string args into the format supported by the modernc package. Most users would not need to worry about it, as wery few should change the DB connection string.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.