Skip to content

Commit

Permalink
support column name 'count'
Browse files Browse the repository at this point in the history
  • Loading branch information
yinloo-ola committed Nov 19, 2024
1 parent ccb7d11 commit f31b3cb
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 63 deletions.
33 changes: 18 additions & 15 deletions golalib/golalib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ import (

//go:embed testdata
var fixtures embed.FS
var s *server.Server
var testDBPort int = 33066
var testDBName string = "testdata"
var testTables = []string{
"blogs",
"users", "songs", "song_user_favourites",
"profile", "account",
"room",
"gifts", "gifts_nn",
"gifts_with_default", "gifts_nn_with_default",
"wallet",
"worker",
}

var (
s *server.Server
testDBPort int = 33066
testDBName string = "testdata"
testTables = []string{
"blogs",
"users", "songs", "song_user_favourites",
"profile", "account",
"room",
"gifts", "gifts_nn",
"gifts_with_default", "gifts_nn_with_default",
"wallet",
"worker",
}
)
var testDataPath = "testdata" + string(filepath.Separator)

var update = flag.Bool("update", false, "update generated files")
Expand Down Expand Up @@ -70,7 +73,7 @@ func testGen(t *testing.T, wd string, gen genMethod, data ormtpl.TplStruct) {
os.Mkdir(expectedFileFolder, os.ModePerm)
}

err := ioutil.WriteFile(testDataPath+path, data, 0644)
err := ioutil.WriteFile(testDataPath+path, data, 0o644)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -136,7 +139,7 @@ func TestIdx(t *testing.T) {
tb := getOne(db.Tables, func(tb *structs.Table) bool {
return tb.Name == "blogs"
})
if len(tb.Indexes) != 7 {
if len(tb.Indexes) != 8 {
t.Error("Failed to parse blogs table's 7 indexes")
}

Expand Down
2 changes: 2 additions & 0 deletions golalib/testdata/blogs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ CREATE TABLE `blogs` (
`country` varchar(255) NOT NULL DEFAULT '' COMMENT 'Country of the blog user',
`created_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Created Timestamp',
`updated_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Updated Timestamp',
`count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'count',
PRIMARY KEY (`id`),
KEY `user` (`user_id`),
KEY `user_vip` (`user_id`, `is_vip`),
KEY `country_cate` (`country`, `category_id`, `is_vip`),
KEY `country_vip` (`country`, `is_vip`),
KEY `cate_pinned` (`category_id`, `is_pinned`, `is_vip`),
KEY `user_pinned_cate` (`user_id`, `is_pinned`, `category_id`),
KEY `user_id_count` (`user_id`, `count`),
UNIQUE KEY `slug` (`slug`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
75 changes: 71 additions & 4 deletions golalib/testdata/blogs/blogs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions golalib/testdata/blogs/blogs_ctx.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 32 additions & 10 deletions golalib/testdata/blogs/blogs_idx.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f31b3cb

Please sign in to comment.