Skip to content

feat: support skip impl generation #1350

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

WqyJh
Copy link

@WqyJh WqyJh commented Jul 18, 2025

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Implement #1349

User Case Description

定义以下接口:

type TestSkipImpl interface {
	// gen:skip
	SkipMethod(id int) (gen.T, error)

	// NoSkipMethod
	// select * from users where id=@id
	NoSkipMethod(id int) (gen.T, error)
}

在生成的接口中会包含两个接口函数

type IUserDo interface {
	// ......
	SkipMethod(id int) (result model.User, err error)
	NoSkipMethod(id int) (result model.User, err error)
}

但是只会生成一个实现函数

// NoSkipMethod
// select * from users where id=@id
func (u userDo) NoSkipMethod(id int) (result model.User, err error) {
	var params []interface{}

	var generateSQL strings.Builder
	params = append(params, id)
	generateSQL.WriteString("select * from users where id=? ")

	var executeSQL *gorm.DB
	executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Take(&result) // ignore_security_alert
	err = executeSQL.Error

	return
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant