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

expected 'IDENT', found '[' (and 1 more errors) #1145

Closed
kinboyw opened this issue May 7, 2024 · 1 comment
Closed

expected 'IDENT', found '[' (and 1 more errors) #1145

kinboyw opened this issue May 7, 2024 · 1 comment

Comments

@kinboyw
Copy link

kinboyw commented May 7, 2024

GORM Playground Link

go-gorm/playground#1

Description

When the return value type of the custom query method in the Model Interface is set to *[]gen.T, the generated code reports an error. The document clearly states that the return value type is allowed to be set to *[]gen.T.

doc

return value

type Querier interface {
  // SELECT * FROM @@table WHERE id=@id
  GetByID(id int) (gen.T, error) // returns struct and error

  // SELECT * FROM @@table WHERE id=@id
  GetByID(id int) gen.T // returns data as struct

  // SELECT * FROM @@table WHERE id=@id
  GetByID(id int) (gen.M, error) // returns map and error

   // INSERT INTO @@table (name, age) VALUES (@name, @age)
  InsertValue(name string, age int) (gen.RowsAffected, error) // returns affected rows count and error
}

version

  • gorm.io/gen v0.3.26
  • gorm.io/gorm v1.25.9

code

type PolicyMethod interface {
	//where(kind=@kind)
	ListByKind(kind string) (*[]gen.T, error)
}

error

/internal/dal/mf_policy.gen.go:209:39: expected 'IDENT', found '[' (and 1 more errors)
204     UnderlyingDB() *gorm.DB
205     schema.Tabler
206 
207     GetByID(id int) (result *model.Policy,err error)
208     ListByKind(kind string) (result *gen.[]T,err error)
209 
210 }
@qqxhb
Copy link
Member

qqxhb commented Aug 9, 2024

maybe []*gen.T

@qqxhb qqxhb closed this as completed Aug 9, 2024
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

No branches or pull requests

2 participants