Fix: Get函数在赋值时未给定Table对象,无法按预期对deleted条件merge #2457

Open
laoqiu wants to merge 1 commits from laoqiu/xorm:v1 into v1
First-time contributor

Find在未给到Table对象时,仍然是按预期,把deleted字段进行了merge,但get方法却没有,会导致查询的时候出现非预期的bug。

单元测试如下:

func TestDeleted(t *testing.T) {
	var (
		ids    []int64
		lastid int64
	)
	db.Table(new(Account)).Select(`id`).Get(&lastid)
	db.Table(new(Account)).Select(`id`).Limit(10).Find(&ids)
}

===========================

[xorm] [info] 2024/04/30 15:34:44.983531 [SQL] SELECT id FROM account LIMIT 1 [] - 3.373954ms
[xorm] [info] 2024/04/30 15:34:44.985408 [SQL] SELECT id FROM account WHERE deleted_at=? LIMIT 10 [0] - 1.621701ms

Find在未给到Table对象时,仍然是按预期,把deleted字段进行了merge,但get方法却没有,会导致查询的时候出现非预期的bug。 单元测试如下: ``` func TestDeleted(t *testing.T) { var ( ids []int64 lastid int64 ) db.Table(new(Account)).Select(`id`).Get(&lastid) db.Table(new(Account)).Select(`id`).Limit(10).Find(&ids) } ``` =========================== [xorm] [info] 2024/04/30 15:34:44.983531 [SQL] SELECT id FROM account LIMIT 1 [] - 3.373954ms [xorm] [info] 2024/04/30 15:34:44.985408 [SQL] SELECT id FROM account WHERE deleted_at=? LIMIT 10 [0] - 1.621701ms
laoqiu added 1 commit 2024-04-30 10:27:26 +00:00
Fix: Get函数在赋值时未给定Table对象,无法按预期对deleted条件merge
Some checks failed
test cockroach / test cockroach (pull_request) Has been cancelled
test mariadb / test mariadb (pull_request) Has been cancelled
test mssql / test mssql with collation (pull_request) Has been cancelled
test mssql / test mssql (pull_request) Has been cancelled
test mysql / test mysql (pull_request) Has been cancelled
test mysql8 / test mysql8 (pull_request) Has been cancelled
test postgres / test postgres (pull_request) Has been cancelled
test sqlite / unit test & test sqlite (pull_request) Has been cancelled
test tidb / test tidb (pull_request) Has been cancelled
43dc0fe9b5
laoqiu changed title from Fix: Get函数在赋值时未给定Table对象,无法按预期对deleted条件merge to WIP: Fix: Get函数在赋值时未给定Table对象,无法按预期对deleted条件merge 2024-04-30 10:30:14 +00:00
laoqiu changed title from WIP: Fix: Get函数在赋值时未给定Table对象,无法按预期对deleted条件merge to Fix: Get函数在赋值时未给定Table对象,无法按预期对deleted条件merge 2024-04-30 10:30:38 +00:00
Some checks failed
test cockroach / test cockroach (pull_request) Has been cancelled
Required
Details
test mariadb / test mariadb (pull_request) Has been cancelled
Required
Details
test mssql / test mssql with collation (pull_request) Has been cancelled
Required
Details
test mssql / test mssql (pull_request) Has been cancelled
Required
Details
test mysql / test mysql (pull_request) Has been cancelled
Required
Details
test mysql8 / test mysql8 (pull_request) Has been cancelled
Required
Details
test postgres / test postgres (pull_request) Has been cancelled
Required
Details
test sqlite / unit test & test sqlite (pull_request) Has been cancelled
Required
Details
test tidb / test tidb (pull_request) Has been cancelled
Required
Details
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u v1:laoqiu-v1
git checkout laoqiu-v1
Sign in to join this conversation.
No description provided.