Skip to content

Releases: pardnchiu/go-sqlite

v1.1.0

29 Jan 10:25

Choose a tag to compare

v1.0.0 -> v1.1.0

Summary

Add automatic struct/slice binding for query results via Bind() method and introduce Last() method for retrieving the last row.

翻譯

新增 Bind() 方法支援查詢結果自動綁定至 struct/slice,並新增 Last() 方法取得最後一筆資料。

Changes

FEAT

  • Add Bind(target) method to automatically map query results to struct or slice using reflection
  • Add Last() method for retrieving the last row based on current ordering
  • Add WithBind field to Builder struct for storing bind target
翻譯
  • 新增 Bind(target) 方法,透過 reflection 將查詢結果自動映射至 struct 或 slice
  • 新增 Last() 方法,根據目前排序取得最後一筆資料
  • Builder struct 新增 WithBind 欄位用於儲存綁定目標

REFACTOR

  • Refactor First() method to reverse sort order (ASC→DESC, DESC→ASC) for correct "first" semantics
  • Extract get() helper function from Get() to separate query execution from result binding
  • Add find(), findSlice(), findRow(), scanTarget(), getPattern() helper functions for struct mapping
翻譯
  • 重構 First() 方法,反轉排序順序(ASC→DESC、DESC→ASC)以符合「第一筆」語意
  • Get() 抽離 get() 輔助函式,分離查詢執行與結果綁定
  • 新增 find()findSlice()findRow()scanTarget()getPattern() 輔助函式處理 struct 映射

UPDATE

  • Update builderClear() to reset WithBind and Error fields
翻譯
  • 更新 builderClear() 以重置 WithBindError 欄位

Files Changed

File Status Tag
core/interface.go Modified FEAT
core/select.go Modified FEAT
core/select_ext.go Modified FEAT, REFACTOR
core/builder.go Modified UPDATE
README.md Modified DOC
README.zh.md Modified DOC

Generated by Claude Code

v1.0.0

29 Jan 03:07

Choose a tag to compare

v0.5.0 -> v1.0.0

Summary

Major internal refactor introducing read/write connection pool separation for improved high-concurrency performance, along with removal of deprecated API methods.

翻譯

重大內部重構,引入讀寫分離連線池架構以優化高併發場景效能,同時移除已棄用的 API 方法。

Changes

REFACTOR

  • Restructure connection architecture to separate read and write connection pools for optimized concurrent access
  • Update Connector to expose Read and Write *Builder fields directly instead of DB(key) method
  • Simplify configuration by removing Key parameter, using single database path model
  • Update default pool settings: MaxOpenConns=50, MaxIdleConns=25, Lifetime=120
  • Reorganize README documentation to reflect new API patterns
翻譯
  • 重構連線架構為讀寫分離連線池,優化併發存取效能
  • 更新 Connector 直接暴露 ReadWrite *Builder 欄位,取代 DB(key) 方法
  • 簡化配置移除 Key 參數,採用單一資料庫路徑模式
  • 更新預設連線池設定:MaxOpenConns=50MaxIdleConns=25Lifetime=120
  • 重新整理 README 文件以反映新 API 模式

REMOVE

  • Remove all deprecated methods from deprecated.go:
    • InsertContext, InsertReturningID, InsertContextReturningID
    • InsertConflict, InsertContexConflict, InsertConflictReturningID, InsertContextConflictReturningID
    • GetContext, GetWithTotal, GetWithTotalContext
    • FirstContext, CountContext, UpdateContext
  • Remove corresponding test cases from core_test.go
翻譯
  • deprecated.go 移除所有已棄用方法:
    • InsertContextInsertReturningIDInsertContextReturningID
    • InsertConflictInsertContexConflictInsertConflictReturningIDInsertContextConflictReturningID
    • GetContextGetWithTotalGetWithTotalContext
    • FirstContextCountContextUpdateContext
  • core_test.go 移除對應的測試案例

Files Changed

