Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ensure setting.Database.UseXXX has been set to the right value when installing #23350

Closed
wants to merge 1 commit into from
Closed

Ensure setting.Database.UseXXX has been set to the right value when installing #23350

wants to merge 1 commit into from

Conversation

wolfogre
Copy link
Member

@wolfogre wolfogre commented Mar 7, 2023

setting.Database.Type has been modified, but setting.Database.UseXXX hasn't.

// Test database setting.
setting.Database.Type = form.DbType
setting.Database.Host = form.DbHost

So registerPostgresSchemaDriver will be missed when initing DB engine.

gitea/models/db/engine.go

Lines 104 to 110 in 84a2993

if setting.Database.UsePostgreSQL && len(setting.Database.Schema) > 0 {
// OK whilst we sort out our schema issues - create a schema aware postgres
registerPostgresSchemaDriver()
engine, err = xorm.NewEngine("postgresschema", connStr)
} else {
engine, err = xorm.NewEngine(setting.Database.Type, connStr)
}


BTW, I think it will be a good idea to refactor setting.Database.UseXXX to methods.

Update: #23354

@wolfogre wolfogre added type/bug outdated/backport/v1.18 This PR should be backported to Gitea 1.18 outdated/backport/v1.19 This PR should be backported to Gitea 1.19 labels Mar 7, 2023
@wolfogre wolfogre added this to the 1.20.0 milestone Mar 7, 2023
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Mar 7, 2023
@wolfogre wolfogre marked this pull request as draft March 7, 2023 06:35
@wolfogre wolfogre closed this Mar 7, 2023
@lunny lunny removed this from the 1.20.0 milestone Mar 7, 2023
lunny pushed a commit that referenced this pull request Mar 7, 2023
Replace #23350.

Refactor `setting.Database.UseMySQL` to
`setting.Database.Type.IsMySQL()`.

To avoid mismatching between `Type` and `UseXXX`.

This refactor can fix the bug mentioned in #23350, so it should be
backported.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Mar 7, 2023
Replace go-gitea#23350.

Refactor `setting.Database.UseMySQL` to
`setting.Database.Type.IsMySQL()`.

To avoid mismatching between `Type` and `UseXXX`.

This refactor can fix the bug mentioned in go-gitea#23350, so it should be
backported.
lunny pushed a commit that referenced this pull request Mar 7, 2023
Backport #23354

Replace #23350.

Refactor `setting.Database.UseMySQL` to
`setting.Database.Type.IsMySQL()`.

To avoid mismatching between `Type` and `UseXXX`.

This refactor can fix the bug mentioned in #23350, so it should be
backported.

Co-authored-by: Jason Song <i@wolfogre.com>
@delvh delvh removed outdated/backport/v1.18 This PR should be backported to Gitea 1.18 outdated/backport/v1.19 This PR should be backported to Gitea 1.19 labels Mar 14, 2023
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants