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

update fails to find table #415

Open
tcurdt opened this issue Feb 27, 2020 · 0 comments
Open

update fails to find table #415

tcurdt opened this issue Feb 27, 2020 · 0 comments

Comments

@tcurdt
Copy link

tcurdt commented Feb 27, 2020

This is the table

CREATE TABLE "t_foo" (
"a" INTEGER NOT NULL,
"b" TEXT NOT NULL,
"name" TEXT
)

Here is the struct

type Foo struct {
  A    uint64 `db:"a"`
  B    string `db:"b"`
  Name string `db:"name"`
}

It's setup like this:

dbmap.AddTableWithName(Foo{}, "t_foo").SetKeys(false, "a", "b")

The select works just fine

foo := Foo{}
err = dbm.SelectOne(&foo,
  "select * from t_foo where a=? and b=? limit 1",
  1,
  "xyz",
)

but when I then do an update

_, err = dbm.Update(&foo)
if err != nil {
  ...
}

I am getting an error no table found for type: .

I tried to turn on the logging but I didn't even see the update statement.

dbmap.TraceOn("[gorp]", log.New(os.Stdout, "indie:", log.Lmicroseconds))

Turns out the problem was super simple: foo was already a reference and not a value.

Is there any way to improve the error message?

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

1 participant