File Status Tag
core/connector.go Modified REFACTOR
core/builder.go Modified REFACTOR
core/interface.go Modified REFACTOR
instance.go Modified REFACTOR
core/deprecated.go Modified REMOVE
core/core_test.go Modified REMOVE
main_test.go Modified REFACTOR
README.md Modified DOC
README.zh.md Modified DOC
.gitignore Modified CHORE
cover.png Modified CHORE

Generated by Claude Code

v0.5.0

28 Jan 17:51

Choose a tag to compare

v0.4.0 -> v0.5.0

Summary

Major refactoring to extract core logic into a dedicated core package with unified public API, plus new batch insert functionality and improved error handling mechanism that collects validation errors for deferred return.

翻譯 大幅重構專案,將核心邏輯抽離至獨立 core 套件並統一對外 API,新增批次插入功能,並改進錯誤處理機制,將驗證錯誤收集後延遲回傳。

Changes

FEAT

  • Add InsertBatch method for batch inserting multiple records in a single query
翻譯
  • 新增 InsertBatch 方法,支援單一查詢批次插入多筆記錄

REFACTOR

  • Extract core logic into core package with unified public API
  • Export Builder struct fields (e.g., dbDB, tableTableName, whereListWhereList)
  • Export utility functions (validateColumnValidateColumn, formatValueFormatValue)
  • Unify error handling mechanism: collect validation errors in Builder.Error slice and defer return at execution time
  • Move buildWhere function from select.go to select_where.go
