Skip to content

Commit 7f74e49

Browse files
committed
feat: Add Limit/Offset API + Comprehensive ai_application docs fix (v0.10.1)
🚀 New Features - ✨ Add Limit(int) API: Simple query pagination without Paged() - ✨ Add Offset(int) API: Skip records for manual pagination - 🛡️ Paged() Priority Protection: Web pagination auto-overrides Limit/Offset to prevent conflicts 📚 Comprehensive Documentation Fixes (ai_application/ directory, 70+ locations) - 🔧 API Usage Corrections (50+ locations) - ToQdrantSearch() → Build().ToQdrantJSON() - WithLimit()/WithScoreThreshold() → functional parameters - VectorSearch() parameter order fixes - BuildInsert() call fixes - 🧹 Remove Unnecessary Checks (16 locations) - Remove `if username != ""` redundant checks - Leverage sqlxb's 9-layer auto-filtering - 🎯 Like() Usage Fixes (2 locations) - "%"+keyword+"%" → keyword (auto-add wildcards) - LikeLeft() semantic fix: keyword% not %keyword - 🔗 GitHub Username Fixes (14 locations) - yourusername → x-ream - 🏷️ Type Fixes (3 locations) - DocID int64 → DocID *int64 (support nil) ✅ Tests - Add limit_offset_test.go (7 tests) - All tests pass - 100% backward compatible 📋 Related Documentation - Update doc/ROADMAP_v1.0.0.md - Fix 10 ai_application/ docs - AGENT_TOOLKIT.md - QUICKSTART.md - PERFORMANCE.md - NL2SQL.md - LANGCHAIN_INTEGRATION.md - LLAMAINDEX_INTEGRATION.md - SEMANTIC_KERNEL_INTEGRATION.md - RAG_BEST_PRACTICES.md - FAQ.md - README.md 🎯 Impact - ✅ Fully backward compatible - ✅ Simplified API usage (auto-filtering + Limit/Offset) - ✅ Improved documentation quality (clearer AI application scenarios) --- Co-authored-by: Claude (Anthropic)
1 parent b3188e7 commit 7f74e49

22 files changed

+5712
-353
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ Quick links:
118118
- [Custom JOINs Guide](./doc/CUSTOM_JOINS_GUIDE.md) - 扩展自定义 JOIN
119119
- [Contributors](./doc/CONTRIBUTORS.md)
120120

121+
**AI Application Ecosystem**:
122+
- **[AI Application Docs →](./doc/ai_application/README.md)** - Complete AI/RAG/Agent integration guide
123+
- [AI Agent Toolkit](./doc/ai_application/AGENT_TOOLKIT.md) - JSON Schema, OpenAPI
124+
- [RAG Best Practices](./doc/ai_application/RAG_BEST_PRACTICES.md) - Document retrieval guide
125+
- [LangChain Integration](./doc/ai_application/LANGCHAIN_INTEGRATION.md) - Python LangChain
126+
- [Performance Optimization](./doc/ai_application/PERFORMANCE.md) - AI app tuning
127+
121128
## Contributing
122129

123130
Contributors are welcomed to join the sqlxb project. <br>

builder_x.go

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package sqlxb
1818

1919
import (
2020
"fmt"
21+
2122
"github.com/x-ream/sqlxb/interceptor"
2223
)
2324

@@ -43,8 +44,10 @@ type BuilderX struct {
4344
isDistinct bool
4445
isWithoutOptimization bool
4546

46-
alia string
47-
meta *interceptor.Metadata // ⭐ 新增:元数据(v0.9.2)
47+
alia string
48+
limitValue int // ⭐ 新增:LIMIT 值(v0.10.1)
49+
offsetValue int // ⭐ 新增:OFFSET 值(v0.10.1)
50+
meta *interceptor.Metadata // ⭐ 新增:元数据(v0.9.2)
4851
}
4952

5053
// Meta 获取元数据
@@ -265,6 +268,24 @@ func (x *BuilderX) Paged(f func(pb *PageBuilder)) *BuilderX {
265268
return x
266269
}
267270

