go-gorm / clickhouse

GORM clickhouse driver
MIT License
250 stars 72 forks source link

CreateInBatches Error #196

Closed aixj1984 closed 1 month ago

aixj1984 commented 1 month ago

GORM Playground Link

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

Description

    type TestModel struct {
        LogID     int64     `gorm:"column:log_id;primaryKey;type:UInt64"  json:"logID"`
        CreatedAt time.Time `json:"createdAt"`
        UpdatedAt time.Time `json:"updatedAt"`
    }
       var arr []*TestModel
    for i := 0; i < 10; i++ {
        newObj := &TestModel{
            CreatedAt: time.Now(),
            UpdatedAt: time.Now(),
            LogID:     int64(i),
        }
        arr = append(arr, newObj)
    }

    db.CreateInBatches(arr, 10000)

Error Msg : clickhouse [AppendRow]: converting clause.Expr to UInt64 is unsupported

aixj1984 commented 1 month ago

log_id clickhouse [AppendRow]: converting clause.Expr to UInt64 is unsupported [16.795ms] [rows:0] INSERT INTO test_models (created_at,updated_at,log_id) VALUES ('2024-10-10 11:21:18.341','2024-10-10 11:21:18.341',DEFAULT)

aixj1984 commented 1 month ago

因为primaryKey导致的