翻譯
  • 將核心邏輯抽離至 core 套件並統一對外 API
  • 匯出 Builder struct 欄位(如 dbDBtableTableNamewhereListWhereList
  • 匯出工具函式(validateColumnValidateColumnformatValueFormatValue
  • 統一錯誤處理機制:將驗證錯誤收集至 Builder.Error 切片,於執行時延遲回傳
  • buildWhere 函式從 select.go 移至 select_where.go

UPDATE

  • Update all Where/Having/Update methods to collect errors into Builder.Error instead of silently ignoring invalid columns
  • Add error checking at the beginning of all terminal methods (Insert, Update, Delete, Get, First, Count)
翻譯
  • 更新所有 Where/Having/Update 方法,將錯誤收集至 Builder.Error 而非靜默忽略無效欄位
  • 在所有終端方法(Insert、Update、Delete、Get、First、Count)開頭加入錯誤檢查

ADD

  • Add core/connector.go for database connection management
  • Add core/interface.go for type definitions (Config, Connector, Builder, Where, Join, Column, etc.)
  • Add core/select_ext.go for First() and Count() methods
  • Add core/select_having.go and core/select_or_having.go for HAVING clause support
翻譯
  • 新增 core/connector.go 用於資料庫連線管理
  • 新增 core/interface.go 用於型別定義(Config、Connector、Builder、Where、Join、Column 等)
  • 新增 core/select_ext.go 用於 First() 與 Count() 方法
  • 新增 core/select_having.gocore/select_or_having.go 用於 HAVING 子句支援

Files Changed

File Status Tag
core/builder.go Renamed from builder.go REFACTOR
core/connector.go Added ADD
core/deprecated.go Renamed from deprecated.go REFACTOR
core/insert.go Added FEAT
core/interface.go Added ADD
core/select.go Renamed from select.go REFACTOR
core/select_ext.go Added ADD
core/select_having.go Added ADD
core/select_or_having.go Added ADD
core/select_or_where.go Renamed from select_or_where.go REFACTOR
core/select_where.go Renamed from select_where.go REFACTOR
core/sql_keywords.json Renamed from sql_keywords.json REFACTOR
core/update.go Renamed from update.go REFACTOR
core/utils.go Renamed from utils.go REFACTOR
insert.go Deleted REMOVE
instance.go Modified REFACTOR
main_test.go Modified TEST
select_ext.go Deleted REMOVE
select_having.go Deleted REMOVE
select_or_having.go Deleted REMOVE
type.go Deleted REMOVE

Generated by Claude Code

v0.4.0

28 Jan 15:09

Choose a tag to compare

v0.3.0 -> v0.4.0

Summary

Added GROUP BY and HAVING clause support, refactored Delete method validation and reorganized codebase with dedicated type definitions and deprecated method files.

翻譯 新增 GROUP BY 與 HAVING 子句支援,重構 Delete 方法驗證邏輯,並將型別定義與已棄用方法分離至獨立檔案。

Changes

FEAT

  • Add GROUP BY clause support for aggregate queries
  • Add HAVING clause support with Having() and OrHaving() methods
翻譯
  • 新增 GROUP BY 子句支援,用於聚合查詢
  • 新增 HAVING 子句支援,提供 Having()OrHaving() 方法

REFACTOR

  • Move unsupported clause validation (JOIN, GROUP BY, HAVING, ORDER BY, LIMIT/OFFSET) to execution time in Delete method
  • Remove invalid SQL construction from Delete that generated unusable queries
  • Extract deprecated methods to dedicated deprecated.go file
  • Consolidate type definitions (Builder, Where, Join, Column, Foreign, Union, Config, Connector, conflict) into type.go
翻譯
  • 將 Delete 方法的不支援子句驗證(JOIN, GROUP BY, HAVING, ORDER BY, LIMIT/OFFSET)移至執行前
  • 移除 Delete 中產生無效 SQL 的建構邏輯
  • 抽離已棄用方法至獨立的 deprecated.go 檔案
  • 集中型別定義(Builder, Where, Join, Column, Foreign, Union, Config, Connector, conflict)至 type.go

Files Changed

File Status Tag
select_having.go Added FEAT
select_or_having.go Added FEAT
type.go Added REFACTOR
deprecated.go Added REFACTOR
builder.go Modified REFACTOR
select.go Modified FEAT
select_ext.go Modified FEAT
insert.go Modified REFACTOR
instance.go Modified REFACTOR
main_test.go Modified TEST
README.md Modified DOC
README.zh.md Modified DOC
update.go Modified REFACTOR

Generated by Claude Code

v0.3.0

28 Jan 11:04

Choose a tag to compare

v0.2.0 -> v0.3.0

Summary

Added Delete method and refactored API to use chainable Context pattern, unifying Insert/Update return values for consistency.

翻譯 新增 Delete 方法並重構 API 為鏈式 Context 模式,統一 Insert/Update 回傳值以提升一致性。

Changes

FEAT

  • Add Delete(force ...bool) method for row deletion with optional force flag for unprotected deletes
  • Add Context(ctx context.Context) chainable method for context propagation
翻譯
  • 新增 Delete(force ...bool) 方法,支援強制刪除選項
  • 新增 Context(ctx context.Context) 鏈式方法支援 Context 傳遞

REFACTOR

  • Unify Insert() to return (int64, error) with LastInsertId instead of just error
  • Unify Update() to return (int64, error) with RowsAffected instead of (sql.Result, error)
  • Extract SQL building logic into independent methods: buildJoin(), buildOrderBy(), buildLimit(), buildOffset()
  • Add ExecAutoAsignContext() helper to automatically use context when available
  • Move Where() and OrWhere() to dedicated files for better organization
翻譯
  • 統一 Insert() 回傳 (int64, error) 含 LastInsertId
  • 統一 Update() 回傳 (int64, error) 含 RowsAffected,取代原本的 (sql.Result, error)
  • 抽取 SQL 構建邏輯為獨立方法:buildJoin()buildOrderBy()buildLimit()buildOffset()
  • 新增 ExecAutoAsignContext() 輔助方法自動使用 Context
  • Where()OrWhere() 移至專屬檔案以改善程式碼組織

UPDATE

  • Mark legacy Context methods as deprecated: InsertContext(), InsertReturningID(), InsertContextReturningID(), InsertConflict(), InsertContexConflict(), InsertConflictReturningID(), InsertContextConflictReturningID(), GetContext(), GetWithTotal(), GetWithTotalContext(), FirstContext(), CountContext(), UpdateContext()
  • Remove deprecated insertBuilderConflict() internal function
翻譯
  • 標記舊版 Context 方法為 Deprecated:InsertContext()InsertReturningID()InsertContextReturningID()InsertConflict()InsertContexConflict()InsertConflictReturningID()InsertContextConflictReturningID()GetContext()GetWithTotal()GetWithTotalContext()FirstContext()CountContext()UpdateContext()
  • 移除已棄用的 insertBuilderConflict() 內部函式

Files Changed

File Status Tag
builder.go Modified FEAT
insert.go Modified REFACTOR
select.go Modified REFACTOR
select_ext.go Modified REFACTOR
select_where.go Modified REFACTOR
select_or_where.go Modified REFACTOR
update.go Modified REFACTOR
main_test.go Modified TEST
README.md Modified DOC
README.zh.md Modified DOC

Generated by Claude Code

v0.2.0

27 Jan 19:21

Choose a tag to compare

v0.1.0 -> v0.2.0

Summary

Major refactoring of the database connector with singleton pattern using sync.Once, enhanced SQL validation with reserved keyword checking, and new chainable APIs for conflict handling and total count queries.

翻譯

重構資料庫連線器為單例模式並使用 sync.Once 確保初始化,強化 SQL 驗證加入保留字檢查,以及新增衝突處理與總數查詢的鏈式 API。

Changes

FEAT

  • Add GetWithTotal() and GetWithTotalContext() methods for paginated queries with total count
  • Add Builder.Raw() method to access underlying *sql.DB instance
  • Add Builder.Conflict() chainable method for insert conflict handling strategy
翻譯
  • 新增 GetWithTotal()GetWithTotalContext() 方法支援含總數的分頁查詢
  • 新增 Builder.Raw() 方法取得底層 *sql.DB 實例
  • 新增 Builder.Conflict() 鏈式方法處理 Insert 衝突策略

REFACTOR

  • Rename Database struct to Connector with singleton initialization via sync.Once
  • Simplify New() return signature from (*Database, *sql.DB, error) to (*Connector, error)
  • Refactor OrderBy direction parameter to typed constant (Asc/Desc)
  • Enhance column validation with length limit (128 chars) and SQL reserved keyword checking via embedded JSON
  • Adjust connection pool settings: MaxOpenConns=8, MaxIdleConns=2, enable WAL mode
翻譯
  • Database 結構重新命名為 Connector,使用 sync.Once 確保單例初始化
  • 簡化 New() 回傳值從 (*Database, *sql.DB, error) 改為 (*Connector, error)
  • 重構 OrderBy 方向參數為型別常數(Asc/Desc
  • 強化欄位驗證:加入長度限制(128 字元)與 SQL 保留字檢查(透過嵌入 JSON)
  • 調整連線池設定:MaxOpenConns=8MaxIdleConns=2,啟用 WAL 模式

UPDATE

  • Change Update() / UpdateContext() parameter to variadic map[string]any
  • Mark legacy conflict methods (InsertConflict, InsertContexConflict, InsertConflictReturningID, InsertContextConflictReturningID) as deprecated for v1.0.0
  • Mark Total() method as deprecated in favor of GetWithTotal()
翻譯
  • 修改 Update() / UpdateContext() 參數為可變長度 map[string]any
  • 標記舊版衝突方法(InsertConflict 等)將於 v1.0.0 棄用
  • 標記 Total() 方法即將棄用,改用 GetWithTotal()

Files Changed

File Status Tag
instance.go Modified REFACTOR
builder.go Modified FEAT
select.go Modified FEAT, REFACTOR
insert.go Modified FEAT, UPDATE
update.go Modified UPDATE
utils.go Modified REFACTOR
sql_keywords.json Added REFACTOR
main_test.go Modified REFACTOR
README.md Modified DOC
README.zh.md Added DOC
LICENSE Added DOC
cover.png Added DOC

Generated by Claude Code

v0.1.0

27 Jan 14:43

Choose a tag to compare

v0.0.0 -> v0.1.0

Summary

Initial release of go-sqlite, a lightweight SQLite ORM built on sqlite3 driver and database/sql, featuring connection pool management, schema builder, and a fluent query builder API consistent with go-mysql.

翻譯 go-sqlite 初始版本發布,基於 sqlite3 驅動與 database/sql 建構的輕量級 SQLite ORM,提供連線池管理、Schema Builder 與流暢的查詢建構器 API,與 go-mysql 保持一致的介面設計。

Changes

FEAT

  • Add connection pool management with configurable lifetime and automatic key derivation from path
  • Add Schema Builder with Create() method supporting columns, primary keys, auto-increment, unique constraints, defaults, and foreign keys
  • Add Insert methods: Insert(), InsertContext(), InsertReturningID(), InsertContextReturningID()
  • Add conflict handling strategies: InsertConflict() with IGNORE/REPLACE/ABORT/FAIL/ROLLBACK modes
  • Add ON CONFLICT DO UPDATE support for upsert operations
  • Add Select query builder: Select(), Where(), OrWhere(), Join(), LeftJoin(), OrderBy(), Limit(), Offset()
  • Add query execution methods: Get(), GetContext() returning *sql.Rows
  • Add convenience methods: First(), FirstContext(), Count(), CountContext()
  • Add Total() with window function (COUNT(*) OVER()) for pagination with total count
  • Add Update methods: Update(), UpdateContext() with map-based data
  • Add column modifiers: Increase(), Decrease(), Toggle() for atomic updates
  • Add raw query wrappers: Database.Query(), Database.QueryContext(), Database.Exec(), Database.ExecContext()
翻譯
  • 新增連線池管理,支援可配置的連線存活時間與自動從路徑推導 key
  • 新增 Schema Builder 的 Create() 方法,支援欄位定義、主鍵、自動遞增、唯一約束、預設值與外鍵
  • 新增 Insert 方法:Insert()InsertContext()InsertReturningID()InsertContextReturningID()
  • 新增衝突處理策略:InsertConflict() 支援 IGNORE/REPLACE/ABORT/FAIL/ROLLBACK 模式
  • 新增 ON CONFLICT DO UPDATE 支援 upsert 操作
  • 新增 Select 查詢建構器:Select()Where()OrWhere()Join()LeftJoin()OrderBy()Limit()Offset()
  • 新增查詢執行方法:Get()GetContext() 回傳 *sql.Rows
  • 新增便捷方法:First()FirstContext()Count()CountContext()
  • 新增 Total() 視窗函式 (COUNT(*) OVER()) 支援分頁與總數查詢
  • 新增 Update 方法:Update()UpdateContext() 支援 map 資料更新
  • 新增欄位修改器:Increase()Decrease()Toggle() 支援原子更新
  • 新增原始查詢包裝:Database.Query()Database.QueryContext()Database.Exec()Database.ExecContext()

REFACTOR

  • Split single-file structure into modular components: instance.go, builder.go, insert.go, select.go, select_ext.go, select_where.go, select_or_where.go, update.go, utils.go
  • Extract column validation and quoting logic into utils.go with validateColumn() and quote()
  • Unify ForeignKey as struct type (Foreign) for cleaner API
  • Add automatic Builder state clearing after query execution via builderClear()
  • Remove test main function and strengthen nil checks with ping verification on connection
翻譯
  • 將單檔結構拆分為模組化元件:instance.go、builder.go、insert.go、select.go、select_ext.go、select_where.go、select_or_where.go、update.go、utils.go
  • 將欄位驗證與引號邏輯抽離至 utils.go,提供 validateColumn()quote()
  • 統一 ForeignKey 為結構型別 (Foreign) 以簡化 API
  • 新增查詢執行後自動清除 Builder 狀態的 builderClear()
  • 移除測試用 main 函式,強化連線初始化的 nil check 與 ping 驗證

Files Changed

File Status Tag
instance.go Added FEAT
builder.go Added FEAT
insert.go Added FEAT
select.go Added FEAT
select_ext.go Added FEAT
select_where.go Added FEAT
select_or_where.go Added FEAT
update.go Added FEAT
utils.go Added REFACTOR
main_test.go Added TEST
README.md Added DOC
.gitignore Modified CHORE
main.go Deleted REMOVE

Generated by Claude Code