GORM Playground Link

https://github.com/go-gorm/playground/pull/1

Description

gorm v1.30.5 give error into method Count

gorm.GE.Count undefined (type gorm.Interface[E] has no field or method Count) (compiler MissingFieldOrMethod)

code production

func (r *BaseRepository[E, I]) List(ctx context.Context, limit, offset int) ([]*E, int64, error) {
    count, err := gorm.G[E](r.db).Count(ctx, "id")
    if err != nil {
        return nil, 0, err
    }

    entities, err := gorm.G[*E](r.db).Offset(offset).Limit(limit).Find(ctx)
    if err != nil {
        return nil, 0, err
    }

    return entities, count, nil
}

before v1.30.5 no error on v1.30.3 using API Generics

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: T4cC0re

I can confirm this

g := gorm.G[T](db)
var _ gorm.ChainInterface[T] = g
var _ gorm.Interface[T] = g

Should not produce a compiler error, but since 1.30.5 it does:

cannot use g (variable of interface type gorm.Interface[T]) as gorm.ChainInterface[T] value in variable declaration: gorm.Interface[T] does not implement gorm.ChainInterface[T] (missing method Count)
cannot use g (variable of interface type gorm.Interface[T]) as gorm.ChainInterface[T] value in struct literal: gorm.Interface[T] does not implement gorm.ChainInterface[T] (missing method Count)

Testing with 1.30.3 the code compiles, as expected.

Comment From: T4cC0re

It seems the ExecInterface replacement here from #7578 broke this

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: T4cC0re

Raised a pull request here with a sample: https://github.com/go-gorm/playground/pull/827