Find和FindAndCount条件参数部分字段失效 #1665

Closed
opened 2020-04-26 07:36:50 +00:00 by xiaoming · 0 comments
type Tech struct {
	Base       `xorm:"extends"`
	// Phone      string   `json:"phone" validate:"required" xorm:"varchar(16) not null"`
	Name       string   `json:"name" xorm:"varchar(8) not null"`
}

type TechParams struct {
	Phone string `url:"phone"`
	Pages `xorm:"extends"`
}

func GetTech(params TechParams) ([]Tech, int64, error) {
	list := make([]Tech, 0)
	count, err := db.OrderBy("created_at desc").Limit(params.Size, params.Page).FindAndCount(&list, params)
	return list, count, err
}

注释了Techphone字段后phone条件失效。


type Part struct {
	Base       `xorm:"extends"`
	Phone      string   `json:"phone" validate:"required" xorm:"varchar(16) not null"`
	Name       string   `json:"name" xorm:"varchar(8) not null"`
}

type Tech struct {
	Part `xorm:"extends"`
}

type TechParams struct {
	Phone string `url:"phone"`
	Pages `xorm:"extends"`
}

使用extends也有类似的条件失效情况。

```golang type Tech struct { Base `xorm:"extends"` // Phone string `json:"phone" validate:"required" xorm:"varchar(16) not null"` Name string `json:"name" xorm:"varchar(8) not null"` } type TechParams struct { Phone string `url:"phone"` Pages `xorm:"extends"` } func GetTech(params TechParams) ([]Tech, int64, error) { list := make([]Tech, 0) count, err := db.OrderBy("created_at desc").Limit(params.Size, params.Page).FindAndCount(&list, params) return list, count, err } ``` 注释了`Tech`的`phone`字段后phone条件失效。 - - - ```golang type Part struct { Base `xorm:"extends"` Phone string `json:"phone" validate:"required" xorm:"varchar(16) not null"` Name string `json:"name" xorm:"varchar(8) not null"` } type Tech struct { Part `xorm:"extends"` } type TechParams struct { Phone string `url:"phone"` Pages `xorm:"extends"` } ``` 使用extends也有类似的条件失效情况。
lunny added this to the 1.0.2 milestone 2020-04-26 08:47:25 +00:00
lunny added the
kind
enhancement
label 2020-04-26 08:47:33 +00:00
lunny closed this issue 2020-04-26 11:34:09 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1665
No description provided.