steebchen / prisma-client-go

Prisma Client Go is an auto-generated and fully type-safe database client
https://goprisma.org
Apache License 2.0
2.05k stars 96 forks source link

Select undefined (type db.modelFindMany has no field or method Select) #1260

Closed komarapc closed 2 months ago

komarapc commented 2 months ago

Select is undefined

func GetAllPost() ([]db.PostModel, error) {
    client := db.NewClient()
    posts, _ := client.Post.FindMany().Select(db.Post.Title.Field()).Exec(context.Background())
    return posts, nil
}
steebchen commented 2 months ago

Thanks, looking into it. Is the error coming from the code above or from the generated db_gen.go? Can you please also share your Go client version and your Prisma schema? Thanks!

kusaljr commented 2 months ago

Same issue encountered using version: github.com/steebchen/prisma-client-go v0.36.0 @steebchen

steebchen commented 2 months ago

@kusaljr can you please share your schema, thank you 🙏

kusaljr commented 2 months ago

I'm using the default schema from documentation

datasource db {
    // could be postgresql or mysql
    provider = "sqlite"
    url      = "file:dev.db"
}

generator db {
    provider = "go run github.com/steebchen/prisma-client-go"
}

model Post {
    id        String   @id @default(cuid())
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt
    title     String
    published Boolean
    desc      String?
}
image

@steebchen

steebchen commented 2 months ago

You need to be on v0.37.0

kusaljr commented 2 months ago

@steebchen problem using v0.37.0 on same schema

image

I'm using M2, go version go1.22.3 darwin/arm64

steebchen commented 2 months ago

Hmm that's weird, can you please open a new issue? Thanks.