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

sess.InsertInto with multicolumn only last column set value #261

Open
tablecell opened this issue Oct 31, 2023 · 0 comments
Open

sess.InsertInto with multicolumn only last column set value #261

tablecell opened this issue Oct 31, 2023 · 0 comments

Comments

@tablecell
Copy link

tablecell commented Oct 31, 2023

main.go

package main

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

type User struct {
	ID        int64
	Name      string
	Age       int

}


func main(){

conn, err:= dbr.Open("sqlite3", "test.db", nil)
// CREATE TABLE `user` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `name` text , age integer)
//conn.SetMaxOpenConns(10)

if nil != err {

		panic(err)
	}
 
sess := conn.NewSession(nil)

     user := &User{Name:"ooo",Age:11}

 
 sess.InsertInto("user").
 	Columns("name").
 		Columns("age").
	Record(user).
	Exec()
}

only field "age" has value but field "name" is NULL

 sess.InsertInto("user").
	Columns("age").
Columns("name").
	Record(user).
	Exec()

only field "name" has value but field "age" is NULL

sess.InsertInto("user").
        Record(user).
	Exec()

and

sess.InsertInto("user").
 	Columns("*").
        Record(user).
	Exec()

and

 sess.InsertInto("user").
	Columns("name,age").
	Record(user).
	Exec()

all fail

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