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

struct field time.Time turn into text after migration #59

Open
tablecell opened this issue Oct 13, 2021 · 0 comments
Open

struct field time.Time turn into text after migration #59

tablecell opened this issue Oct 13, 2021 · 0 comments

Comments

@tablecell
Copy link

tablecell commented Oct 13, 2021

package main

import (
	"fmt"
	"github.com/coocood/qbs"
	_ "github.com/mattn/go-sqlite3"
	"log"

	"time"
)

type Blog struct {
	Id int64
 
	Title     string    `db:"title"`
	Author    string    `db:"author"`
	Published time.Time `db:"published"`
}

func checkErr(err error, msg string) {
	if err != nil {
		log.Fatalln(msg, err)
	}
}

func main() {

	qbs.Register("sqlite3", "blog.db", "qbs_test", qbs.NewSqlite3())

	q, err := qbs.GetQbs()
	fmt.Print(q, err)
	migration, err := qbs.GetMigration()
 
	defer migration.Close()
	err = migration.CreateTableIfNotExists(new(Blog))
	fmt.Println(err)
}

generate table schema

CREATE TABLE `blog` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `title` text, `author` text, `published` text )
@tablecell tablecell changed the title panic: reflect: Elem of invalid type main.Blog struct field time.Time turn into text after migration Oct 13, 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

1 participant