Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unknown value type for bind (insert) #1

Closed
dmitrykim opened this issue Jan 12, 2012 · 4 comments
Closed

unknown value type for bind (insert) #1

dmitrykim opened this issue Jan 12, 2012 · 4 comments

Comments

@dmitrykim
Copy link

First thank you very much for nice ORM, now it's one of the most documented DB libraries for Go and one of a few up-to-date.

Go's native type "bool" is not supported. Consider this:

type PersistentUser struct {
Key int32
Id string
PassedTraining bool
}

this code will panic (panic: unknown value type for bind)

pu := &PersistentUser{43,"33r",false}

// Insert your rows
err := dbmap.Insert(pu)
if err!=nil {
panic(err)
}

Windows 7/x86, MySql 5.1, Go weekly.2011-12-22 11071

@coopernurse
Copy link
Contributor

Hi there,

are you using mymysql as your exp/sql driver? If so, there's a patch I submitted to that project that is required to map bool values. This patch also pools prepared statements, which is important to avoid running out of prepared statement handles in mysql.

ziutek/mymysql#5

also, there are probably some other issues you'll run into with gorp if you're using the weekly. I have a pending patch into the exp/sql project that is needed to define all the Nullable types:

http://codereview.appspot.com/5534048/

@coopernurse
Copy link
Contributor

Oh, by the way, in my local environment, your test above passes. So I think the problem is probably due to one of the two issues above (probably the bool marshalling). Here's my test code:

// this passes for me
func TestPersistentUser(t *testing.T) {
    dbmap := &DbMap{Db: connect(), Dialect: dialect}
    dbmap.TraceOn("", log.New(os.Stdout, "gorptest: ", log.Lmicroseconds))
    table := dbmap.AddTable(PersistentUser{}).SetKeys(false, "Key")
    table.ColMap("Key").Rename("mykey")
    err := dbmap.CreateTables()
    if err != nil {
        panic(err)
    }
    pu := &PersistentUser{43,"33r",false}
    err = dbmap.Insert(pu)
    if err!=nil {
        panic(err)
    }
}  

@dmitrykim
Copy link
Author

Thank you for the two links, will use them for now. Yes I was using https://github.com/ziutek/mymysql .

@dmitrykim
Copy link
Author

Fix of ziutek/mymysql#5 fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants