Weichang Zha

Results 11 comments of Weichang Zha

**Root Cause:** The issue occurs because `PrepareStmt` is enabled, which triggers schema initialization during the first `First` query for a given model. Schema initialization internally requires a database connection. At...

@LUKIEYF I tested this issue in both SQLite (v3.39.4) and MySQL (v8.0.32) using GORM v1.25.5, and I was not able to reproduce the problem. In my test, I used AutoMigrate...

``` type ChatStreamReq { Query string `json:"query"` ConversationId string `json:"conversation_id,optional"` User string `json:"user,optional"` Inputs map[string]interface{} `json:"inputs,optional"` } type ChatStreamResp {} ``` @chowyu12 In Go-Zero's .api syntax: Do not use struct...

Can there be multiple "with" keywords? Or does it depend on where it is located?

In GORM, when you update a model with a primary key (e.g., `ID`), it automatically adds the primary key to the `WHERE` clause for performance optimization. This ensures only the...

Here's a simple approach: ### 1. **Globally Customize JSON Serialization** * Create a new type `Int64String` that wraps the `int64` type. * Implement the `MarshalJSON` method to convert the `int64`...

In GORM, if a struct already contains a non-zero primary key value, it will automatically add a `WHERE` clause using that primary key when executing queries like `First()`. This optimization...

[API documentation](https://gorm.io/docs/query.html) I found that this section is mentioned in the documentation, though it's not very prominent. ![Image](https://github.com/user-attachments/assets/76ec1abc-50fe-4a10-bc78-0433a30987bf) Do you have any recommendations for optimizing this design?

I think the key issue is that the primary key is automatically added as a condition during queries, which can be confusing. @jinzhu Maybe it would be better to add...