Skip to content

Commit b225dff

Browse files
committed
feat: v1.2.1 - 统一 Custom() 入口,删除 QdrantX()
🎯 核心改进:认知负担最小化 ## 新增功能 ### Builder 模式 - NewQdrantBuilder() - Qdrant 配置构建器 - NewMySQLBuilder() - MySQL 配置构建器 - 链式方法:HnswEf(), ScoreThreshold(), WithVector(), UseUpsert() 等 - 显式 .Build() 转换为 Custom ### Custom 默认值在 SELECT 中生效 - QdrantCustom.DefaultHnswEf 现在影响 SELECT 查询 - QdrantCustom.DefaultScoreThreshold 现在影响 SELECT 查询 - QdrantCustom.DefaultWithVector 现在影响 SELECT 查询 - 优先级:Custom 默认值 > 硬编码默认值 ## 删除功能 ### 完全移除 QdrantX() - qdrant_x.go 文件 - QdrantX() 方法 - QdrantBuilderX 结构 - 6 个相关测试文件 ### 删除过度设计 - CustomBuilder[T any] 泛型接口(无实际用途) ## API 变更 ### 统一配置入口 Before (v1.2.0): ```go // 两个入口(令人困惑) .Custom(...) // INSERT/UPDATE/DELETE .QdrantX(...) // SELECT ``` After (v1.2.1): ```go // 唯一入口(清晰明了) .Custom(NewQdrantBuilder()...Build()) // 所有操作 ``` ## 破坏性变更 ### 迁移指南 ```go // ❌ Old .QdrantX(func(qx *QdrantBuilderX) { qx.HnswEf(512).ScoreThreshold(0.8) }) // ✅ New .Custom( xb.NewQdrantBuilder(). HnswEf(512). ScoreThreshold(0.8). Build(), ) ``` ## 设计哲学 "Don't add concepts to solve problems" "Minimize human cognitive load - AI can remember complexity, humans cannot" ### 技术权衡 - Go 没有 Java 的 `? extends Custom` - 无法用泛型约束 Builder 类型 - 接受显式 .Build() 调用 - 换来统一的 API 和最低记忆成本 ## 测试 - 196 个测试全部通过 ✅ - 新增 QdrantBuilder 和 MySQLBuilder 测试 - 删除 QdrantX 相关测试 - 保持完整的测试覆盖 ## 文件变更 新增: - qdrant_builder_test.go - mysql_builder_test.go - qdrant_custom_priority_test.go 修改: - qdrant_custom.go (添加 QdrantBuilder) - mysql_custom.go (添加 MySQLBuilder) - to_qdrant_json.go (Custom 默认值应用) - CHANGELOG.md (v1.2.1 条目) 删除: - qdrant_x.go - qdrant_x_test.go - qdrant_xx_test.go - qdrant_compat_test.go - qdrant_recommend_test.go - qdrant_discover_test.go - qdrant_custom_select_test.go 净减少: 4 个文件 ## 用户只需记住 1. NewXxxBuilder() - 创建构建器 2. .Method() - 链式配置 3. .Build() - 构建配置 4. Custom() - 统一入口 4 个步骤,0 个例外,100% 一致性 --- xb - 迈向更完美!🚀
1 parent e8b73dd commit b225dff

18 files changed

+1172
-1214
lines changed

CHANGELOG.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,79 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.2.1] - 2025-01-XX
9+
10+
### 🎯 Ultimate API Simplification (Cognitive Load Minimization)
11+
12+
**Core Achievement**: One unified entry point for all database configurations.
13+
14+
### Added
15+
- **Builder Pattern**:
16+
- `NewQdrantBuilder()` - Fluent API for Qdrant configuration
17+
- `NewMySQLBuilder()` - Fluent API for MySQL configuration
18+
- Chain methods: `.HnswEf()`, `.ScoreThreshold()`, `.WithVector()`, `.UseUpsert()`, etc.
19+
- Explicit `.Build()` for type conversion
20+
21+
- **Custom Default Values in SELECT**:
22+
- `QdrantCustom.DefaultHnswEf` now affects SELECT queries
23+
- `QdrantCustom.DefaultScoreThreshold` now affects SELECT queries
24+
- `QdrantCustom.DefaultWithVector` now affects SELECT queries
25+
- Priority: Runtime params > Custom defaults > Hardcoded defaults
26+
27+
### Removed
28+
- **QdrantX() Method**: Eliminated to reduce API surface
29+
- `qdrant_x.go` - Entire file removed
30+
- `QdrantBuilderX` - No longer needed
31+
- All related tests removed (6 test files)
32+
- **Unused Generic Interface**: `CustomBuilder[T any]` removed (over-engineering)
33+
34+
### Changed
35+
- **Unified Configuration Entry**: All databases now use only `Custom()`
36+
```go
37+
// ✅ Before: Two entry points (confusing)
38+
.Custom(...) // for INSERT/UPDATE/DELETE
39+
.QdrantX(...) // for SELECT ???
40+
41+
// ✅ After: One entry point (clear)
42+
.Custom(NewQdrantBuilder()...Build()) // for ALL operations
43+
```
44+
45+
### Why This Matters
46+
47+
**Human Memory Cost Minimization**:
48+
- **Before**: Remember when to use `Custom()` vs `QdrantX()`
49+
- **After**: Always use `Custom()` - one rule, zero confusion
50+
51+
**Design Philosophy**:
52+
> "Don't add concepts to solve problems"
53+
> "Minimize human cognitive load - AI can remember complexity, humans cannot"
54+
55+
### Migration from v1.2.0
56+
57+
```go
58+
// ❌ Old way (v1.2.0)
59+
xb.Of(...).
60+
QdrantX(func(qx *QdrantBuilderX) {
61+
qx.HnswEf(512).ScoreThreshold(0.8)
62+
})
63+
64+
// ✅ New way (v1.2.1)
65+
xb.Of(...).
66+
Custom(
67+
xb.NewQdrantBuilder().
68+
HnswEf(512).
69+
ScoreThreshold(0.8).
70+
Build(),
71+
)
72+
```
73+
74+
### Tests
75+
- All existing tests pass
76+
- New tests for QdrantBuilder and MySQLBuilder
77+
- Comprehensive coverage maintained
78+
79+
---
80+
881
## [1.2.0] - 2025-01-XX
982

