qbs icon indicating copy to clipboard operation
qbs copied to clipboard

struct field time.Time turn into text after migration

Open tablecell opened this issue 3 years ago • 0 comments

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 avatar Oct 13 '21 08:10 tablecell