Giter Site home page Giter Site logo

Primary key data type about beedb HOT 3 CLOSED

astaxie avatar astaxie commented on August 27, 2024
Primary key data type

from beedb.

Comments (3)

astaxie avatar astaxie commented on August 27, 2024

i found it is a bug, thanks, i will fix it next week

from beedb.

astaxie avatar astaxie commented on August 27, 2024

i think this problem today, i find some problems
orm.Save(&thing)
i have to distinguish wherther it is insert or update
if you set a string pk,then if you use save function maybe always update.And if i support string then insert return LastInsertId will error. So now it's hard to support Primary key for other data type

from beedb.

chinakr avatar chinakr commented on August 27, 2024

我也遇到了类似的错误。如果没有if err != nil { orm = initDb() }这部分代码,就有可能出现reflect: call of reflect.Value.Set on zero Value beedb这个错误。如果有这部分代码,就不会出错了,但是原因我还没想明白。谢大能给看一下吗?

// 把微博数据保存到数据库
func saveWeibos(apiWeibos ApiWeiboList) {
    orm := initDb()
    for _, apiWeibo := range(apiWeibos.Statuses) {
        weibo := Weibo{}
        err := orm.Where("wid=?", apiWeibo.Id).Find(&weibo)    // 更新或新建记录
        //Check(err)
        if err != nil {    // No record found
            orm = initDb()
        }
        weibo.Wid = apiWeibo.Id
        weibo.Text = apiWeibo.Text
        weibo.Created = getTime(apiWeibo.Created_At)
        err = orm.Save(&weibo)
        Check(err)
        Debug("Weibo %d(%v) saved.", weibo.Wid, weibo.Created)
    }
}

from beedb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.