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

can't load rest data after insert blank record #240

Closed
tablecell opened this issue Oct 13, 2021 · 2 comments
Closed

can't load rest data after insert blank record #240

tablecell opened this issue Oct 13, 2021 · 2 comments
Labels

Comments

@tablecell
Copy link

tablecell commented Oct 13, 2021

no-data-after-blank-record.go

package main

import (
	"fmt"
	dbr "github.com/gocraft/dbr/v2"
	_ "github.com/mattn/go-sqlite3"
)

type Item struct {
	ID   int
	Name string
}

func main() {
	// CREATE TABLE `item`(`id` integer DEFAULT (NULL) NOT NULL UNIQUE PRIMARY KEY AUTOINCREMENT, `name` varchar(255));

	sqlite3Session, err := dbr.Open("sqlite3", "item.db", nil)

	sugg := Item{Name: "aaa"}

	sess := sqlite3Session.NewSession(nil)

	res, err := sess.InsertInto("item").
		Columns("Name"). // insert  a blank item     no err report
		Record(&sugg).Exec()
/*
sqlite> select * from item;
1   -
*/
	fmt.Println(res, err)

	sugg = Item{Name: "bbb"}

	res, err = sess.InsertInto("Item").
		Columns("name"). //    add  a  record has field name data
		Record(&sugg).Exec()
	fmt.Println(res, err)
/*
sqlite> select * from item;
1| -
2|bbb
*/

	var items []Item

	sess.Select("name").From("item").Load(&items) // can't load  rest data  after  blank record
	for k, v := range items {
		fmt.Println(k, v)
	}

}
@taylorchu
Copy link
Contributor

0 sql: Scan error on column index 0, name "name": converting NULL to string is unsupported

Please confirm this by checking returning values of Load.

@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 9, 2022
@stale stale bot closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants