diff --git a/models/db/collation.go b/models/db/collation.go index d24a211336d86..77354ff72df3c 100644 --- a/models/db/collation.go +++ b/models/db/collation.go @@ -185,6 +185,6 @@ func preprocessDatabaseCollation(x *xorm.Engine) { } if len(r.InconsistentCollationColumns) > 0 { - 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) + 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) } } diff --git a/tests/integration/db_collation_test.go b/tests/integration/db_collation_test.go index 35c5a99934be1..988af2903887d 100644 --- a/tests/integration/db_collation_test.go +++ b/tests/integration/db_collation_test.go @@ -22,32 +22,31 @@ type TestCollationTbl struct { func TestDatabaseCollation(t *testing.T) { x := db.GetEngine(db.DefaultContext).(*xorm.Engine) - // all created tables should use case-sensitive collation by default - if !setting.Database.Type.IsMSSQL() { - _, _ = x.Exec("DROP TABLE IF EXISTS test_collation_tbl") - err := x.Sync(&TestCollationTbl{}) - assert.NoError(t, err) - _, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('main')") - _, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('Main')") - _, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('main')") - cnt, err := x.Count(&TestCollationTbl{}) - assert.NoError(t, err) - assert.EqualValues(t, 2, cnt) - _, _ = x.Exec("DROP TABLE IF EXISTS test_collation_tbl") + // there are blockers for MSSQL to use case-sensitive collation, see the comments in db/collation.go + if setting.Database.Type.IsMSSQL() { + t.Skip("there are blockers for MSSQL to use case-sensitive collation") + return } + // all created tables should use case-sensitive collation by default + _, _ = x.Exec("DROP TABLE IF EXISTS test_collation_tbl") + err := x.Sync(&TestCollationTbl{}) + assert.NoError(t, err) + _, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('main')") + _, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('Main')") + _, _ = x.Exec("INSERT INTO test_collation_tbl (txt) VALUES ('main')") + cnt, err := x.Count(&TestCollationTbl{}) + assert.NoError(t, err) + assert.EqualValues(t, 2, cnt) + _, _ = x.Exec("DROP TABLE IF EXISTS test_collation_tbl") + // by default, SQLite3 and PostgreSQL are using case-sensitive collations, but MySQL and MSSQL are not + // the following tests are only for MySQL and MSSQL if !setting.Database.Type.IsMySQL() && !setting.Database.Type.IsMSSQL() { t.Skip("only MySQL and MSSQL requires the case-sensitive collation check at the moment") return } - // but there are blockers for MSSQL to use case-sensitive collation, see the comments in db/collation.go - if !setting.Database.Type.IsMySQL() { - t.Skip("there are blockers for MSSQL to use case-sensitive collation") - return - } - t.Run("Default startup makes database collation case-sensitive", func(t *testing.T) { r, err := db.CheckCollations(x) assert.NoError(t, err)