Skip to content

Commit 486d66f

Browse files
committed
make code more readable
1 parent b80e7de commit 486d66f

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

docs/content/installation/database-preparation.en-us.md

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Note: All steps below requires that the database engine of your choice is instal
7373

7474
Replace database name as appropriate.
7575

76+
7677
5. Grant all privileges on the database to database user created above.
7778

7879
For local database:

models/db/collation.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,6 @@ func preprocessDatabaseCollation(x *xorm.Engine) {
185185
}
186186

187187
if len(r.InconsistentCollationColumns) > 0 {
188-
log.Error("There are %d table columns have inconsistent collation, they should use %q. Please go to admin panel Self Check page or refer to Gitea document", len(r.InconsistentCollationColumns), r.DatabaseCollation)
188+
log.Error("There are %d table columns using inconsistent collation, they should use %q. Please go to admin panel Self Check page", len(r.InconsistentCollationColumns), r.DatabaseCollation)
189189
}
190190
}

tests/integration/db_collation_test.go

+17-18
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,31 @@ type TestCollationTbl struct {
2222
func TestDatabaseCollation(t *testing.T) {
2323
x := db.GetEngine(db.DefaultContext).(*xorm.Engine)
2424

25-
// all created tables should use case-sensitive collation by default
26-
if !setting.Database.Type.IsMSSQL() {
27-
_, _ = x.Exec("DROP TABLE IF EXISTS test_collation_tbl")
28-
err := x.Sync(&TestCollationTbl{})
29-
assert.NoError(t, err)
30-
_, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('main')")
31-
_, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('Main')")
32-
_, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('main')")
33-
cnt, err := x.Count(&TestCollationTbl{})
34-
assert.NoError(t, err)
35-
assert.EqualValues(t, 2, cnt)
36-
_, _ = x.Exec("DROP TABLE IF EXISTS test_collation_tbl")
25+
// there are blockers for MSSQL to use case-sensitive collation, see the comments in db/collation.go
26+
if setting.Database.Type.IsMSSQL() {
27+
t.Skip("there are blockers for MSSQL to use case-sensitive collation")
28+
return
3729
}
3830

31+
// all created tables should use case-sensitive collation by default
32+
_, _ = x.Exec("DROP TABLE IF EXISTS test_collation_tbl")
33+
err := x.Sync(&TestCollationTbl{})
34+
assert.NoError(t, err)
35+
_, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('main')")
36+
_, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('Main')")
37+
_, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('main')")
38+
cnt, err := x.Count(&TestCollationTbl{})
39+
assert.NoError(t, err)
40+
assert.EqualValues(t, 2, cnt)
41+
_, _ = x.Exec("DROP TABLE IF EXISTS test_collation_tbl")
42+
3943
// by default, SQLite3 and PostgreSQL are using case-sensitive collations, but MySQL and MSSQL are not
44+
// the following tests are only for MySQL and MSSQL
4045
if !setting.Database.Type.IsMySQL() && !setting.Database.Type.IsMSSQL() {
4146
t.Skip("only MySQL and MSSQL requires the case-sensitive collation check at the moment")
4247
return
4348
}
4449

45-
// but there are blockers for MSSQL to use case-sensitive collation, see the comments in db/collation.go
46-
if !setting.Database.Type.IsMySQL() {
47-
t.Skip("there are blockers for MSSQL to use case-sensitive collation")
48-
return
49-
}
50-
5150
t.Run("Default startup makes database collation case-sensitive", func(t *testing.T) {
5251
r, err := db.CheckCollations(x)
5352
assert.NoError(t, err)

0 commit comments

Comments
 (0)