Gorm: Issues with MySQL

Created on 5 May 2016  路  2Comments  路  Source: go-gorm/gorm

With the following struct I got the error:
[2016-05-05 21:10:16] using unaddressable value

type Channel struct {
    ID          uint   `gorm:"primary_key"`
    ChannelID   string `json:"channel_id"`
    Group       string `json:"group"`
    Image       bool   `json:"image"`
    IsAtsc      bool   `json:"is_atsc"`
    IsCable     bool   `json:"is_cable"`
    IsRadio     bool   `json:"is_radio"`
    IsSat       bool   `json:"is_sat"`
    IsTerr      bool   `json:"is_terr"`
    Name        string `json:"name"`
    Number      int    `json:"number"`
    Stream      string `json:"stream"`
    Transponder int    `json:"transponder"`
}

If I drop the ID column and use gorm.Model instead I got:
[2016-05-05 21:50:18] Error 1292: Incorrect datetime value: '0000-00-00' for column 'created_at' at row 1

Also I noticed that I got some issues with boolean, the mysql column was creates wit TINYINT(1) but it failes with given "true" or "false"

Maybe the mysql driver isn't that ready yet? Or did I something wrong?

Do you recommend to use sqlite instead?

Any ideas?

Most helpful comment

you need to use pointer of value like db.Save(&User{})

All 2 comments

I just tried sqlite, but still the same...
Weird, hmm then I will proceed without an ORM for now.

you need to use pointer of value like db.Save(&User{})

Was this page helpful?
0 / 5 - 0 ratings

Related issues

satb picture satb  路  3Comments

izouxv picture izouxv  路  3Comments

fieryorc picture fieryorc  路  3Comments

kumarsiva07 picture kumarsiva07  路  3Comments

Ganitzsh picture Ganitzsh  路  3Comments