Skip to content

Commit 28d79ac

Browse files
committed
add geeorm day1 & cmd_test
1 parent 5087f8c commit 28d79ac

File tree

10 files changed

+421
-11
lines changed

10 files changed

+421
-11
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"geeorm"
6+
_ "github.com/mattn/go-sqlite3"
7+
)
8+
9+
func main() {
10+
engine, _ := geeorm.NewEngine("sqlite3", "gee.db")
11+
defer engine.Close()
12+
s := engine.NewSession()
13+
_, _ = s.Raw("DROP TABLE IF EXISTS User;").Exec()
14+
_, _ = s.Raw("CREATE TABLE User(Name text);").Exec()
15+
_, _ = s.Raw("CREATE TABLE User(Name text);").Exec()
16+
result, _ := s.Raw("INSERT INTO User(`Name`) values (?), (?)", "Tom", "Sam").Exec()
17+
count, _ := result.RowsAffected()
18+
fmt.Printf("Exec success, %d affected\n", count)
19+
20+
}

gee-orm/day1-database-sql/session/raw_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestMain(m *testing.M) {
1818
}
1919

2020
func NewSession() *Session {
21-
return &Session{db: TestDB}
21+
return New(TestDB)
2222
}
2323

2424
func TestSession_Exec(t *testing.T) {

gee-orm/day2-reflect-schema/session/raw_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestMain(m *testing.M) {
2323
}
2424

2525
func NewSession() *Session {
26-
return &Session{db: TestDB, dialect: TestDial}
26+
return New(TestDB, TestDial)
2727
}
2828

2929
func TestSession_Exec(t *testing.T) {

gee-orm/day3-save-query/session/raw_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ func TestMain(m *testing.M) {
2323
}
2424

2525
func NewSession() *Session {
26-
return &Session{db: TestDB, dialect: TestDial}
26+
return New(TestDB, TestDial)
2727
}
28-
2928
func TestSession_Exec(t *testing.T) {
3029
s := NewSession()
3130
_, _ = s.Raw("DROP TABLE IF EXISTS User;").Exec()

gee-orm/day4-chain-operation/session/raw_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestMain(m *testing.M) {
2323
}
2424

2525
func NewSession() *Session {
26-
return &Session{db: TestDB, dialect: TestDial}
26+
return New(TestDB, TestDial)
2727
}
2828

2929
func TestSession_Exec(t *testing.T) {

gee-orm/day5-hooks/session/raw_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestMain(m *testing.M) {
2323
}
2424

2525
func NewSession() *Session {
26-
return &Session{db: TestDB, dialect: TestDial}
26+
return New(TestDB, TestDial)
2727
}
2828

2929
func TestSession_Exec(t *testing.T) {

gee-orm/day6-transaction/session/raw_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestMain(m *testing.M) {
2323
}
2424

2525
func NewSession() *Session {
26-
return &Session{db: TestDB, dialect: TestDial}
26+
return New(TestDB, TestDial)
2727
}
2828

2929
func TestSession_Exec(t *testing.T) {

gee-orm/day7-migrate/session/raw_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestMain(m *testing.M) {
2323
}
2424

2525
func NewSession() *Session {
26-
return &Session{db: TestDB, dialect: TestDial}
26+
return New(TestDB, TestDial)
2727
}
2828

2929
func TestSession_Exec(t *testing.T) {

0 commit comments

Comments
 (0)