diff --git a/assets/go-licenses.json b/assets/go-licenses.json index 711044278f..6f1e5d5225 100644 --- a/assets/go-licenses.json +++ b/assets/go-licenses.json @@ -814,6 +814,26 @@ "path": "github.com/inbucket/html2text/LICENSE", "licenseText": "The MIT License (MIT)\n\nCopyright (c) 2015 Jay Taylor\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n" }, + { + "name": "github.com/jackc/pgpassfile", + "path": "github.com/jackc/pgpassfile/LICENSE", + "licenseText": "Copyright (c) 2019 Jack Christensen\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" + }, + { + "name": "github.com/jackc/pgservicefile", + "path": "github.com/jackc/pgservicefile/LICENSE", + "licenseText": "Copyright (c) 2020 Jack Christensen\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" + }, + { + "name": "github.com/jackc/pgx/v5", + "path": "github.com/jackc/pgx/v5/LICENSE", + "licenseText": "Copyright (c) 2013-2021 Jack Christensen\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" + }, + { + "name": "github.com/jackc/puddle/v2", + "path": "github.com/jackc/puddle/v2/LICENSE", + "licenseText": "Copyright (c) 2018 Jack Christensen\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" + }, { "name": "github.com/jbenet/go-context/io", "path": "github.com/jbenet/go-context/io/LICENSE", diff --git a/go.mod b/go.mod index 1772af561b..980eea1974 100644 --- a/go.mod +++ b/go.mod @@ -67,12 +67,12 @@ require ( github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/huandu/xstrings v1.5.0 github.com/inbucket/html2text v0.9.0 + github.com/jackc/pgx/v5 v5.7.6 github.com/jhillyerd/enmime/v2 v2.2.0 github.com/json-iterator/go v1.1.12 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/klauspost/compress v1.18.1 github.com/klauspost/cpuid/v2 v2.2.11 - github.com/lib/pq v1.10.9 github.com/markbates/goth v1.80.0 github.com/mattn/go-isatty v0.0.20 github.com/mattn/go-sqlite3 v1.14.32 @@ -206,10 +206,14 @@ require ( github.com/gorilla/securecookie v1.1.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-retryablehttp v0.7.8 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect + github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/pgzip v1.2.6 // indirect + github.com/lib/pq v1.10.9 // indirect github.com/libdns/libdns v1.0.0 // indirect github.com/mailru/easyjson v0.9.0 // indirect github.com/markbates/going v1.0.3 // indirect diff --git a/go.sum b/go.sum index 3939e5781f..701ae772d9 100644 --- a/go.sum +++ b/go.sum @@ -458,6 +458,14 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/inbucket/html2text v0.9.0 h1:ULJmVcBEMAcmLE+/rN815KG1Fx6+a4HhbUxiDiN+qks= github.com/inbucket/html2text v0.9.0/go.mod h1:QDaumzl+/OzlSVbNohhmg+yAy5pKjUjzCKW2BMvztKE= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk= +github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M= +github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= +github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= diff --git a/models/db/engine.go b/models/db/engine.go index 0dcbfa0378..1c8ad9d3f5 100755 --- a/models/db/engine.go +++ b/models/db/engine.go @@ -25,7 +25,6 @@ import ( "xorm.io/xorm/schemas" _ "github.com/go-sql-driver/mysql" // Needed for the MySQL driver - _ "github.com/lib/pq" // Needed for the Postgresql driver ) var ( @@ -112,10 +111,14 @@ func newXORMEngineGroup() (xormEngineInterface, error) { } var masterEngine *xorm.Engine - // For PostgreSQL: if a schema is provided, we use the special "postgresschema" driver. - if setting.Database.Type.IsPostgreSQL() && len(setting.Database.Schema) > 0 { - registerPostgresSchemaDriver() - masterEngine, err = xorm.NewEngine("postgresschema", masterConnStr) + // For PostgreSQL: use pgx driver for better performance and multi-host support + // If a schema is provided, use "postgresschema" which wraps pgx with schema injection + if setting.Database.Type.IsPostgreSQL() { + if len(setting.Database.Schema) > 0 { + masterEngine, err = xorm.NewEngine("postgresschema", masterConnStr) + } else { + masterEngine, err = xorm.NewEngine("pgx", masterConnStr) + } } else { masterEngine, err = xorm.NewEngine(setting.Database.Type.String(), masterConnStr) } @@ -138,7 +141,17 @@ func newXORMEngineGroup() (xormEngineInterface, error) { var slaveEngines []*xorm.Engine // Iterate over all slave DSNs and create engines for _, dsn := range slaveConnStrs { - slaveEngine, err := xorm.NewEngine(setting.Database.Type.String(), dsn) + var slaveEngine *xorm.Engine + // Use same driver selection logic as master + if setting.Database.Type.IsPostgreSQL() { + if len(setting.Database.Schema) > 0 { + slaveEngine, err = xorm.NewEngine("postgresschema", dsn) + } else { + slaveEngine, err = xorm.NewEngine("pgx", dsn) + } + } else { + slaveEngine, err = xorm.NewEngine(setting.Database.Type.String(), dsn) + } if err != nil { return nil, fmt.Errorf("failed to create slave engine for dsn %q: %w", dsn, err) } diff --git a/models/db/sql_postgres_with_schema.go b/models/db/sql_postgres_with_schema.go index 376f984dc6..3851fa6e87 100644 --- a/models/db/sql_postgres_with_schema.go +++ b/models/db/sql_postgres_with_schema.go @@ -1,70 +1,55 @@ // Copyright 2020 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +// Copyright 2025 The Forgejo Authors. All rights reserved. +// SPDX-License-Identifier: GPL-3.0-or-later package db import ( + "context" "database/sql" "database/sql/driver" - "sync" + "errors" "forgejo.org/modules/setting" - "github.com/lib/pq" + "github.com/jackc/pgx/v5/stdlib" "xorm.io/xorm/dialects" ) -var registerOnce sync.Once - -func registerPostgresSchemaDriver() { - registerOnce.Do(func() { - sql.Register("postgresschema", &postgresSchemaDriver{}) - dialects.RegisterDriver("postgresschema", dialects.QueryDriver("postgres")) - }) +func init() { + // Register pgx-based driver as "postgresschema" for PostgreSQL with schema support + // This wraps pgx/v5/stdlib and injects search_path configuration on connection + // For PostgreSQL without schema, engine.go uses "pgx" directly (registered by pgx/v5/stdlib) + drv := &postgresSchemaDriver{innerDriver: &stdlib.Driver{}} + sql.Register("postgresschema", drv) + dialects.RegisterDriver("postgresschema", dialects.QueryDriver("postgres")) } type postgresSchemaDriver struct { - pq.Driver + innerDriver *stdlib.Driver } // Open opens a new connection to the database. name is a connection string. // This function opens the postgres connection in the default manner but immediately // runs set_config to set the search_path appropriately func (d *postgresSchemaDriver) Open(name string) (driver.Conn, error) { - conn, err := d.Driver.Open(name) + conn, err := d.innerDriver.Open(name) if err != nil { return conn, err } - schemaValue, _ := driver.String.ConvertValue(setting.Database.Schema) - // golangci lint is incorrect here - there is no benefit to using driver.ExecerContext here - // and in any case pq does not implement it - if execer, ok := conn.(driver.Execer); ok { //nolint - _, err := execer.Exec(`SELECT set_config( - 'search_path', - $1 || ',' || current_setting('search_path'), - false)`, []driver.Value{schemaValue}) - if err != nil { - _ = conn.Close() - return nil, err - } - return conn, nil + // pgx implements ExecerContext, not the deprecated Execer interface + execer, ok := conn.(driver.ExecerContext) + if !ok { + _ = conn.Close() + return nil, errors.New("pgx driver connection does not implement ExecerContext") } - stmt, err := conn.Prepare(`SELECT set_config( + _, err = execer.ExecContext(context.Background(), `SELECT set_config( 'search_path', $1 || ',' || current_setting('search_path'), - false)`) - if err != nil { - _ = conn.Close() - return nil, err - } - defer stmt.Close() - - // driver.String.ConvertValue will never return err for string - - // golangci lint is incorrect here - there is no benefit to using stmt.ExecWithContext here - _, err = stmt.Exec([]driver.Value{schemaValue}) //nolint + false)`, []driver.NamedValue{{Ordinal: 1, Value: setting.Database.Schema}}) if err != nil { _ = conn.Close() return nil, err diff --git a/models/db/sql_postgres_with_schema_test.go b/models/db/sql_postgres_with_schema_test.go new file mode 100644 index 0000000000..19a3e7ece3 --- /dev/null +++ b/models/db/sql_postgres_with_schema_test.go @@ -0,0 +1,29 @@ +// Copyright 2025 The Forgejo Authors. All rights reserved. +// SPDX-License-Identifier: GPL-3.0-or-later + +package db + +import ( + "database/sql" + "slices" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestPostgresSchemaDriverRegistered(t *testing.T) { + // Verify the driver is registered (happens in init()) + drivers := sql.Drivers() + found := slices.Contains(drivers, "postgresschema") + assert.True(t, found, "postgresschema driver should be registered") +} + +func TestPostgresSchemaDriverOpenFailsWithInvalidConnString(t *testing.T) { + // Verify Open() is actually called by checking that an invalid connection string returns an error + drv := &postgresSchemaDriver{innerDriver: nil} + + require.Panics(t, func() { + _, _ = drv.Open("invalid") + }, "Open with nil innerDriver should panic (confirming the Open method is called)") +} diff --git a/models/fixtures/action_run.yml b/models/fixtures/action_run.yml index 4e5af28166..8fa04b0066 100644 --- a/models/fixtures/action_run.yml +++ b/models/fixtures/action_run.yml @@ -9,13 +9,13 @@ ref: "refs/heads/master" commit_sha: "c2d72f548424103f01ee1dc02889c1e2bff816b0" event: "push" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 started: 1683636528 stopped: 1683636626 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 event_payload: | { @@ -217,13 +217,13 @@ ref: "refs/heads/master" commit_sha: "c2d72f548424103f01ee1dc02889c1e2bff816b0" event: "push" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 started: 1683636528 stopped: 1683636626 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 event_payload: | { @@ -424,13 +424,13 @@ ref: "refs/heads/master" commit_sha: "c2d72f548424103f01ee1dc02889c1e2bff816b0" event: "push" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 started: 1683636528 stopped: 1683636626 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 - id: 794 @@ -443,13 +443,13 @@ ref: "refs/heads/test" commit_sha: "c2d72f548424103f01ee1dc02889c1e2bff816b0" event: "push" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 started: 1683636528 stopped: 1683636626 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 - id: 891 @@ -462,13 +462,13 @@ ref: "refs/heads/branch2" commit_sha: "985f0301dba5e7b34be866819cd15ad3d8f508ee" event: "push" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 # success started: 1683636528 stopped: 1683636626 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 event_payload: '{"head_commit":{"id":"5f22f7d0d95d614d25a5b68592adb345a4b5c7fd"}}' @@ -485,13 +485,13 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" event: "push" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 # success started: 1683636528 stopped: 1683636626 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 - @@ -505,13 +505,13 @@ ref: "refs/heads/bugfix-1" commit_sha: "35c5cddfc19397501ec8f4f7bb808a7c8f04445f" event: "pull_request" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 2 # failure started: 1683636528 stopped: 1683636626 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 - @@ -526,10 +526,10 @@ commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" event: "workflow_dispatch" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 6 # running started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 diff --git a/models/fixtures/action_run_job.yml b/models/fixtures/action_run_job.yml index ed716cd5a9..bb812c1570 100644 --- a/models/fixtures/action_run_job.yml +++ b/models/fixtures/action_run_job.yml @@ -4,7 +4,7 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_2 attempt: 1 job_id: job_2 @@ -18,7 +18,7 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_2 attempt: 1 job_id: job_2 @@ -32,7 +32,7 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false name: job1 (1) attempt: 1 job_id: job1 @@ -46,7 +46,7 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false name: job1 (2) attempt: 1 job_id: job1 @@ -60,7 +60,7 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false name: job2 attempt: 1 job_id: job2 @@ -75,7 +75,7 @@ repo_id: 1 owner_id: 1 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_2 attempt: 1 job_id: job_2 @@ -89,7 +89,7 @@ repo_id: 1 owner_id: 1 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_2 attempt: 1 job_id: job_2 @@ -104,7 +104,7 @@ repo_id: 1 owner_id: 2 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_2 attempt: 2 job_id: job_2 @@ -119,7 +119,7 @@ repo_id: 1 owner_id: 3 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_2 attempt: 1 job_id: job_2 @@ -134,7 +134,7 @@ repo_id: 4 owner_id: 1 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_2 attempt: 0 job_id: job_2 @@ -149,7 +149,7 @@ repo_id: 1 owner_id: 3 commit_sha: ea09cba7099f7e3bea80dee1a42f0b5d5e127f2e - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_3 attempt: 1 job_id: job_3 diff --git a/models/fixtures/action_runner_token.yml b/models/fixtures/action_runner_token.yml index 6520b7f6fb..8318349c9d 100644 --- a/models/fixtures/action_runner_token.yml +++ b/models/fixtures/action_runner_token.yml @@ -3,7 +3,7 @@ token: xeiWBL5kuTYxGPynHCqQdoeYmJAeG3IzGXCYTrDX owner_id: 0 repo_id: 0 - is_active: 1 + is_active: true created: 1695617748 updated: 1695617748 @@ -12,7 +12,7 @@ token: vohJB9QcZuSv1gAXESTk2uqpSjHhsKT9j4zYF84x owner_id: 1 repo_id: 0 - is_active: 0 + is_active: false created: 1695617749 updated: 1695617749 @@ -21,7 +21,7 @@ token: gjItAeJ3CA74hNPmPPo0Zco8I1eMaNcP1jVifjOE owner_id: 1 repo_id: 0 - is_active: 1 + is_active: true created: 1695617750 updated: 1695617750 @@ -30,6 +30,6 @@ token: NOjLubxzFxPGhPXflZknys0gjVvQNhomFbAYuhbH owner_id: 0 repo_id: 1 - is_active: 1 + is_active: true created: 1695617751 updated: 1695617751 diff --git a/models/fixtures/action_task.yml b/models/fixtures/action_task.yml index e5fa35f0b3..956bc736f9 100644 --- a/models/fixtures/action_task.yml +++ b/models/fixtures/action_task.yml @@ -8,15 +8,15 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: 6d8ef48297195edcc8e22c70b3020eaa06c52976db67d39b4260c64a69a2cc1508825121b7b8394e48e00b1bf8718b2aaaaa token_salt: eeeeeeee token_last_eight: eeeeeeee log_filename: artifact-test2/2f/47.log - log_in_storage: 1 + log_in_storage: true log_length: 707 log_size: 90179 - log_expired: 0 + log_expired: false - id: 47 job_id: 192 @@ -28,15 +28,15 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: 6d8ef48297195edcc8e22c70b3020eaa06c52976db67d39b4260c64a69a2cc1508825121b7b8394e48e00b1bf8718b2a867e token_salt: jVuKnSPGgy token_last_eight: eeb1a71a log_filename: artifact-test2/2f/47.log - log_in_storage: 1 + log_in_storage: true log_length: 707 log_size: 90179 - log_expired: 0 + log_expired: false - id: 48 job_id: 193 @@ -48,15 +48,15 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: ffffcfffffffbffffffffffffffffefffffffafffffffffffffffffffffffffffffdffffffffffffffffffffffffffffffff token_salt: ffffffffff token_last_eight: ffffffff log_filename: artifact-test2/2f/47.log - log_in_storage: 1 + log_in_storage: true log_length: 707 log_size: 90179 - log_expired: 0 + log_expired: false - id: 49 job_id: 194 @@ -68,15 +68,15 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: b8d3962425466b6709b9ac51446f93260c54afe8e7b6d3686e34f991fb8a8953822b0deed86fe41a103f34bc48dbc4784220 token_salt: ffffffffff token_last_eight: ffffffff log_filename: artifact-test2/2f/47.log - log_in_storage: 1 + log_in_storage: true log_length: 707 log_size: 90179 - log_expired: 0 + log_expired: false - id: 50 job_id: 195 @@ -88,15 +88,15 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: b8d3962425466b6709b9ac51446f93260c54afe8e7b6d3686e34f991fb8a8953822b0deed86fe41a103f34bc48dbc4784221 token_salt: ffffffffff token_last_eight: ffffffff log_filename: artifact-test2/2f/47.log - log_in_storage: 1 + log_in_storage: true log_length: 707 log_size: 90179 - log_expired: 0 + log_expired: false - id: 51 job_id: 196 @@ -108,15 +108,15 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: b8d3962425466b6709b9ac51446f93260c54afe8e7b6d3686e34f991fb8a8953822b0deed86fe41a103f34bc48dbc4784222 token_salt: ffffffffff token_last_eight: ffffffff log_filename: artifact-test2/2f/47.log - log_in_storage: 1 + log_in_storage: true log_length: 707 log_size: 90179 - log_expired: 0 + log_expired: false - id: 52 job_id: 192 @@ -128,15 +128,15 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: b8d3962425466b6709b9ac51446f93260c54afe8e7b6d3686e34f991fb8a8953822b0deed86fe41a103f34bc48dbc4784223 token_salt: ffffffffff token_last_eight: ffffffff log_filename: artifact-test2/2f/47.log - log_in_storage: 1 + log_in_storage: true log_length: 707 log_size: 90179 - log_expired: 0 + log_expired: false - id: 53 job_id: 192 @@ -148,12 +148,12 @@ repo_id: 4 owner_id: 1 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: b8d3962425466b6709b9ac51446f93260c54afe8e7b6d3686e34f991fb8a8953822b0deed86fe41a103f34bc48dbc4784224 token_salt: ffffffffff token_last_eight: ffffffff log_filename: artifact-test2/2f/47.log - log_in_storage: 1 + log_in_storage: true log_length: 707 log_size: 90179 - log_expired: 0 + log_expired: false diff --git a/models/fixtures/comment.yml b/models/fixtures/comment.yml index 6908d85dda..27f147fbce 100644 --- a/models/fixtures/comment.yml +++ b/models/fixtures/comment.yml @@ -268,7 +268,7 @@ poster_id: 1 issue_id: 1 # in repo_id 1 label_id: 1 - content: 1 # add label + content: "1" # add label created_unix: 946685520 - @@ -277,7 +277,7 @@ poster_id: 1 issue_id: 1 label_id: 2 - content: 1 # add label + content: "1" # add label created_unix: 946685620 - @@ -286,7 +286,7 @@ poster_id: 2 issue_id: 1 # in repo_id 1 label_id: 1 - content: 0 # remove label + content: "0" # remove label created_unix: 946685720 - @@ -295,7 +295,7 @@ poster_id: 1 issue_id: 1 # in repo_id 1 label_id: 1 - content: 1 # add label + content: "1" # add label created_unix: 946685720 - @@ -304,7 +304,7 @@ poster_id: 1 issue_id: 1 # in repo_id 1 label_id: 2 - content: 0 # remove label + content: "0" # remove label created_unix: 946685720 - @@ -313,7 +313,7 @@ poster_id: 2 issue_id: 1 # in repo_id 1 label_id: 2 - content: 1 # add label + content: "1" # add label created_unix: 946685820 - @@ -322,7 +322,7 @@ poster_id: 1 issue_id: 1 # in repo_id 1 label_id: 1 - content: 0 # remove label + content: "0" # remove label created_unix: 946685920 - @@ -331,7 +331,7 @@ poster_id: 1 issue_id: 1 # in repo_id 1 label_id: 2 - content: 0 # remove label + content: "0" # remove label created_unix: 946685920 - id: 2040 diff --git a/models/fixtures/team.yml b/models/fixtures/team.yml index a863f1203a..b0c0dc0aa1 100644 --- a/models/fixtures/team.yml +++ b/models/fixtures/team.yml @@ -249,5 +249,5 @@ authorize: 3 num_repos: 0 num_members: 0 - includes_all_repositories: 0 - can_create_org_repo: 0 + includes_all_repositories: false + can_create_org_repo: false diff --git a/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package.yml b/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package.yml index df6fd6348f..7c357ea1bc 100644 --- a/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package.yml +++ b/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package.yml @@ -4,40 +4,40 @@ type: maven name: com.example-parent-project lower_name: com.example-parent-project - semver_compatible: 0 - is_internal: 0 + semver_compatible: false + is_internal: false - id: 2 owner_id: 2 repo_id: 0 type: maven name: com.example-sub-module lower_name: com.example-sub-module - semver_compatible: 0 - is_internal: 0 + semver_compatible: false + is_internal: false - id: 3 owner_id: 1 repo_id: 0 type: maven name: com.example-parent-project lower_name: com.example-parent-project - semver_compatible: 0 - is_internal: 0 + semver_compatible: false + is_internal: false - id: 4 owner_id: 1 repo_id: 0 type: maven name: com.example-sub-module lower_name: com.example-sub-module - semver_compatible: 0 - is_internal: 0 + semver_compatible: false + is_internal: false - id: 5 owner_id: 1 repo_id: 0 type: maven name: foo--bar lower_name: foo--bar - semver_compatible: 0 - is_internal: 0 + semver_compatible: false + is_internal: false # broken uploads - id: 6 owner_id: 8 @@ -45,16 +45,16 @@ type: maven name: com.broken-br-rest-webmvc lower_name: com.broken-br-rest-webmvc - semver_compatible: 0 - is_internal: 0 + semver_compatible: false + is_internal: false - id: 7 owner_id: 8 repo_id: 54 type: maven name: com.broken-br-openapi-base lower_name: com.broken-br-openapi-base - semver_compatible: 0 - is_internal: 0 + semver_compatible: false + is_internal: false # collision - id: 8 owner_id: 1 @@ -62,5 +62,5 @@ type: maven name: group-bar-art lower_name: group-bar-art - semver_compatible: 0 - is_internal: 0 + semver_compatible: false + is_internal: false diff --git a/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package_file.yml b/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package_file.yml index 2d7bd135b3..a49d8c06e8 100644 --- a/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package_file.yml +++ b/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package_file.yml @@ -4,7 +4,7 @@ name: parent-project-1.0-20250503.071237-1.pom lower_name: parent-project-1.0-20250503.071237-1.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256357 - id: 3 version_id: 2 @@ -12,7 +12,7 @@ name: sub-module-1.0-20250503.071237-1.pom lower_name: sub-module-1.0-20250503.071237-1.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256358 - id: 4 version_id: 2 @@ -20,7 +20,7 @@ name: sub-module-1.0-20250503.071237-1.jar lower_name: sub-module-1.0-20250503.071237-1.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256358 - id: 6 version_id: 3 @@ -28,7 +28,7 @@ name: parent-project-7.0.0.pom lower_name: parent-project-7.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256360 - id: 7 version_id: 4 @@ -36,7 +36,7 @@ name: sub-module-7.0.0.pom lower_name: sub-module-7.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256361 - id: 8 version_id: 4 @@ -44,7 +44,7 @@ name: sub-module-7.0.0.jar lower_name: sub-module-7.0.0.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256361 - id: 9 version_id: 5 @@ -52,7 +52,7 @@ name: parent-project-7.0.0.pom lower_name: parent-project-7.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256364 - id: 10 version_id: 6 @@ -60,7 +60,7 @@ name: sub-module-7.0.0.pom lower_name: sub-module-7.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256365 - id: 11 version_id: 6 @@ -68,7 +68,7 @@ name: sub-module-7.0.0.jar lower_name: sub-module-7.0.0.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256365 - id: 12 version_id: 7 @@ -76,7 +76,7 @@ name: bar-1.0-20250503.071248-1.pom lower_name: bar-1.0-20250503.071248-1.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256367 - id: 14 version_id: 8 @@ -84,7 +84,7 @@ name: bar-7.0.0.pom lower_name: bar-7.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256370 - id: 15 version_id: 7 @@ -92,7 +92,7 @@ name: -bar-1.0-20250503.071253-2.pom lower_name: -bar-1.0-20250503.071253-2.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256373 - id: 17 version_id: 8 @@ -100,7 +100,7 @@ name: -bar-7.0.0.pom lower_name: -bar-7.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256375 - id: 18 version_id: 1 @@ -108,7 +108,7 @@ name: parent-project-1.0-20250503.071306-2.pom lower_name: parent-project-1.0-20250503.071306-2.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256385 - id: 20 version_id: 2 @@ -116,7 +116,7 @@ name: sub-module-1.0-20250503.071306-2.pom lower_name: sub-module-1.0-20250503.071306-2.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256386 - id: 21 version_id: 2 @@ -124,7 +124,7 @@ name: sub-module-1.0-20250503.071306-2.jar lower_name: sub-module-1.0-20250503.071306-2.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256386 - id: 23 version_id: 9 @@ -132,7 +132,7 @@ name: parent-project-8.0.0.pom lower_name: parent-project-8.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256389 - id: 24 version_id: 10 @@ -140,7 +140,7 @@ name: sub-module-8.0.0.pom lower_name: sub-module-8.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256390 - id: 25 version_id: 10 @@ -148,7 +148,7 @@ name: sub-module-8.0.0.jar lower_name: sub-module-8.0.0.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256390 - id: 26 version_id: 11 @@ -156,7 +156,7 @@ name: parent-project-8.0.0.pom lower_name: parent-project-8.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256393 - id: 27 version_id: 12 @@ -164,7 +164,7 @@ name: sub-module-8.0.0.pom lower_name: sub-module-8.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256394 - id: 28 version_id: 12 @@ -172,7 +172,7 @@ name: sub-module-8.0.0.jar lower_name: sub-module-8.0.0.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256394 - id: 29 version_id: 7 @@ -180,7 +180,7 @@ name: bar-1.0-20250503.071317-3.pom lower_name: bar-1.0-20250503.071317-3.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256397 - id: 31 version_id: 13 @@ -188,7 +188,7 @@ name: bar-8.0.0.pom lower_name: bar-8.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256399 - id: 32 version_id: 7 @@ -196,7 +196,7 @@ name: -bar-1.0-20250503.071323-4.pom lower_name: -bar-1.0-20250503.071323-4.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256402 - id: 34 version_id: 13 @@ -204,7 +204,7 @@ name: -bar-8.0.0.pom lower_name: -bar-8.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256405 - id: 35 version_id: 1 @@ -212,7 +212,7 @@ name: parent-project-1.0-20250503.071335-3.pom lower_name: parent-project-1.0-20250503.071335-3.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256415 - id: 37 version_id: 2 @@ -220,7 +220,7 @@ name: sub-module-1.0-20250503.071335-3.pom lower_name: sub-module-1.0-20250503.071335-3.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256416 - id: 38 version_id: 2 @@ -228,7 +228,7 @@ name: sub-module-1.0-20250503.071335-3.jar lower_name: sub-module-1.0-20250503.071335-3.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256416 - id: 40 version_id: 14 @@ -236,7 +236,7 @@ name: parent-project-9.0.0.pom lower_name: parent-project-9.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256419 - id: 41 version_id: 15 @@ -244,7 +244,7 @@ name: sub-module-9.0.0.pom lower_name: sub-module-9.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256420 - id: 42 version_id: 15 @@ -252,7 +252,7 @@ name: sub-module-9.0.0.jar lower_name: sub-module-9.0.0.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256420 - id: 43 version_id: 16 @@ -260,7 +260,7 @@ name: parent-project-9.0.0.pom lower_name: parent-project-9.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256423 - id: 44 version_id: 17 @@ -268,7 +268,7 @@ name: sub-module-9.0.0.pom lower_name: sub-module-9.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256424 - id: 45 version_id: 17 @@ -276,7 +276,7 @@ name: sub-module-9.0.0.jar lower_name: sub-module-9.0.0.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256424 - id: 46 version_id: 7 @@ -284,7 +284,7 @@ name: bar-1.0-20250503.071347-5.pom lower_name: bar-1.0-20250503.071347-5.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256427 - id: 48 version_id: 18 @@ -292,7 +292,7 @@ name: bar-9.0.0.pom lower_name: bar-9.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256429 - id: 49 version_id: 7 @@ -300,7 +300,7 @@ name: -bar-1.0-20250503.071353-6.pom lower_name: -bar-1.0-20250503.071353-6.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256432 - id: 51 version_id: 18 @@ -308,7 +308,7 @@ name: -bar-9.0.0.pom lower_name: -bar-9.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256435 - id: 52 version_id: 1 @@ -316,7 +316,7 @@ name: parent-project-1.0-20250503.071405-4.pom lower_name: parent-project-1.0-20250503.071405-4.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256445 - id: 54 version_id: 2 @@ -324,7 +324,7 @@ name: sub-module-1.0-20250503.071405-4.pom lower_name: sub-module-1.0-20250503.071405-4.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256446 - id: 55 version_id: 2 @@ -332,7 +332,7 @@ name: sub-module-1.0-20250503.071405-4.jar lower_name: sub-module-1.0-20250503.071405-4.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256446 - id: 57 version_id: 19 @@ -340,7 +340,7 @@ name: parent-project-10.0.0.pom lower_name: parent-project-10.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256449 - id: 58 version_id: 20 @@ -348,7 +348,7 @@ name: sub-module-10.0.0.pom lower_name: sub-module-10.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256450 - id: 59 version_id: 20 @@ -356,7 +356,7 @@ name: sub-module-10.0.0.jar lower_name: sub-module-10.0.0.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256450 - id: 60 version_id: 21 @@ -364,7 +364,7 @@ name: parent-project-10.0.0.pom lower_name: parent-project-10.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256452 - id: 61 version_id: 22 @@ -372,7 +372,7 @@ name: sub-module-10.0.0.pom lower_name: sub-module-10.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256453 - id: 62 version_id: 22 @@ -380,7 +380,7 @@ name: sub-module-10.0.0.jar lower_name: sub-module-10.0.0.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256453 - id: 63 version_id: 7 @@ -388,7 +388,7 @@ name: bar-1.0-20250503.071416-7.pom lower_name: bar-1.0-20250503.071416-7.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256456 - id: 65 version_id: 23 @@ -396,7 +396,7 @@ name: bar-10.0.0.pom lower_name: bar-10.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256459 - id: 66 version_id: 7 @@ -404,7 +404,7 @@ name: -bar-1.0-20250503.071422-8.pom lower_name: -bar-1.0-20250503.071422-8.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256461 - id: 68 version_id: 23 @@ -412,7 +412,7 @@ name: -bar-10.0.0.pom lower_name: -bar-10.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256464 - id: 69 version_id: 1 @@ -420,7 +420,7 @@ name: parent-project-1.0-20250503.071435-5.pom lower_name: parent-project-1.0-20250503.071435-5.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256474 - id: 70 version_id: 1 @@ -428,7 +428,7 @@ name: maven-metadata.xml lower_name: maven-metadata.xml composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256474 - id: 71 version_id: 2 @@ -436,7 +436,7 @@ name: sub-module-1.0-20250503.071435-5.pom lower_name: sub-module-1.0-20250503.071435-5.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256475 - id: 72 version_id: 2 @@ -444,7 +444,7 @@ name: sub-module-1.0-20250503.071435-5.jar lower_name: sub-module-1.0-20250503.071435-5.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256475 - id: 73 version_id: 2 @@ -452,7 +452,7 @@ name: maven-metadata.xml lower_name: maven-metadata.xml composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256476 - id: 74 version_id: 24 @@ -460,7 +460,7 @@ name: parent-project-11.0.0.pom lower_name: parent-project-11.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256478 - id: 75 version_id: 25 @@ -468,7 +468,7 @@ name: sub-module-11.0.0.pom lower_name: sub-module-11.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256479 - id: 76 version_id: 25 @@ -476,7 +476,7 @@ name: sub-module-11.0.0.jar lower_name: sub-module-11.0.0.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256479 - id: 77 version_id: 26 @@ -484,7 +484,7 @@ name: parent-project-11.0.0.pom lower_name: parent-project-11.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256482 - id: 78 version_id: 27 @@ -492,7 +492,7 @@ name: sub-module-11.0.0.pom lower_name: sub-module-11.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256483 - id: 79 version_id: 27 @@ -500,7 +500,7 @@ name: sub-module-11.0.0.jar lower_name: sub-module-11.0.0.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256483 - id: 80 version_id: 7 @@ -508,7 +508,7 @@ name: bar-1.0-20250503.071446-9.pom lower_name: bar-1.0-20250503.071446-9.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256486 - id: 82 version_id: 28 @@ -516,7 +516,7 @@ name: bar-11.0.0.pom lower_name: bar-11.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256488 - id: 83 version_id: 7 @@ -524,7 +524,7 @@ name: -bar-1.0-20250503.071451-10.pom lower_name: -bar-1.0-20250503.071451-10.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256491 - id: 84 version_id: 7 @@ -532,7 +532,7 @@ name: maven-metadata.xml lower_name: maven-metadata.xml composite_key: "" - is_lead: 0 + is_lead: false created_unix: 1746256491 - id: 85 version_id: 28 @@ -540,7 +540,7 @@ name: -bar-11.0.0.pom lower_name: -bar-11.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746256494 # broken uploads - id: 86 @@ -549,7 +549,7 @@ name: br-repo-jooq-1.2.4-sources.jar lower_name: br-repo-jooq-1.2.4-sources.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 174625649444986 - id: 87 version_id: 29 @@ -557,7 +557,7 @@ name: br-rest-webmvc-1.2.4.jar lower_name: br-rest-webmvc-1.2.4.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 174625649446161 - id: 88 version_id: 29 @@ -565,7 +565,7 @@ name: br-openapi-base-1.2.4.pom lower_name: br-openapi-base-1.2.4.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 174625649444734 - id: 89 version_id: 29 @@ -573,7 +573,7 @@ name: br-openapi-base-1.2.4.jar lower_name: br-openapi-base-1.2.4.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 174625649444746 - id: 90 version_id: 29 @@ -581,7 +581,7 @@ name: br-openapi-base-1.2.4-sources.jar lower_name: br-openapi-base-1.2.4-sources.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 174625649444775 - id: 91 version_id: 29 @@ -589,7 +589,7 @@ name: br-parent-1.2.4.pom lower_name: br-parent-1.2.4.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 174625649444852 - id: 92 version_id: 29 @@ -597,7 +597,7 @@ name: br-repo-in-memory-1.2.4.pom lower_name: br-repo-in-memory-1.2.4.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 174625649444900 - id: 93 version_id: 29 @@ -605,7 +605,7 @@ name: br-repo-in-memory-1.2.4.jar lower_name: br-repo-in-memory-1.2.4.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 174625649444911 - id: 94 version_id: 29 @@ -613,7 +613,7 @@ name: br-repo-in-memory-1.2.4-sources.jar lower_name: br-repo-in-memory-1.2.4-sources.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 174625649444922 - id: 95 version_id: 29 @@ -621,7 +621,7 @@ name: br-repo-jooq-1.2.4.pom lower_name: br-repo-jooq-1.2.4.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 174625649444953 - id: 96 version_id: 29 @@ -629,7 +629,7 @@ name: br-repo-jooq-1.2.4.jar lower_name: br-repo-jooq-1.2.4.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 174625649444969 - id: 97 version_id: 29 @@ -637,7 +637,7 @@ name: br-rest-webmvc-1.2.4-sources.jar lower_name: br-rest-webmvc-1.2.4-sources.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 174625649446161 - id: 98 version_id: 29 @@ -645,7 +645,7 @@ name: br-rest-webmvc-1.2.4.pom lower_name: br-rest-webmvc-1.2.4.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 174625649446195 - id: 99 version_id: 29 @@ -653,7 +653,7 @@ name: br-root-1.2.4.pom lower_name: br-root-1.2.4.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 174625649446217 - id: 100 version_id: 30 @@ -661,7 +661,7 @@ name: br-rest-webmvc-1.2.4.pom lower_name: br-rest-webmvc-1.2.4.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 174625649446311 - id: 101 version_id: 30 @@ -669,7 +669,7 @@ name: br-rest-webmvc-1.2.4.jar lower_name: br-rest-webmvc-1.2.4.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 174625649446312 - id: 102 version_id: 30 @@ -677,7 +677,7 @@ name: br-rest-webmvc-1.2.4-sources.jar lower_name: br-rest-webmvc-1.2.4-sources.jar composite_key: "" - is_lead: 0 + is_lead: false created_unix: 174625649446312 # collision - id: 103 @@ -686,7 +686,7 @@ name: bar-art-11.0.0.pom lower_name: bar-art-11.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746280832 - id: 104 version_id: 31 @@ -694,5 +694,5 @@ name: art-11.0.0.pom lower_name: art-11.0.0.pom composite_key: "" - is_lead: 1 + is_lead: true created_unix: 1746280843 diff --git a/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package_version.yml b/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package_version.yml index dbdb427adf..0ef8518a8a 100644 --- a/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package_version.yml +++ b/models/gitea_migrations/fixtures/Test_ChangeMavenArtifactConcatenation/package_version.yml @@ -4,7 +4,7 @@ version: 1.0-SNAPSHOT lower_version: 1.0-snapshot created_unix: 1746256357 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 2 @@ -13,7 +13,7 @@ version: 1.0-SNAPSHOT lower_version: 1.0-snapshot created_unix: 1746256358 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 3 @@ -22,7 +22,7 @@ version: 7.0.0 lower_version: 7.0.0 created_unix: 1746256360 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 4 @@ -31,7 +31,7 @@ version: 7.0.0 lower_version: 7.0.0 created_unix: 1746256361 - is_internal: 0 + is_internal: false metadata_json: '{"artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 5 @@ -40,7 +40,7 @@ version: 7.0.0 lower_version: 7.0.0 created_unix: 1746256364 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 6 @@ -49,7 +49,7 @@ version: 7.0.0 lower_version: 7.0.0 created_unix: 1746256365 - is_internal: 0 + is_internal: false metadata_json: '{"artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 7 @@ -58,7 +58,7 @@ version: 1.0-SNAPSHOT lower_version: 1.0-snapshot created_unix: 1746256367 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"foo","artifact_id":"-bar","name":"Example :: Parent "}' download_count: 0 - id: 8 @@ -67,7 +67,7 @@ version: 7.0.0 lower_version: 7.0.0 created_unix: 1746256370 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"foo","artifact_id":"-bar","name":"Example :: Parent "}' download_count: 0 - id: 9 @@ -76,7 +76,7 @@ version: 8.0.0 lower_version: 8.0.0 created_unix: 1746256389 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 10 @@ -85,7 +85,7 @@ version: 8.0.0 lower_version: 8.0.0 created_unix: 1746256390 - is_internal: 0 + is_internal: false metadata_json: '{"artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 11 @@ -94,7 +94,7 @@ version: 8.0.0 lower_version: 8.0.0 created_unix: 1746256393 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 12 @@ -103,7 +103,7 @@ version: 8.0.0 lower_version: 8.0.0 created_unix: 1746256394 - is_internal: 0 + is_internal: false metadata_json: '{"artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 13 @@ -112,7 +112,7 @@ version: 8.0.0 lower_version: 8.0.0 created_unix: 1746256399 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"foo","artifact_id":"-bar","name":"Example :: Parent "}' download_count: 0 - id: 14 @@ -121,7 +121,7 @@ version: 9.0.0 lower_version: 9.0.0 created_unix: 1746256419 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 15 @@ -130,7 +130,7 @@ version: 9.0.0 lower_version: 9.0.0 created_unix: 1746256420 - is_internal: 0 + is_internal: false metadata_json: '{"artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 16 @@ -139,7 +139,7 @@ version: 9.0.0 lower_version: 9.0.0 created_unix: 1746256423 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 17 @@ -148,7 +148,7 @@ version: 9.0.0 lower_version: 9.0.0 created_unix: 1746256424 - is_internal: 0 + is_internal: false metadata_json: '{"artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 18 @@ -157,7 +157,7 @@ version: 9.0.0 lower_version: 9.0.0 created_unix: 1746256429 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"foo","artifact_id":"-bar","name":"Example :: Parent "}' download_count: 0 - id: 19 @@ -166,7 +166,7 @@ version: 10.0.0 lower_version: 10.0.0 created_unix: 1746256449 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 20 @@ -175,7 +175,7 @@ version: 10.0.0 lower_version: 10.0.0 created_unix: 1746256450 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 21 @@ -184,7 +184,7 @@ version: 10.0.0 lower_version: 10.0.0 created_unix: 1746256452 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 22 @@ -193,7 +193,7 @@ version: 10.0.0 lower_version: 10.0.0 created_unix: 1746256453 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 23 @@ -202,7 +202,7 @@ version: 10.0.0 lower_version: 10.0.0 created_unix: 1746256459 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"foo","artifact_id":"-bar","name":"Example :: Parent "}' download_count: 0 - id: 24 @@ -211,7 +211,7 @@ version: 11.0.0 lower_version: 11.0.0 created_unix: 1746256478 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 25 @@ -220,7 +220,7 @@ version: 11.0.0 lower_version: 11.0.0 created_unix: 1746256479 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 26 @@ -229,7 +229,7 @@ version: 11.0.0 lower_version: 11.0.0 created_unix: 1746256482 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"parent-project","name":"Example :: Parent "}' download_count: 0 - id: 27 @@ -238,7 +238,7 @@ version: 11.0.0 lower_version: 11.0.0 created_unix: 1746256483 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.example","artifact_id":"sub-module","name":"Example :: SubModule ","dependencies":[{"group_id":"junit","artifact_id":"junit","version":"3.8.1"}]}' download_count: 0 - id: 28 @@ -247,7 +247,7 @@ version: 11.0.0 lower_version: 11.0.0 created_unix: 1746256488 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"foo","artifact_id":"-bar","name":"Example :: Parent "}' download_count: 0 # broken uploads @@ -257,7 +257,7 @@ version: 1.2.4 lower_version: 1.2.4 created_unix: 1746256488 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"com.broken","artifact_id":"br-root","name":"Foo"}' download_count: 0 - id: 30 @@ -266,7 +266,7 @@ version: 1.2.4 lower_version: 1.2.4 created_unix: 1746256488 - is_internal: 0 + is_internal: false metadata_json: '{"artifact_id":"br-rest-webmvc","name":"Foo :: REST :: Web MVC","dependencies":[{"group_id":"com.broken","artifact_id":"br-base"},{"group_id":"jakarta.servlet","artifact_id":"jakarta.servlet-api"},{"group_id":"jakarta.validation","artifact_id":"jakarta.validation-api"},{"group_id":"org.springframework","artifact_id":"spring-webmvc"},{"group_id":"org.springframework.hateoas","artifact_id":"spring-hateoas"},{"group_id":"org.springframework.boot","artifact_id":"spring-boot-starter-test"},{"group_id":"com.broken","artifact_id":"br-test"},{"group_id":"com.broken","artifact_id":"br-repo-in-memory"},{"group_id":"org.hibernate.validator","artifact_id":"hibernate-validator"},{"group_id":"org.glassfish.expressly","artifact_id":"expressly"}]}' download_count: 0 # collision @@ -276,6 +276,6 @@ version: 11.0.0 lower_version: 11.0.0 created_unix: 1746256488 - is_internal: 0 + is_internal: false metadata_json: '{"group_id":"group-bar","artifact_id":"art","name":"Example :: Parent "}' download_count: 0 diff --git a/models/gitea_migrations/fixtures/Test_v14ActionsApprovalAndTrustPopulateTableActionUser/action_run.yml b/models/gitea_migrations/fixtures/Test_v14ActionsApprovalAndTrustPopulateTableActionUser/action_run.yml index 78eb18a955..78ab756707 100644 --- a/models/gitea_migrations/fixtures/Test_v14ActionsApprovalAndTrustPopulateTableActionUser/action_run.yml +++ b/models/gitea_migrations/fixtures/Test_v14ActionsApprovalAndTrustPopulateTableActionUser/action_run.yml @@ -10,12 +10,12 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 # success started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false - id: 1001 @@ -29,12 +29,12 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 # success started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false - id: 1002 @@ -48,12 +48,12 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 # success started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false - id: 1003 @@ -67,12 +67,12 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 # success started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false - id: 1004 @@ -86,12 +86,12 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 # success started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false - id: 1005 @@ -105,12 +105,12 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 # success started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false - id: 1006 @@ -124,12 +124,12 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 # success started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false - id: 1007 @@ -143,9 +143,9 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 1 # success started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false diff --git a/models/gitea_migrations/test/tests.go b/models/gitea_migrations/test/tests.go index 6a4865194d..fc54b65626 100644 --- a/models/gitea_migrations/test/tests.go +++ b/models/gitea_migrations/test/tests.go @@ -26,6 +26,8 @@ import ( "github.com/stretchr/testify/require" "xorm.io/xorm" + + _ "github.com/jackc/pgx/v5/stdlib" // Import pgx driver ) // PrepareTestEnv prepares the test environment and reset the database. The skip parameter should usually be 0. @@ -210,7 +212,7 @@ func deleteDB() error { } return nil case setting.Database.Type.IsPostgreSQL(): - db, err := sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/?sslmode=%s", + db, err := sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@%s/?sslmode=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.SSLMode)) if err != nil { return err @@ -228,7 +230,7 @@ func deleteDB() error { // Check if we need to setup a specific schema if len(setting.Database.Schema) != 0 { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.Name, setting.Database.SSLMode)) if err != nil { return err diff --git a/models/gitea_migrations/v1_18/v229.go b/models/gitea_migrations/v1_18/v229.go index 00d794725f..b544e063d0 100644 --- a/models/gitea_migrations/v1_18/v229.go +++ b/models/gitea_migrations/v1_18/v229.go @@ -14,7 +14,7 @@ import ( func UpdateOpenMilestoneCounts(x *xorm.Engine) error { var openMilestoneIDs []int64 - err := x.Table("milestone").Select("id").Where(builder.Neq{"is_closed": 1}).Find(&openMilestoneIDs) + err := x.Table("milestone").Select("id").Where(builder.Neq{"is_closed": true}).Find(&openMilestoneIDs) if err != nil { return fmt.Errorf("error selecting open milestone IDs: %w", err) } diff --git a/models/issues/dependency.go b/models/issues/dependency.go index fab35dad12..9c429c57e6 100644 --- a/models/issues/dependency.go +++ b/models/issues/dependency.go @@ -215,7 +215,7 @@ func IssueNoDependenciesLeft(ctx context.Context, issue *Issue) (bool, error) { Select("issue.*"). Join("INNER", "issue", "issue.id = issue_dependency.dependency_id"). Where("issue_dependency.issue_id = ?", issue.ID). - And("issue.is_closed = ?", "0"). + And("issue.is_closed = ?", false). Exist(&Issue{}) return !exists, err diff --git a/models/issues/issue_user_test.go b/models/issues/issue_user_test.go index 77e6c5bc5a..4522b85ce2 100644 --- a/models/issues/issue_user_test.go +++ b/models/issues/issue_user_test.go @@ -41,10 +41,10 @@ func TestUpdateIssueUserByRead(t *testing.T) { issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1}) require.NoError(t, issues_model.UpdateIssueUserByRead(db.DefaultContext, 4, issue.ID)) - unittest.AssertExistsAndLoadBean(t, &issues_model.IssueUser{IssueID: issue.ID, UID: 4}, "is_read=1") + unittest.AssertExistsAndLoadBean(t, &issues_model.IssueUser{IssueID: issue.ID, UID: 4}, unittest.Cond("is_read = ?", true)) require.NoError(t, issues_model.UpdateIssueUserByRead(db.DefaultContext, 4, issue.ID)) - unittest.AssertExistsAndLoadBean(t, &issues_model.IssueUser{IssueID: issue.ID, UID: 4}, "is_read=1") + unittest.AssertExistsAndLoadBean(t, &issues_model.IssueUser{IssueID: issue.ID, UID: 4}, unittest.Cond("is_read = ?", true)) require.NoError(t, issues_model.UpdateIssueUserByRead(db.DefaultContext, unittest.NonexistentID, unittest.NonexistentID)) } @@ -56,6 +56,6 @@ func TestUpdateIssueUsersByMentions(t *testing.T) { uids := []int64{2, 5} require.NoError(t, issues_model.UpdateIssueUsersByMentions(db.DefaultContext, issue.ID, uids)) for _, uid := range uids { - unittest.AssertExistsAndLoadBean(t, &issues_model.IssueUser{IssueID: issue.ID, UID: uid}, "is_mentioned=1") + unittest.AssertExistsAndLoadBean(t, &issues_model.IssueUser{IssueID: issue.ID, UID: uid}, unittest.Cond("is_mentioned = ?", true)) } } diff --git a/models/issues/milestone_test.go b/models/issues/milestone_test.go index e486c55b24..6f90e6e243 100644 --- a/models/issues/milestone_test.go +++ b/models/issues/milestone_test.go @@ -307,7 +307,7 @@ func TestChangeMilestoneStatusByRepoIDAndID(t *testing.T) { unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: 1}, &issues_model.Milestone{}) require.NoError(t, issues_model.ChangeMilestoneStatusByRepoIDAndID(db.DefaultContext, 1, 1, false)) - unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1}, "is_closed=0") + unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1}, unittest.Cond("is_closed = ?", false)) unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: 1}, &issues_model.Milestone{}) } @@ -335,7 +335,7 @@ func TestUpdateMilestone(t *testing.T) { func TestUpdateMilestoneCounters(t *testing.T) { require.NoError(t, unittest.PrepareTestDatabase()) issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{MilestoneID: 1}, - "is_closed=0") + unittest.Cond("is_closed = ?", false)) issue.IsClosed = true issue.ClosedUnix = timeutil.TimeStampNow() diff --git a/models/user/fixtures/login_source.yml b/models/user/fixtures/login_source.yml index 3950f85964..cb37ea6366 100644 --- a/models/user/fixtures/login_source.yml +++ b/models/user/fixtures/login_source.yml @@ -2,7 +2,7 @@ id: 1001 type: 6 # OAuth2 name: OAuth2 authentication source - is_active: 1 + is_active: true cfg: '{"Provider":"invalid","ClientID":"invalid","ClientSecret":"invalid","AllowUsernameChange":true}' created_unix: 1753740851 updated_unix: 1753740851 diff --git a/modules/setting/database.go b/modules/setting/database.go index cac677e491..bbea81352b 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -277,6 +277,36 @@ func parsePostgreSQLHostPort(info string) (host, port string) { func getPostgreSQLConnectionString(dbHost, dbUser, dbPasswd, dbName, dbsslMode string) (connStr string) { dbName, dbParam, _ := strings.Cut(dbName, "?") + + // pgx multi-host specification: "host1:port1,host2:port2" + if strings.Contains(dbHost, ",") { + var hostParts []string + for host := range strings.SplitSeq(dbHost, ",") { + trimmed := strings.TrimSpace(host) + if trimmed == "" { + continue + } + h, p := parsePostgreSQLHostPort(trimmed) + hostParts = append(hostParts, net.JoinHostPort(h, p)) + } + + // Validate that we have at least one valid host after parsing + if len(hostParts) > 0 { + connURL := url.URL{ + Scheme: "postgres", + User: url.UserPassword(dbUser, dbPasswd), + Host: strings.Join(hostParts, ","), + Path: dbName, + OmitHost: false, + RawQuery: dbParam, + } + query := connURL.Query() + query.Set("sslmode", dbsslMode) + connURL.RawQuery = query.Encode() + return connURL.String() + } + } + host, port := parsePostgreSQLHostPort(dbHost) connURL := url.URL{ Scheme: "postgres", diff --git a/modules/setting/database_test.go b/modules/setting/database_test.go index ce816d53e8..fb3c884690 100644 --- a/modules/setting/database_test.go +++ b/modules/setting/database_test.go @@ -101,6 +101,51 @@ func Test_getPostgreSQLConnectionString(t *testing.T) { Name: "gitea?param=1", Output: "postgres://user:pass@localhost:1234/gitea?param=1&sslmode=", }, + { + // Multi-host with same ports + Host: "host1,host2,host3", + User: "user", + Passwd: "pass", + Name: "forgejo", + SSLMode: "disable", + Output: "postgres://user:pass@host1:5432,host2:5432,host3:5432/forgejo?sslmode=disable", + }, + { + // Multi-host with different ports + Host: "host1:5432,host2:5433", + User: "user", + Passwd: "pass", + Name: "forgejo", + SSLMode: "require", + Output: "postgres://user:pass@host1:5432,host2:5433/forgejo?sslmode=require", + }, + { + // Multi-host IPv6 + Host: "[::1]:1234,[::2]:2345", + User: "user", + Passwd: "pass", + Name: "forgejo", + SSLMode: "disable", + Output: "postgres://user:pass@[::1]:1234,[::2]:2345/forgejo?sslmode=disable", + }, + { + // Multi-host with spaces (should be trimmed) + Host: "host1:5432 , host2:5433 , host3", + User: "user", + Passwd: "pass", + Name: "forgejo", + SSLMode: "verify-full", + Output: "postgres://user:pass@host1:5432,host2:5433,host3:5432/forgejo?sslmode=verify-full", + }, + { + // Multi-host with database parameters + Host: "host1,host2", + User: "user", + Passwd: "pass", + Name: "forgejo?connect_timeout=10", + SSLMode: "disable", + Output: "postgres://user:pass@host1:5432,host2:5432/forgejo?connect_timeout=10&sslmode=disable", + }, } for _, test := range tests { @@ -120,9 +165,8 @@ func getPostgreSQLEngineGroupConnectionStrings(primaryHost, replicaHosts, user, // Build the replica connection strings. replicaConns := []string{} if strings.TrimSpace(replicaHosts) != "" { - // Split comma-separated replica host values. - hosts := strings.Split(replicaHosts, ",") - for _, h := range hosts { + // Split comma-separated replica host values + for h := range strings.SplitSeq(replicaHosts, ",") { trimmed := strings.TrimSpace(h) if trimmed != "" { replicaConns = append(replicaConns, diff --git a/routers/api/v1/repo/repo_test.go b/routers/api/v1/repo/repo_test.go index a6bd23ae06..f3c8256cfb 100644 --- a/routers/api/v1/repo/repo_test.go +++ b/routers/api/v1/repo/repo_test.go @@ -61,7 +61,7 @@ func TestRepoEdit(t *testing.T) { assert.Equal(t, http.StatusOK, ctx.Resp.Status()) unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ ID: 1, - }, unittest.Cond("name = ? AND is_archived = 1", *opts.Name)) + }, unittest.Cond("name = ? AND is_archived = ?", *opts.Name, true)) } func TestRepoEditNameChange(t *testing.T) { diff --git a/services/actions/TestActions_CancelOrApproveRun/action_run.yml b/services/actions/TestActions_CancelOrApproveRun/action_run.yml index b084007503..9267cf6f34 100644 --- a/services/actions/TestActions_CancelOrApproveRun/action_run.yml +++ b/services/actions/TestActions_CancelOrApproveRun/action_run.yml @@ -9,12 +9,12 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "synchronized" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 6 # running started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 concurrency_group: abc123 - @@ -28,11 +28,11 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "synchronized" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 5 # waiting started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 1 + need_approval: true approved_by: 0 concurrency_group: def435 diff --git a/services/actions/TestActions_CancelOrApproveRun/action_run_job.yml b/services/actions/TestActions_CancelOrApproveRun/action_run_job.yml index 610f34e274..34abcd791c 100644 --- a/services/actions/TestActions_CancelOrApproveRun/action_run_job.yml +++ b/services/actions/TestActions_CancelOrApproveRun/action_run_job.yml @@ -4,7 +4,7 @@ repo_id: 63 owner_id: 2 commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 @@ -18,7 +18,7 @@ repo_id: 63 owner_id: 2 commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_2 attempt: 0 job_id: job_2 @@ -32,7 +32,7 @@ repo_id: 63 owner_id: 2 commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 diff --git a/services/actions/TestActions_CancelOrApproveRun/action_task.yml b/services/actions/TestActions_CancelOrApproveRun/action_task.yml index 5aaafe97a1..20d95e7056 100644 --- a/services/actions/TestActions_CancelOrApproveRun/action_task.yml +++ b/services/actions/TestActions_CancelOrApproveRun/action_task.yml @@ -9,15 +9,15 @@ repo_id: 63 owner_id: 2 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: 8d8ef48297195edcc8e22c70b3020eaa06c52976db67d39b4260c64a69a2cc1508825121b7b8394e48e00b1bf8718b2a867e token_salt: jVuKnSPGgy token_last_eight: eeb1a71a log_filename: artifact-test2/2f/47.log - log_in_storage: 1 + log_in_storage: true log_length: 707 log_size: 90179 - log_expired: 0 + log_expired: false - id: 711900 job_id: 11900 @@ -29,12 +29,12 @@ repo_id: 63 owner_id: 2 commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0 - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: 7d8ef48297195edcc8e22c70b3020eaa06c52976db67d39b4260c64a69a2cc1508825121b7b8394e48e00b1bf8718b2a867e token_salt: jVuKnSPGgy token_last_eight: eeb1a71a log_filename: artifact-test2/2f/47.log - log_in_storage: 1 + log_in_storage: true log_length: 707 log_size: 90179 - log_expired: 0 + log_expired: false diff --git a/services/actions/TestCancelPreviousJobs/action_run_job.yml b/services/actions/TestCancelPreviousJobs/action_run_job.yml index 98a39bbe4e..2ee89c4ec3 100644 --- a/services/actions/TestCancelPreviousJobs/action_run_job.yml +++ b/services/actions/TestCancelPreviousJobs/action_run_job.yml @@ -4,7 +4,7 @@ repo_id: 63 owner_id: 2 commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 diff --git a/services/actions/TestCancelPreviousWithConcurrencyGroup/action_run.yml b/services/actions/TestCancelPreviousWithConcurrencyGroup/action_run.yml index 09555ec356..f019989597 100644 --- a/services/actions/TestCancelPreviousWithConcurrencyGroup/action_run.yml +++ b/services/actions/TestCancelPreviousWithConcurrencyGroup/action_run.yml @@ -9,12 +9,12 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 6 # running started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 concurrency_group: abc123 - @@ -28,11 +28,11 @@ ref: "refs/heads/main" commit_sha: "97f29ee599c373c729132a5c46a046978311e0ee" trigger_event: "workflow_dispatch" - is_fork_pull_request: 0 + is_fork_pull_request: false status: 6 # running started: 1683636528 created: 1683636108 updated: 1683636626 - need_approval: 0 + need_approval: false approved_by: 0 concurrency_group: abc123 diff --git a/services/actions/TestCancelPreviousWithConcurrencyGroup/action_run_job.yml b/services/actions/TestCancelPreviousWithConcurrencyGroup/action_run_job.yml index 9e4fd930b6..3dd805de70 100644 --- a/services/actions/TestCancelPreviousWithConcurrencyGroup/action_run_job.yml +++ b/services/actions/TestCancelPreviousWithConcurrencyGroup/action_run_job.yml @@ -4,7 +4,7 @@ repo_id: 63 owner_id: 2 commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 @@ -18,7 +18,7 @@ repo_id: 63 owner_id: 2 commit_sha: 97f29ee599c373c729132a5c46a046978311e0ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 diff --git a/services/actions/TestServicesActions_TransferLingeringLogs/action_task.yml b/services/actions/TestServicesActions_TransferLingeringLogs/action_task.yml index aab10191a6..c3dc3b06d5 100644 --- a/services/actions/TestServicesActions_TransferLingeringLogs/action_task.yml +++ b/services/actions/TestServicesActions_TransferLingeringLogs/action_task.yml @@ -7,11 +7,11 @@ repo_id: 4 owner_id: 1 commit_sha: "1000" - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: "1000" log_filename: path1 log_in_storage: false - log_expired: 0 + log_expired: false created: 1732575600 # date +%s --date 2024-11-26 updated: 1732575605 # a few seconds later @@ -23,11 +23,11 @@ repo_id: 4 owner_id: 1 commit_sha: "2000" - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: "2000" log_filename: path2 log_in_storage: false - log_expired: 0 + log_expired: false created: 1732921200 # date +%s --date 2024-11-30 updated: 1732921205 # a few seconds later @@ -39,11 +39,11 @@ repo_id: 4 owner_id: 1 commit_sha: "3000" - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: "3000" log_filename: path3 log_in_storage: true - log_expired: 0 + log_expired: false created: 1732575600 # date +%s --date 2024-11-26 updated: 1732575605 # a few seconds later @@ -55,11 +55,11 @@ repo_id: 4 owner_id: 1 commit_sha: "4000" - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: "4000" log_filename: path4 log_in_storage: false - log_expired: 0 + log_expired: false created: 1732575600 # date +%s --date 2024-11-26 updated: 1732575605 # a few seconds later @@ -71,10 +71,10 @@ repo_id: 4 owner_id: 1 commit_sha: "5000" - is_fork_pull_request: 0 + is_fork_pull_request: false token_hash: "5000" log_filename: path5 log_in_storage: false - log_expired: 0 + log_expired: false created: 1732575600 # date +%s --date 2024-11-26 updated: 1732575605 # a few seconds later diff --git a/services/issue/commit_test.go b/services/issue/commit_test.go index e3a41d2305..e38e10e2fc 100644 --- a/services/issue/commit_test.go +++ b/services/issue/commit_test.go @@ -60,10 +60,10 @@ func TestUpdateIssuesCommit(t *testing.T) { issueBean := &issues_model.Issue{RepoID: repo.ID, Index: 4} unittest.AssertNotExistsBean(t, commentBean) - unittest.AssertNotExistsBean(t, &issues_model.Issue{RepoID: repo.ID, Index: 2}, "is_closed=1") + unittest.AssertNotExistsBean(t, &issues_model.Issue{RepoID: repo.ID, Index: 2}, unittest.Cond("is_closed = ?", true)) require.NoError(t, UpdateIssuesCommit(db.DefaultContext, user, repo, pushCommits, repo.DefaultBranch)) unittest.AssertExistsAndLoadBean(t, commentBean) - unittest.AssertExistsAndLoadBean(t, issueBean, "is_closed=1") + unittest.AssertExistsAndLoadBean(t, issueBean, unittest.Cond("is_closed = ?", true)) unittest.CheckConsistencyFor(t, &activities_model.Action{}) // Test that push to a non-default branch closes no issue. @@ -87,10 +87,10 @@ func TestUpdateIssuesCommit(t *testing.T) { issueBean = &issues_model.Issue{RepoID: repo.ID, Index: 1} unittest.AssertNotExistsBean(t, commentBean) - unittest.AssertNotExistsBean(t, &issues_model.Issue{RepoID: repo.ID, Index: 1}, "is_closed=1") + unittest.AssertNotExistsBean(t, &issues_model.Issue{RepoID: repo.ID, Index: 1}, unittest.Cond("is_closed = ?", true)) require.NoError(t, UpdateIssuesCommit(db.DefaultContext, user, repo, pushCommits, "non-existing-branch")) unittest.AssertExistsAndLoadBean(t, commentBean) - unittest.AssertNotExistsBean(t, issueBean, "is_closed=1") + unittest.AssertNotExistsBean(t, issueBean, unittest.Cond("is_closed = ?", true)) unittest.CheckConsistencyFor(t, &activities_model.Action{}) pushCommits = []*repository.PushCommit{ @@ -113,10 +113,10 @@ func TestUpdateIssuesCommit(t *testing.T) { issueBean = &issues_model.Issue{RepoID: repo.ID, Index: 1} unittest.AssertNotExistsBean(t, commentBean) - unittest.AssertNotExistsBean(t, &issues_model.Issue{RepoID: repo.ID, Index: 1}, "is_closed=1") + unittest.AssertNotExistsBean(t, &issues_model.Issue{RepoID: repo.ID, Index: 1}, unittest.Cond("is_closed = ?", true)) require.NoError(t, UpdateIssuesCommit(db.DefaultContext, user, repo, pushCommits, repo.DefaultBranch)) unittest.AssertExistsAndLoadBean(t, commentBean) - unittest.AssertExistsAndLoadBean(t, issueBean, "is_closed=1") + unittest.AssertExistsAndLoadBean(t, issueBean, unittest.Cond("is_closed = ?", true)) unittest.CheckConsistencyFor(t, &activities_model.Action{}) } @@ -139,9 +139,9 @@ func TestUpdateIssuesCommit_Colon(t *testing.T) { issueBean := &issues_model.Issue{RepoID: repo.ID, Index: 4} - unittest.AssertNotExistsBean(t, &issues_model.Issue{RepoID: repo.ID, Index: 2}, "is_closed=1") + unittest.AssertNotExistsBean(t, &issues_model.Issue{RepoID: repo.ID, Index: 2}, unittest.Cond("is_closed = ?", true)) require.NoError(t, UpdateIssuesCommit(db.DefaultContext, user, repo, pushCommits, repo.DefaultBranch)) - unittest.AssertExistsAndLoadBean(t, issueBean, "is_closed=1") + unittest.AssertExistsAndLoadBean(t, issueBean, unittest.Cond("is_closed = ?", true)) unittest.CheckConsistencyFor(t, &activities_model.Action{}) } @@ -172,10 +172,10 @@ func TestUpdateIssuesCommit_Issue5957(t *testing.T) { issueBean := &issues_model.Issue{RepoID: repo.ID, Index: 2, ID: 7} unittest.AssertNotExistsBean(t, commentBean) - unittest.AssertNotExistsBean(t, issueBean, "is_closed=1") + unittest.AssertNotExistsBean(t, issueBean, unittest.Cond("is_closed = ?", true)) require.NoError(t, UpdateIssuesCommit(db.DefaultContext, user, repo, pushCommits, "non-existing-branch")) unittest.AssertExistsAndLoadBean(t, commentBean) - unittest.AssertExistsAndLoadBean(t, issueBean, "is_closed=1") + unittest.AssertExistsAndLoadBean(t, issueBean, unittest.Cond("is_closed = ?", true)) unittest.CheckConsistencyFor(t, &activities_model.Action{}) } @@ -207,10 +207,10 @@ func TestUpdateIssuesCommit_AnotherRepo(t *testing.T) { issueBean := &issues_model.Issue{RepoID: 1, Index: 1, ID: 1} unittest.AssertNotExistsBean(t, commentBean) - unittest.AssertNotExistsBean(t, issueBean, "is_closed=1") + unittest.AssertNotExistsBean(t, issueBean, unittest.Cond("is_closed = ?", true)) require.NoError(t, UpdateIssuesCommit(db.DefaultContext, user, repo, pushCommits, repo.DefaultBranch)) unittest.AssertExistsAndLoadBean(t, commentBean) - unittest.AssertExistsAndLoadBean(t, issueBean, "is_closed=1") + unittest.AssertExistsAndLoadBean(t, issueBean, unittest.Cond("is_closed = ?", true)) unittest.CheckConsistencyFor(t, &activities_model.Action{}) } @@ -242,10 +242,10 @@ func TestUpdateIssuesCommit_AnotherRepo_FullAddress(t *testing.T) { issueBean := &issues_model.Issue{RepoID: 1, Index: 1, ID: 1} unittest.AssertNotExistsBean(t, commentBean) - unittest.AssertNotExistsBean(t, issueBean, "is_closed=1") + unittest.AssertNotExistsBean(t, issueBean, unittest.Cond("is_closed = ?", true)) require.NoError(t, UpdateIssuesCommit(db.DefaultContext, user, repo, pushCommits, repo.DefaultBranch)) unittest.AssertExistsAndLoadBean(t, commentBean) - unittest.AssertExistsAndLoadBean(t, issueBean, "is_closed=1") + unittest.AssertExistsAndLoadBean(t, issueBean, unittest.Cond("is_closed = ?", true)) unittest.CheckConsistencyFor(t, &activities_model.Action{}) } @@ -292,10 +292,10 @@ func TestUpdateIssuesCommit_AnotherRepoNoPermission(t *testing.T) { unittest.AssertNotExistsBean(t, commentBean) unittest.AssertNotExistsBean(t, commentBean2) - unittest.AssertNotExistsBean(t, issueBean, "is_closed=1") + unittest.AssertNotExistsBean(t, issueBean, unittest.Cond("is_closed = ?", true)) require.NoError(t, UpdateIssuesCommit(db.DefaultContext, user, repo, pushCommits, repo.DefaultBranch)) unittest.AssertNotExistsBean(t, commentBean) unittest.AssertNotExistsBean(t, commentBean2) - unittest.AssertNotExistsBean(t, issueBean, "is_closed=1") + unittest.AssertNotExistsBean(t, issueBean, unittest.Cond("is_closed = ?", true)) unittest.CheckConsistencyFor(t, &activities_model.Action{}) } diff --git a/tests/integration/fixtures/TestActionConcurrencyGroupQueue/action_run_job.yml b/tests/integration/fixtures/TestActionConcurrencyGroupQueue/action_run_job.yml index c8c12085d3..dd1d47f70c 100644 --- a/tests/integration/fixtures/TestActionConcurrencyGroupQueue/action_run_job.yml +++ b/tests/integration/fixtures/TestActionConcurrencyGroupQueue/action_run_job.yml @@ -4,7 +4,7 @@ repo_id: 4 owner_id: 1 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 @@ -18,7 +18,7 @@ repo_id: 4 owner_id: 1 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 @@ -32,7 +32,7 @@ repo_id: 4 owner_id: 1 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 diff --git a/tests/integration/fixtures/TestActionConcurrencyRunnerFiltering/action_run_job.yml b/tests/integration/fixtures/TestActionConcurrencyRunnerFiltering/action_run_job.yml index 17d5b6426a..ef807fee22 100644 --- a/tests/integration/fixtures/TestActionConcurrencyRunnerFiltering/action_run_job.yml +++ b/tests/integration/fixtures/TestActionConcurrencyRunnerFiltering/action_run_job.yml @@ -4,7 +4,7 @@ repo_id: 62 owner_id: 2 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 @@ -18,7 +18,7 @@ repo_id: 4 owner_id: 3 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 @@ -32,7 +32,7 @@ repo_id: 1 owner_id: 2 commit_sha: 985f0301dba5e7b34be866819cd15ad3d8f508ee - is_fork_pull_request: 0 + is_fork_pull_request: false name: job_1 attempt: 0 job_id: job_1 diff --git a/tests/integration/migration-test/migration_test.go b/tests/integration/migration-test/migration_test.go index 04ed353edc..2bc57142e2 100644 --- a/tests/integration/migration-test/migration_test.go +++ b/tests/integration/migration-test/migration_test.go @@ -29,6 +29,7 @@ import ( "forgejo.org/modules/util" "forgejo.org/tests" + _ "github.com/jackc/pgx/v5/stdlib" // Import pgx driver "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "xorm.io/xorm" @@ -193,11 +194,11 @@ func restoreOldDB(t *testing.T, version string) bool { var db *sql.DB var err error if setting.Database.Host[0] == '/' { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@/?sslmode=%s&host=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@/?sslmode=%s&host=%s", setting.Database.User, setting.Database.Passwd, setting.Database.SSLMode, setting.Database.Host)) require.NoError(t, err) } else { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/?sslmode=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@%s/?sslmode=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.SSLMode)) require.NoError(t, err) } @@ -213,10 +214,10 @@ func restoreOldDB(t *testing.T, version string) bool { // Check if we need to setup a specific schema if len(setting.Database.Schema) != 0 { if setting.Database.Host[0] == '/' { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@/%s?sslmode=%s&host=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@/%s?sslmode=%s&host=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Name, setting.Database.SSLMode, setting.Database.Host)) } else { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.Name, setting.Database.SSLMode)) } require.NoError(t, err) @@ -244,10 +245,10 @@ func restoreOldDB(t *testing.T, version string) bool { } if setting.Database.Host[0] == '/' { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@/%s?sslmode=%s&host=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@/%s?sslmode=%s&host=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Name, setting.Database.SSLMode, setting.Database.Host)) } else { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.Name, setting.Database.SSLMode)) } require.NoError(t, err) diff --git a/tests/test_utils.go b/tests/test_utils.go index 3034375eb1..293856e1b3 100644 --- a/tests/test_utils.go +++ b/tests/test_utils.go @@ -47,6 +47,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "xorm.io/xorm/convert" + + _ "github.com/jackc/pgx/v5/stdlib" // Import pgx driver ) func exitf(format string, args ...any) { @@ -128,10 +130,10 @@ func InitTest(requireGitea bool) { var db *sql.DB var err error if setting.Database.Host[0] == '/' { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@/%s?sslmode=%s&host=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@/%s?sslmode=%s&host=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Name, setting.Database.SSLMode, setting.Database.Host)) } else { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.Name, setting.Database.SSLMode)) } @@ -157,10 +159,10 @@ func InitTest(requireGitea bool) { db.Close() if setting.Database.Host[0] == '/' { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@/%s?sslmode=%s&host=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@/%s?sslmode=%s&host=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Name, setting.Database.SSLMode, setting.Database.Host)) } else { - db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", + db, err = sql.Open("pgx", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.Name, setting.Database.SSLMode)) } // This is a different db object; requires a different Close()