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

PANIC table User has no column named FirstName #1

Closed
tablecell opened this issue Mar 18, 2021 · 2 comments
Closed

PANIC table User has no column named FirstName #1

tablecell opened this issue Mar 18, 2021 · 2 comments

Comments

@tablecell
Copy link

tablecell commented Mar 18, 2021

package main

import (
  "fmt"
  "time"
_ "github.com/mattn/go-sqlite3"

  "github.com/cxr29/huge"
_  "github.com/cxr29/huge/query"
  "github.com/cxr29/log"
)


type User struct {
    Id          int64     
    FirstName   string     
    LastName    string     
    Group       string      
}
func main() {
  n := &User{Id:1,FirstName:"aaa",LastName:"bbb",Group:"{bj:100}", }

  h, err := huge.Open("sqlite3", "user.db")
  log.ErrPanic(err)

  // CRUD row
  r, err := h.Create(n)
  log.ErrPanic(err)
  fmt.Println(r.(bool), n.Id, n.FirstName)
}
@cxr29
Copy link
Owner

cxr29 commented Apr 21, 2021

auto create table:

createTableSQL := huge.CreateTable(n, query.SQLiteStarter, false, true)
fmt.Println(createTableSQL)
_, err = h.Querier.Exec(createTableSQL)
log.ErrPanic(err)

@cxr29
Copy link
Owner

cxr29 commented Apr 21, 2021

sqlite driverName fixed:

  createTableSQL := huge.CreateTable(n, h.Starter, false, true)
  fmt.Println(createTableSQL)
  _, err = h.Querier.Exec(createTableSQL)
  log.ErrPanic(err)

@cxr29 cxr29 closed this as completed Apr 21, 2021
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