Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subquery v2.7.4 version has probelem SHOW FULL COLUMNS FROM settle_balance #3880

Open
lala0257 opened this issue Oct 22, 2024 · 3 comments
Open
Assignees
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@lala0257
Copy link

Go version

go1.22.2 windows/amd64

GoFrame version

github.com/gogf/gf/[email protected]

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

mysql 驱动 github.com/gogf/gf/contrib/drivers/mysql/[email protected]

image
image

What did you see happen?

新版本还是有该问题呢,是不是哪里我没弄对

What did you expect to see?

不该有 SHOW FULL COLUMNS FROM settle_balance

@lala0257 lala0257 added the bug It is confirmed a bug, but don't worry, we'll handle it. label Oct 22, 2024
@gqcn gqcn self-assigned this Oct 24, 2024
@gqcn
Copy link
Member

gqcn commented Oct 24, 2024

@lala0257 您好,麻烦提供一下可复现该问题的,最小可运行完整代码呢,包含sql,我们运行复现一下。谢谢。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@lala0257 Hello, please provide us with the minimum executable complete code that can reproduce this problem, including sql. Let's run it to reproduce it. Thanks.

@lala0257
Copy link
Author

lala0257 commented Oct 25, 2024

package test

import (
	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
	"github.com/gogf/gf/v2/frame/g"
	"testing"
)

func TestSubQuery1(t *testing.T) {
	subQuery := g.Model("merchants").Fields("settle_account, settle_balance").Group("settle_account")
	total, err := g.Model("? as u", subQuery).Sum("settle_balance")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(total)
}

func TestSubQuery2(t *testing.T) {
	subQuery := g.Model("merchants").Fields("DISTINCT(settle_account), settle_balance")
	TotalRegularBalance, err := g.Model("? as u", subQuery).Sum("settle_balance")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(TotalRegularBalance)
}
`
`
CREATE TABLE `merchants` (
  `id` bigint UNSIGNED NOT NULL,
  `merchant_no` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户编号',
  `merchant_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '商户名称',
  `settle_account` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '商户结算账户',
  `settle_balance` decimal(20,2) NOT NULL DEFAULT '0.00' COMMENT '商户结算账户余额',
  `sys_status` tinyint NOT NULL DEFAULT '0' COMMENT '系统状态:0-正常 1-注销',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

3 participants