271+
// Limit 设置返回记录数量(适用于简单查询,非分页场景)
272+
// 支持 PostgreSQL 和 MySQL
273+
func (x *BuilderX) Limit(limit int) *BuilderX {
274+
if limit > 0 {
275+
x.limitValue = limit
276+
}
277+
return x
278+
}
279+
280+
// Offset 设置跳过记录数量(通常与 Limit 配合使用)
281+
// 支持 PostgreSQL 和 MySQL
282+
func (x *BuilderX) Offset(offset int) *BuilderX {
283+
if offset > 0 {
284+
x.offsetValue = offset
285+
}
286+
return x
287+
}
288+
268289
func (x *BuilderX) Last(last string) *BuilderX {
269290
x.last = last
270291
return x
@@ -316,18 +337,20 @@ func (x *BuilderX) Build() *Built {
316337
x.optimizeFromBuilder()
317338

318339
built := Built{
319-
ResultKeys: x.resultKeys,
320-
Updates: x.updates,
321-
Conds: x.bbs,
322-
Sorts: x.sorts,
323-
Aggs: x.aggs,
324-
Havings: x.havings,
325-
GroupBys: x.groupBys,
326-
Last: x.last,
327-
OrFromSql: x.orFromSql,
328-
Fxs: x.sxs,
329-
Svs: x.svs,
330-
Meta: x.meta, // ⭐ 传递元数据
340+
ResultKeys: x.resultKeys,
341+
Updates: x.updates,
342+
Conds: x.bbs,
343+
Sorts: x.sorts,
344+
Aggs: x.aggs,
345+
Havings: x.havings,
346+
GroupBys: x.groupBys,
347+
Last: x.last,
348+
OrFromSql: x.orFromSql,
349+
Fxs: x.sxs,
350+
Svs: x.svs,
351+
LimitValue: x.limitValue, // ⭐ 传递 Limit
352+
OffsetValue: x.offsetValue, // ⭐ 传递 Offset
353+
Meta: x.meta, // ⭐ 传递元数据
331354
}
332355

333356
if x.pageBuilder != nil {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
feat: 新增 Limit/Offset API + 全面修复 ai_application 文档 (v0.10.1)
2+
3+
🚀 新增功能
4+
- ✨ 新增 Limit(int) API:简单查询分页,无需 Paged()
5+
- ✨ 新增 Offset(int) API:跳过记录数,支持手动分页
6+
- 🛡️ Paged() 优先级保护:Web 分页自动覆盖 Limit/Offset,防止冲突
7+
8+
📚 文档全面修复(ai_application/ 目录,70+ 处)
9+
- 🔧 API 用法修正(50+ 处)
10+
- ToQdrantSearch() → Build().ToQdrantJSON()
11+
- WithLimit()/WithScoreThreshold() → 函数式参数
12+
- VectorSearch() 参数顺序修正
13+
- BuildInsert() 调用修正
14+
- 🧹 移除不必要判断(16 处)
15+
- 删除 `if username != ""` 等冗余判断
16+
- 利用 sqlxb 9 层自动过滤机制
17+
- 🎯 Like() 用法修正(2 处)
18+
- "%"+keyword+"%" → keyword(自动添加通配符)
19+
- LikeLeft() 语义修正:keyword% 而非 %keyword
20+
- 🔗 GitHub 用户名修正(14 处)
21+
- yourusername → x-ream
22+
- 🏷️ 类型修正(3 处)
23+
- DocID int64 → DocID *int64(支持 nil)
24+
25+
✅ 测试
26+
- 新增 limit_offset_test.go(7 个测试)
27+
- 所有测试通过
28+
- 100% 向后兼容
29+
30+
📋 相关文档
31+
- 更新 doc/ROADMAP_v1.0.0.md
32+
- 修复 ai_application/ 9 个文档
33+
- AGENT_TOOLKIT.md
34+
- QUICKSTART.md
35+
- PERFORMANCE.md
36+
- NL2SQL.md
37+
- LANGCHAIN_INTEGRATION.md
38+
- LLAMAINDEX_INTEGRATION.md
39+
- SEMANTIC_KERNEL_INTEGRATION.md
40+
- RAG_BEST_PRACTICES.md
41+
- FAQ.md
42+
- README.md
43+
44+
🎯 影响
45+
- ✅ 完全向后兼容
46+
- ✅ 简化 API 使用(自动过滤 + Limit/Offset)
47+
- ✅ 提升文档质量(AI 应用场景更清晰)
48+
49+
---
50+
Co-authored-by: Claude (Anthropic)
51+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
feat: Add Limit/Offset API + Comprehensive ai_application docs fix (v0.10.1)
2+
3+
🚀 New Features
4+
- ✨ Add Limit(int) API: Simple query pagination without Paged()
5+
- ✨ Add Offset(int) API: Skip records for manual pagination
6+
- 🛡️ Paged() Priority Protection: Web pagination auto-overrides Limit/Offset to prevent conflicts
7+
8+
📚 Comprehensive Documentation Fixes (ai_application/ directory, 70+ locations)
9+
- 🔧 API Usage Corrections (50+ locations)
10+
- ToQdrantSearch() → Build().ToQdrantJSON()
11+
- WithLimit()/WithScoreThreshold() → functional parameters
12+
- VectorSearch() parameter order fixes
13+
- BuildInsert() call fixes
14+
- 🧹 Remove Unnecessary Checks (16 locations)
15+
- Remove `if username != ""` redundant checks
16+
- Leverage sqlxb's 9-layer auto-filtering
17+
- 🎯 Like() Usage Fixes (2 locations)
18+
- "%"+keyword+"%" → keyword (auto-add wildcards)
19+
- LikeLeft() semantic fix: keyword% not %keyword
20+
- 🔗 GitHub Username Fixes (14 locations)
21+
- yourusername → x-ream
22+
- 🏷️ Type Fixes (3 locations)
23+
- DocID int64 → DocID *int64 (support nil)
24+
25+
✅ Tests
26+
- Add limit_offset_test.go (7 tests)
27+
- All tests pass
28+
- 100% backward compatible
29+
30+
📋 Related Documentation
31+
- Update doc/ROADMAP_v1.0.0.md
32+
- Fix 10 ai_application/ docs
33+
- AGENT_TOOLKIT.md
34+
- QUICKSTART.md
35+
- PERFORMANCE.md
36+
- NL2SQL.md
37+
- LANGCHAIN_INTEGRATION.md
38+
- LLAMAINDEX_INTEGRATION.md
39+
- SEMANTIC_KERNEL_INTEGRATION.md
40+
- RAG_BEST_PRACTICES.md
41+
- FAQ.md
42+
- README.md
43+
44+
🎯 Impact
45+
- ✅ Fully backward compatible
46+
- ✅ Simplified API usage (auto-filtering + Limit/Offset)
47+
- ✅ Improved documentation quality (clearer AI application scenarios)
48+
49+
---
50+
Co-authored-by: Claude (Anthropic)
51+

0 commit comments

Comments
 (0)