1083
### 🎨 Complete API Unification (Major Improvement over v1.1.0)

COMMIT_v1.2.1.txt

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
feat: v1.2.1 - 统一 Custom() 入口,删除 QdrantX()
2+
3+
🎯 核心改进:认知负担最小化
4+
5+
## 新增功能
6+
7+
### Builder 模式
8+
- NewQdrantBuilder() - Qdrant 配置构建器
9+
- NewMySQLBuilder() - MySQL 配置构建器
10+
- 链式方法:HnswEf(), ScoreThreshold(), WithVector(), UseUpsert() 等
11+
- 显式 .Build() 转换为 Custom
12+
13+
### Custom 默认值在 SELECT 中生效
14+
- QdrantCustom.DefaultHnswEf 现在影响 SELECT 查询
15+
- QdrantCustom.DefaultScoreThreshold 现在影响 SELECT 查询
16+
- QdrantCustom.DefaultWithVector 现在影响 SELECT 查询
17+
- 优先级:Custom 默认值 > 硬编码默认值
18+
19+
## 删除功能
20+
21+
### 完全移除 QdrantX()
22+
- qdrant_x.go 文件
23+
- QdrantX() 方法
24+
- QdrantBuilderX 结构
25+
- 6 个相关测试文件
26+
27+
### 删除过度设计
28+
- CustomBuilder[T any] 泛型接口(无实际用途)
29+
30+
## API 变更
31+
32+
### 统一配置入口
33+
34+
Before (v1.2.0):
35+
```go
36+
// 两个入口(令人困惑)
37+
.Custom(...) // INSERT/UPDATE/DELETE
38+
.QdrantX(...) // SELECT
39+
```
40+
41+
After (v1.2.1):
42+
```go
43+
// 唯一入口(清晰明了)
44+
.Custom(NewQdrantBuilder()...Build()) // 所有操作
45+
```
46+
47+
## 破坏性变更
48+
49+
### 迁移指南
50+
51+
```go
52+
// ❌ Old
53+
.QdrantX(func(qx *QdrantBuilderX) {
54+
qx.HnswEf(512).ScoreThreshold(0.8)
55+
})
56+
57+
// ✅ New
58+
.Custom(
59+
xb.NewQdrantBuilder().
60+
HnswEf(512).
61+
ScoreThreshold(0.8).
62+
Build(),
63+
)
64+
```
65+
66+
## 设计哲学
67+
68+
"Don't add concepts to solve problems"
69+
"Minimize human cognitive load - AI can remember complexity, humans cannot"
70+
71+
### 技术权衡
72+
73+
- Go 没有 Java 的 `? extends Custom`
74+
- 无法用泛型约束 Builder 类型
75+
- 接受显式 .Build() 调用
76+
- 换来统一的 API 和最低记忆成本
77+
78+
## 测试
79+
80+
- 196 个测试全部通过 ✅
81+
- 新增 QdrantBuilder 和 MySQLBuilder 测试
82+
- 删除 QdrantX 相关测试
83+
- 保持完整的测试覆盖
84+
85+
## 文件变更
86+
87+
新增:
88+
- qdrant_builder_test.go
89+
- mysql_builder_test.go
90+
- qdrant_custom_priority_test.go
91+
92+
修改:
93+
- qdrant_custom.go (添加 QdrantBuilder)
94+
- mysql_custom.go (添加 MySQLBuilder)
95+
- to_qdrant_json.go (Custom 默认值应用)
96+
- CHANGELOG.md (v1.2.1 条目)
97+
98+
删除:
99+
- qdrant_x.go
100+
- qdrant_x_test.go
101+
- qdrant_xx_test.go
102+
- qdrant_compat_test.go
103+
- qdrant_recommend_test.go
104+
- qdrant_discover_test.go
105+
- qdrant_custom_select_test.go
106+
107+
净减少: 4 个文件
108+
109+
## 用户只需记住
110+
111+
1. NewXxxBuilder() - 创建构建器
112+
2. .Method() - 链式配置
113+
3. .Build() - 构建配置
114+
4. Custom() - 统一入口
115+
116+
4 个步骤,0 个例外,100% 一致性
117+
118+
---
119+
120+
xb - 迈向更完美!🚀
121+

