Skip to content

Commit

Permalink
Merge pull request #18 from LanceAdd/main
Browse files Browse the repository at this point in the history
[LanceAdd]GoFrame ORM WhereBuilder Support
  • Loading branch information
johnmai-dev authored Aug 21, 2024
2 parents da98734 + 753b1e7 commit 99334fc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.idea
.qodana
build
.DS_Store
.DS_Store
.intellijPlatform
14 changes: 14 additions & 0 deletions example/goframe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,17 @@ func test5() {
query = query.Where("id = ?", "")
return
}

func test6() {
model := g.Model(&User{})
condition := model.Builder()
condition = condition.Where("id IN ?", g.Slice{1, 2, 3, 4})

// @Table(user)
condition = condition.WhereOr(`id IN ?`, g.Slice{1, 2, 3, 4})

condition = condition.WhereOr("user_name = ?", "zhangsan")

// @Model(User)
condition = condition.WhereGT("age", 11)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,35 @@ public interface GoFrameTypes {
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.Model).WhereOrNotIn"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.Model).WhereOrNotNull"), -1),

// @Doc https://goframe.org/pages/viewpage.action?pageId=7301832#ORM%E6%9F%A5%E8%AF%A2Where/WhereOr/WhereNot-WhereBuilder%E5%A4%8D%E6%9D%82%E6%9D%A1%E4%BB%B6%E7%BB%84%E5%90%88
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).Where"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).Wheref"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereBetween"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereLike"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereIn"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereNull"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereLT"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereLTE"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereGT"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereGTE"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereNotBetween"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereNotLike"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereNotIn"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereNotNull"), -1),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOr"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrBetween"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrLike"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrIn"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrNull"), -1),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrLT"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrLTE"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrGT"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrGTE"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrNotBetween"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrNotLike"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrNotIn"), 0),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOrNotNull"), -1),

// @Doc https://goframe.org/pages/viewpage.action?pageId=7301838
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.Model).All"), -1),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.Model).One"), -1),
Expand Down Expand Up @@ -121,11 +150,15 @@ public interface GoFrameTypes {
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.Model).FindValue"), Types.OPERATOR_EXPR),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.Model).FindCount"), Types.OPERATOR_EXPR),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.Model).FindScan"), Types.OPERATOR_EXPR),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.Model).Having"), Types.OPERATOR_EXPR)
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.Model).Having"), Types.OPERATOR_EXPR),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).Where"), Types.OPERATOR_EXPR),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).Wheref"), Types.OPERATOR_EXPR),
Map.entry(GoMethodDescriptor.of("(*github.com/gogf/gf/database/gdb.WhereBuilder).WhereOr"), Types.OPERATOR_EXPR)
);

Set<GoCallableDescriptor> ALLOW_TYPES = Set.of(
GoTypeSpecDescriptor.of("github.com/gogf/gf/database/gdb.Model")
GoTypeSpecDescriptor.of("github.com/gogf/gf/database/gdb.Model"),
GoTypeSpecDescriptor.of("github.com/gogf/gf/database/gdb.WhereBuilder")
);

GoTypeSpecDescriptor G_META = GoTypeSpecDescriptor.of("github.com/gogf/gf/frame/g.Meta");
Expand Down

0 comments on commit 99334fc

Please sign in to comment.