Closed goxiaoy closed 1 year ago
One thing I'm not sure to note here is that, from my understanding gorm.Statement.Parse would only run in local cache, and won't talk to DB, right?
That's true.
But if it is not true, we might need to consider parsing schema at somewhere only once, and maybe caching it on paginator instance.
This is implemented by gorm internally by DB.cacheStore
, see
https://github.com/go-gorm/gorm/blob/c3d7d08b9a9f861e53e8b194fcc6b7cedc4191e1/schema/schema.go#L304-L309
Nice, learn a lot from this PR. 🙌 All looks good to me. I will prepare a new version after merging.
@goxiaoy I just released v2.4.0 to include your changes. Thanks again for the contribution, it helps a lot 🙌
And sorry about that I didn't aware debug mode generating too many messages that interferes development and testing, so I disable it by default. You can enable it for local debug at will, but just skip committing it to the repo 😃
SQLKey is hard coded as snake case, but GORM has configuration
NamingStrategy
This pr useschema.LookUpField(key).DBName
to get database name of key fieldsee https://gorm.io/docs/gorm_config.html#NamingStrategy