Skip to content

Commit 101df98

Browse files
authored
eorm: 支持分库分表最简单的 ShardingSelector (#145)
1 parent f57e3af commit 101df98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2336
-127
lines changed

.CHANGELOG.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
## 开发中
2-
- [eorm: Distinct功能](https://github.com/ecodeclub/eorm/pull/116)
3-
- [eorm: aop方案的支持](https://github.com/ecodeclub/eorm/pull/117)
4-
- [eorm: 利用 aop 接口打印 SQL](https://github.com/ecodeclub/eorm/pull/123)
5-
- [eorm: 插入忽略主键](https://github.com/ecodeclub/eorm/pull/126)
6-
- [eorm: join查询](https://github.com/ecodeclub/eorm/pull/122)
7-
- [eorm: 重构 JOIN 查询](https://github.com/ecodeclub/eorm/pull/130)
8-
- [eorm: 新增子查詢](https://github.com/ecodeclub/eorm/pull/131)
9-
- [eorm: 取消支持 Having 中使用 alias](https://github.com/ecodeclub/eorm/pull/135)
10-
- [eorm: 删除 IsAutoIncrement 字段](https://github.com/ecodeclub/eorm/pull/136)
11-
- [eorm: 删除 IsHolderType](https://github.com/ecodeclub/eorm/pull/137)
12-
- [eorm: MasterSlaveDB实现](https://github.com/ecodeclub/eorm/pull/146)
13-
- [eorm: 重构 Update 语句忽略零值和Nil](https://github.com/ecodeclub/eorm/pull/138)
2+
- [eorm: Distinct功能](https://github.com/gotomicro/eorm/pull/116)
3+
- [eorm: aop方案的支持](https://github.com/gotomicro/eorm/pull/117)
4+
- [eorm: 利用 aop 接口打印 SQL](https://github.com/gotomicro/eorm/pull/123)
5+
- [eorm: 插入忽略主键](https://github.com/gotomicro/eorm/pull/126)
6+
- [eorm: join查询](https://github.com/gotomicro/eorm/pull/122)
7+
- [eorm: 重构 JOIN 查询](https://github.com/gotomicro/eorm/pull/130)
8+
- [eorm: 新增子查詢](https://github.com/gotomicro/eorm/pull/131)
9+
- [eorm: 取消支持 Having 中使用 alias](https://github.com/gotomicro/eorm/pull/135)
10+
- [eorm: 删除 IsAutoIncrement 字段](https://github.com/gotomicro/eorm/pull/136)
11+
- [eorm: 删除 IsHolderType](https://github.com/gotomicro/eorm/pull/137)
12+
- [eorm: MasterSlaveDB实现](https://github.com/gotomicro/eorm/pull/146)
13+
- [eorm: 重构 Update 语句忽略零值和Nil](https://github.com/gotomicro/eorm/pull/138)
14+
- [eorm: 新增 ShardingSelector 实现](https://github.com/gotomicro/eorm/pull/145)
1415
- [eorm: 基于dns的slave发现](https://github.com/ecodeclub/eorm/pull/152)
1516

17+
1618
## v0.0.1:
1719
- [Init Project](https://github.com/ecodeclub/eorm/pull/1)
1820
- [Selector Definition](https://github.com/ecodeclub/eorm/pull/2)

.LICENSE_FILE_HEADER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2021 ecodehub
1+
Copyright 2021 ecodeclub
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

.licenserc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"**/*.go": "// Copyright 2021 ecodehub",
2+
"**/*.go": "// Copyright 2021 ecodeclub",
33
"**/*.{yml,toml}": "# Copyright 2021 ecodeclub"
44
}

aggregate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 ecodehub
1+
// Copyright 2021 ecodeclub
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

aggregate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 ecodehub
1+
// Copyright 2021 ecodeclub
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

assignment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 ecodehub
1+
// Copyright 2021 ecodeclub
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

assignment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 ecodehub
1+
// Copyright 2021 ecodeclub
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

builder.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 ecodehub
1+
// Copyright 2021 ecodeclub
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -23,20 +23,10 @@ import (
2323
"github.com/valyala/bytebufferpool"
2424
)
2525

26-
// QueryBuilder is used to build a query
27-
type QueryBuilder interface {
28-
Build() (*Query, error)
29-
}
30-
3126
var _ Executor = &Inserter[any]{}
3227
var _ Executor = &Updater[any]{}
3328
var _ Executor = &Deleter[any]{}
3429

35-
// Executor is used to build a query
36-
type Executor interface {
37-
Exec(ctx context.Context) Result
38-
}
39-
4030
// Query 代表一个查询
4131
type Query struct {
4232
SQL string
@@ -109,6 +99,18 @@ func (q Querier[T]) Get(ctx context.Context) (*T, error) {
10999
return res.Result.(*T), nil
110100
}
111101

102+
type selectorBuilder struct {
103+
builder
104+
columns []Selectable
105+
where []Predicate
106+
distinct bool
107+
having []Predicate
108+
groupBy []string
109+
orderBy []OrderBy
110+
offset int
111+
limit int
112+
}
113+
112114
type builder struct {
113115
core
114116
// 使用 bytebufferpool 以减少内存分配

builder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 ecodehub
1+
// Copyright 2021 ecodeclub
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

column.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 ecodehub
1+
// Copyright 2021 ecodeclub
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)