README.md

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,51 @@ or build condition sql for some orm framework, like [xorm](https://github.com/go
1313
also can build json for some json parameter db, like [Qdrant](https://github.com/qdrant/qdrant) ....
1414

1515

16-
> 🎉 **v1.2.0 Released**: Complete API Unification! One Insert/Update/Delete API for SQL and vector databases.
16+
> 🎉 **v1.2.1 Released**: Ultimate API Simplification! One `Custom()` entry point for all database configurations.
1717
1818
---
1919

20-
## 🚀 NEW: Unified CRUD API (v1.2.0)
20+
## 🚀 NEW: Builder Pattern + Unified Entry (v1.2.1)
2121

22-
**Unified abstraction for SQL and Vector Databases with database-specific features!**
22+
**One configuration entry for all databases - minimum cognitive load!**
2323

24-
**✨ New in v1.2.0**:
25-
- 🎯 **Complete API Unification** - One `Insert(func)` for SQL and vector databases
26-
- 📝 **No Extra Methods** - No InsertPoint, no Delete(), just the essentials
27-
- 🔧 **Smart Detection** - Custom automatically handles different data formats
28-
- 🏗️ **Extreme Simplicity** - Removed 5 preset functions, kept only basics
29-
- 📚 **Convenience Methods** - SqlOfUpsert(), SqlOfInsertIgnore() for common cases
24+
**✨ New in v1.2.1**:
25+
- 🎯 **Builder Pattern** - `NewQdrantBuilder()`, `NewMySQLBuilder()` for fluent configuration
26+
- 🔧 **Unified Entry** - Only `Custom()` for all operations (INSERT/UPDATE/DELETE/SELECT)
27+
- 📉 **Lower Cognitive Load** - Humans only remember ONE rule, not two
28+
- 🔗 **Chain Style** - `.HnswEf().ScoreThreshold().Build()` - fluent and readable
29+
- ♻️ **Config Reuse** - Builder pattern naturally supports reusing configurations
3030

3131
```go
32-
// MySQL UPSERT (v1.2.0) - 无需 Custom
32+
// Qdrant Vector Search (v1.2.1) - 统一的 Custom() 入口
33+
built := xb.Of(&CodeVector{}).
34+
Custom(
35+
xb.NewQdrantBuilder().
36+
HnswEf(512).
37+
ScoreThreshold(0.85).
38+
WithVector(false).
39+
Build(),
40+
).
41+
VectorSearch("embedding", queryVector, 10).
42+
Eq("language", "golang").
43+
Build()
44+
json, _ := built.JsonOfSelect()
45+
46+
// MySQL UPSERT (v1.2.1) - 统一的 Custom() 入口
3347
built := xb.Of(user).
48+
Custom(
49+
xb.NewMySQLBuilder().
50+
UseUpsert(true).
51+
Build(),
52+
).
3453
Insert(func(ib *xb.InsertBuilder) {
35-
ib.Set("id", user.ID).
36-
Set("name", user.Name).
54+
ib.Set("name", user.Name).
3755
Set("email", user.Email)
3856
}).
3957
Build()
40-
sql, args := built.SqlOfUpsert()
58+
sql, args := built.SqlOfInsert()
4159
// INSERT INTO users ... ON DUPLICATE KEY UPDATE ...
4260

43-
// Qdrant Vector Search (v1.2.0)
44-
built := xb.Of(&CodeVector{}).
45-
Custom(xb.NewQdrantCustom()).
46-
Eq("language", "golang").
47-
VectorSearch("embedding", queryVector, 10).
48-
QdrantX(func(qx *xb.QdrantBuilderX) {
49-
qx.HnswEf(512).ScoreThreshold(0.85) // 配置参数
50-
}).
51-
Build()
52-
json, _ := built.JsonOfSelect()
53-
5461
// Qdrant CRUD (v1.1.0) - 与 SQL 完全一致的 API
5562
// Insert
5663
built := xb.Of(&CodeVector{}).

0 commit comments

Comments
 (0)