woodpecker/pkg/store/builtin/repo_sql.go

583 lines
8.6 KiB
Go
Raw Normal View History

2015-06-13 23:48:06 +00:00
package builtin
// DO NOT EDIT
// code generated by go:generate
import (
"database/sql"
"encoding/json"
. "github.com/drone/drone/pkg/types"
)
var _ = json.Marshal
// generic database interface, matching both *sql.Db and *sql.Tx
type repoDB interface {
Exec(query string, args ...interface{}) (sql.Result, error)
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryRow(query string, args ...interface{}) *sql.Row
}
func getRepo(db repoDB, query string, args ...interface{}) (*Repo, error) {
row := db.QueryRow(query, args...)
return scanRepo(row)
}
func getRepos(db repoDB, query string, args ...interface{}) ([]*Repo, error) {
rows, err := db.Query(query, args...)
if err != nil {
return nil, err
}
defer rows.Close()
return scanRepos(rows)
}
func createRepo(db repoDB, query string, v *Repo) error {
var v0 int64
var v1 string
var v2 string
var v3 string
var v4 string
var v5 string
2015-06-19 01:50:57 +00:00
var v6 string
2015-06-13 23:48:06 +00:00
var v7 string
2015-08-03 07:10:43 +00:00
var v8 string
2015-06-19 01:50:57 +00:00
var v9 bool
2015-08-03 07:10:43 +00:00
var v10 bool
var v11 int64
2015-06-19 01:50:57 +00:00
var v12 string
2015-08-03 07:10:43 +00:00
var v13 string
2015-06-13 23:48:06 +00:00
var v14 bool
2015-06-19 01:50:57 +00:00
var v15 bool
2015-08-03 07:10:43 +00:00
var v16 bool
var v17 []byte
var v18 string
2015-06-13 23:48:06 +00:00
v0 = v.UserID
v1 = v.Owner
v2 = v.Name
v3 = v.FullName
2015-08-03 07:10:43 +00:00
v4 = v.Avatar
v5 = v.Self
v6 = v.Link
v7 = v.Clone
v8 = v.Branch
v9 = v.Private
v10 = v.Trusted
v11 = v.Timeout
2015-06-19 01:50:57 +00:00
if v.Keys != nil {
2015-08-03 07:10:43 +00:00
v12 = v.Keys.Public
v13 = v.Keys.Private
2015-06-19 01:50:57 +00:00
}
if v.Hooks != nil {
2015-08-03 07:10:43 +00:00
v14 = v.Hooks.PullRequest
v15 = v.Hooks.Push
v16 = v.Hooks.Tags
2015-06-19 01:50:57 +00:00
}
2015-08-03 07:10:43 +00:00
v17, _ = json.Marshal(v.Params)
v18 = v.Hash
2015-06-13 23:48:06 +00:00
res, err := db.Exec(query,
&v0,
&v1,
&v2,
&v3,
&v4,
&v5,
&v6,
&v7,
&v8,
&v9,
&v10,
&v11,
&v12,
&v13,
&v14,
&v15,
&v16,
2015-08-03 07:10:43 +00:00
&v17,
&v18,
2015-06-13 23:48:06 +00:00
)
if err != nil {
return err
}
v.ID, err = res.LastInsertId()
return err
}
func updateRepo(db repoDB, query string, v *Repo) error {
var v0 int64
var v1 int64
var v2 string
var v3 string
var v4 string
var v5 string
var v6 string
2015-06-19 01:50:57 +00:00
var v7 string
2015-06-13 23:48:06 +00:00
var v8 string
2015-08-03 07:10:43 +00:00
var v9 string
2015-06-19 01:50:57 +00:00
var v10 bool
2015-08-03 07:10:43 +00:00
var v11 bool
var v12 int64
2015-06-19 01:50:57 +00:00
var v13 string
2015-08-03 07:10:43 +00:00
var v14 string
2015-06-13 23:48:06 +00:00
var v15 bool
2015-06-19 01:50:57 +00:00
var v16 bool
2015-08-03 07:10:43 +00:00
var v17 bool
var v18 []byte
var v19 string
2015-06-13 23:48:06 +00:00
v0 = v.ID
v1 = v.UserID
v2 = v.Owner
v3 = v.Name
v4 = v.FullName
2015-08-03 07:10:43 +00:00
v5 = v.Avatar
v6 = v.Self
v7 = v.Link
v8 = v.Clone
v9 = v.Branch
v10 = v.Private
v11 = v.Trusted
v12 = v.Timeout
2015-06-19 01:50:57 +00:00
if v.Keys != nil {
2015-08-03 07:10:43 +00:00
v13 = v.Keys.Public
v14 = v.Keys.Private
2015-06-19 01:50:57 +00:00
}
if v.Hooks != nil {
2015-08-03 07:10:43 +00:00
v15 = v.Hooks.PullRequest
v16 = v.Hooks.Push
v17 = v.Hooks.Tags
2015-06-19 01:50:57 +00:00
}
2015-08-03 07:10:43 +00:00
v18, _ = json.Marshal(v.Params)
v19 = v.Hash
2015-06-13 23:48:06 +00:00
_, err := db.Exec(query,
&v1,
&v2,
&v3,
&v4,
&v5,
&v6,
&v7,
&v8,
&v9,
&v10,
&v11,
&v12,
&v13,
&v14,
&v15,
&v16,
&v17,
2015-08-03 07:10:43 +00:00
&v18,
&v19,
2015-06-13 23:48:06 +00:00
&v0,
)
return err
}
func scanRepo(row *sql.Row) (*Repo, error) {
var v0 int64
var v1 int64
var v2 string
var v3 string
var v4 string
var v5 string
var v6 string
2015-06-19 01:50:57 +00:00
var v7 string
2015-06-13 23:48:06 +00:00
var v8 string
2015-08-03 07:10:43 +00:00
var v9 string
2015-06-19 01:50:57 +00:00
var v10 bool
2015-08-03 07:10:43 +00:00
var v11 bool
var v12 int64
2015-06-19 01:50:57 +00:00
var v13 string
2015-08-03 07:10:43 +00:00
var v14 string
2015-06-13 23:48:06 +00:00
var v15 bool
2015-06-19 01:50:57 +00:00
var v16 bool
2015-08-03 07:10:43 +00:00
var v17 bool
var v18 []byte
var v19 string
2015-06-13 23:48:06 +00:00
err := row.Scan(
&v0,
&v1,
&v2,
&v3,
&v4,
&v5,
&v6,
&v7,
&v8,
&v9,
&v10,
&v11,
&v12,
&v13,
&v14,
&v15,
&v16,
&v17,
2015-08-03 07:10:43 +00:00
&v18,
&v19,
2015-06-13 23:48:06 +00:00
)
if err != nil {
return nil, err
}
v := &Repo{}
v.ID = v0
v.UserID = v1
v.Owner = v2
v.Name = v3
v.FullName = v4
2015-08-03 07:10:43 +00:00
v.Avatar = v5
v.Self = v6
v.Link = v7
v.Clone = v8
v.Branch = v9
v.Private = v10
v.Trusted = v11
v.Timeout = v12
2015-06-19 01:50:57 +00:00
v.Keys = &Keypair{}
2015-08-03 07:10:43 +00:00
v.Keys.Public = v13
v.Keys.Private = v14
2015-06-19 01:50:57 +00:00
v.Hooks = &Hooks{}
2015-08-03 07:10:43 +00:00
v.Hooks.PullRequest = v15
v.Hooks.Push = v16
v.Hooks.Tags = v17
json.Unmarshal(v18, &v.Params)
v.Hash = v19
2015-06-13 23:48:06 +00:00
return v, nil
}
func scanRepos(rows *sql.Rows) ([]*Repo, error) {
var err error
var vv []*Repo
for rows.Next() {
var v0 int64
var v1 int64
var v2 string
var v3 string
var v4 string
var v5 string
var v6 string
2015-06-19 01:50:57 +00:00
var v7 string
2015-06-13 23:48:06 +00:00
var v8 string
2015-08-03 07:10:43 +00:00
var v9 string
2015-06-19 01:50:57 +00:00
var v10 bool
2015-08-03 07:10:43 +00:00
var v11 bool
var v12 int64
2015-06-19 01:50:57 +00:00
var v13 string
2015-08-03 07:10:43 +00:00
var v14 string
2015-06-13 23:48:06 +00:00
var v15 bool
2015-06-19 01:50:57 +00:00
var v16 bool
2015-08-03 07:10:43 +00:00
var v17 bool
var v18 []byte
var v19 string
2015-06-13 23:48:06 +00:00
err = rows.Scan(
&v0,
&v1,
&v2,
&v3,
&v4,
&v5,
&v6,
&v7,
&v8,
&v9,
&v10,
&v11,
&v12,
&v13,
&v14,
&v15,
&v16,
&v17,
2015-08-03 07:10:43 +00:00
&v18,
&v19,
2015-06-13 23:48:06 +00:00
)
if err != nil {
return vv, err
}
v := &Repo{}
v.ID = v0
v.UserID = v1
v.Owner = v2
v.Name = v3
v.FullName = v4
2015-08-03 07:10:43 +00:00
v.Avatar = v5
v.Self = v6
v.Link = v7
v.Clone = v8
v.Branch = v9
v.Private = v10
v.Trusted = v11
v.Timeout = v12
2015-06-19 01:50:57 +00:00
v.Keys = &Keypair{}
2015-08-03 07:10:43 +00:00
v.Keys.Public = v13
v.Keys.Private = v14
2015-06-19 01:50:57 +00:00
v.Hooks = &Hooks{}
2015-08-03 07:10:43 +00:00
v.Hooks.PullRequest = v15
v.Hooks.Push = v16
v.Hooks.Tags = v17
json.Unmarshal(v18, &v.Params)
v.Hash = v19
2015-06-13 23:48:06 +00:00
vv = append(vv, v)
}
return vv, rows.Err()
}
const stmtRepoSelectList = `
SELECT
repo_id
,repo_user_id
,repo_owner
,repo_name
,repo_full_name
2015-08-03 07:10:43 +00:00
,repo_avatar
2015-06-13 23:48:06 +00:00
,repo_self
,repo_link
,repo_clone
,repo_branch
2015-06-19 01:50:57 +00:00
,repo_private
2015-06-13 23:48:06 +00:00
,repo_trusted
2015-06-19 01:50:57 +00:00
,repo_timeout
,repo_keys_public
,repo_keys_private
,repo_hooks_pull_request
,repo_hooks_push
,repo_hooks_tags
2015-06-13 23:48:06 +00:00
,repo_params
,repo_hash
2015-06-13 23:48:06 +00:00
FROM repos
`
const stmtRepoSelectRange = `
SELECT
repo_id
,repo_user_id
,repo_owner
,repo_name
,repo_full_name
2015-08-03 07:10:43 +00:00
,repo_avatar
2015-06-13 23:48:06 +00:00
,repo_self
,repo_link
,repo_clone
,repo_branch
2015-06-19 01:50:57 +00:00
,repo_private
2015-06-13 23:48:06 +00:00
,repo_trusted
2015-06-19 01:50:57 +00:00
,repo_timeout
,repo_keys_public
,repo_keys_private
,repo_hooks_pull_request
,repo_hooks_push
,repo_hooks_tags
2015-06-13 23:48:06 +00:00
,repo_params
,repo_hash
2015-06-13 23:48:06 +00:00
FROM repos
LIMIT ? OFFSET ?
`
const stmtRepoSelect = `
SELECT
repo_id
,repo_user_id
,repo_owner
,repo_name
,repo_full_name
2015-08-03 07:10:43 +00:00
,repo_avatar
2015-06-13 23:48:06 +00:00
,repo_self
,repo_link
,repo_clone
,repo_branch
2015-06-19 01:50:57 +00:00
,repo_private
2015-06-13 23:48:06 +00:00
,repo_trusted
2015-06-19 01:50:57 +00:00
,repo_timeout
,repo_keys_public
,repo_keys_private
,repo_hooks_pull_request
,repo_hooks_push
,repo_hooks_tags
2015-06-13 23:48:06 +00:00
,repo_params
,repo_hash
2015-06-13 23:48:06 +00:00
FROM repos
WHERE repo_id = ?
`
const stmtRepoSelectRepoFullName = `
2015-06-13 23:48:06 +00:00
SELECT
repo_id
,repo_user_id
,repo_owner
,repo_name
,repo_full_name
2015-08-03 07:10:43 +00:00
,repo_avatar
2015-06-13 23:48:06 +00:00
,repo_self
,repo_link
,repo_clone
,repo_branch
2015-06-19 01:50:57 +00:00
,repo_private
,repo_trusted
2015-06-13 23:48:06 +00:00
,repo_timeout
2015-06-19 01:50:57 +00:00
,repo_keys_public
,repo_keys_private
,repo_hooks_pull_request
,repo_hooks_push
,repo_hooks_tags
,repo_params
,repo_hash
2015-06-19 01:50:57 +00:00
FROM repos
WHERE repo_full_name = ?
2015-06-19 01:50:57 +00:00
`
const stmtRepoSelectRepoUserId = `
2015-06-19 01:50:57 +00:00
SELECT
repo_id
,repo_user_id
,repo_owner
,repo_name
,repo_full_name
2015-08-03 07:10:43 +00:00
,repo_avatar
2015-06-19 01:50:57 +00:00
,repo_self
,repo_link
,repo_clone
,repo_branch
,repo_private
2015-06-13 23:48:06 +00:00
,repo_trusted
2015-06-19 01:50:57 +00:00
,repo_timeout
,repo_keys_public
,repo_keys_private
,repo_hooks_pull_request
,repo_hooks_push
,repo_hooks_tags
2015-06-13 23:48:06 +00:00
,repo_params
,repo_hash
2015-06-13 23:48:06 +00:00
FROM repos
WHERE repo_user_id = ?
2015-06-13 23:48:06 +00:00
`
const stmtRepoSelectRepoOwnerName = `
2015-06-13 23:48:06 +00:00
SELECT
repo_id
,repo_user_id
,repo_owner
,repo_name
,repo_full_name
2015-08-03 07:10:43 +00:00
,repo_avatar
2015-06-13 23:48:06 +00:00
,repo_self
,repo_link
,repo_clone
,repo_branch
2015-06-19 01:50:57 +00:00
,repo_private
2015-06-13 23:48:06 +00:00
,repo_trusted
2015-06-19 01:50:57 +00:00
,repo_timeout
,repo_keys_public
,repo_keys_private
,repo_hooks_pull_request
,repo_hooks_push
,repo_hooks_tags
2015-06-13 23:48:06 +00:00
,repo_params
,repo_hash
2015-06-13 23:48:06 +00:00
FROM repos
WHERE repo_owner = ?
AND repo_name = ?
2015-06-13 23:48:06 +00:00
`
2015-06-19 01:50:57 +00:00
const stmtRepoSelectCount = `
SELECT count(1)
FROM repos
`
2015-06-13 23:48:06 +00:00
const stmtRepoInsert = `
INSERT INTO repos (
repo_user_id
,repo_owner
,repo_name
,repo_full_name
2015-08-03 07:10:43 +00:00
,repo_avatar
2015-06-13 23:48:06 +00:00
,repo_self
,repo_link
,repo_clone
,repo_branch
2015-06-19 01:50:57 +00:00
,repo_private
2015-06-13 23:48:06 +00:00
,repo_trusted
2015-06-19 01:50:57 +00:00
,repo_timeout
,repo_keys_public
,repo_keys_private
,repo_hooks_pull_request
,repo_hooks_push
,repo_hooks_tags
2015-06-13 23:48:06 +00:00
,repo_params
,repo_hash
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
2015-06-13 23:48:06 +00:00
`
const stmtRepoUpdate = `
UPDATE repos SET
repo_user_id = ?
,repo_owner = ?
,repo_name = ?
,repo_full_name = ?
2015-08-03 07:10:43 +00:00
,repo_avatar = ?
2015-06-13 23:48:06 +00:00
,repo_self = ?
,repo_link = ?
,repo_clone = ?
,repo_branch = ?
2015-06-19 01:50:57 +00:00
,repo_private = ?
2015-06-13 23:48:06 +00:00
,repo_trusted = ?
2015-06-19 01:50:57 +00:00
,repo_timeout = ?
,repo_keys_public = ?
,repo_keys_private = ?
,repo_hooks_pull_request = ?
,repo_hooks_push = ?
,repo_hooks_tags = ?
2015-06-13 23:48:06 +00:00
,repo_params = ?
,repo_hash = ?
2015-06-13 23:48:06 +00:00
WHERE repo_id = ?
`
const stmtRepoDelete = `
DELETE FROM repos
WHERE repo_id = ?
`
const stmtRepoTable = `
CREATE TABLE IF NOT EXISTS repos (
repo_id INTEGER PRIMARY KEY AUTOINCREMENT
,repo_user_id INTEGER
,repo_owner VARCHAR
,repo_name VARCHAR
,repo_full_name VARCHAR
,repo_avatar VARCHAR
,repo_self VARCHAR
,repo_link VARCHAR
,repo_clone VARCHAR
,repo_branch VARCHAR
,repo_private BOOLEAN
,repo_trusted BOOLEAN
,repo_timeout INTEGER
,repo_keys_public VARCHAR
,repo_keys_private VARCHAR
,repo_hooks_pull_request BOOLEAN
,repo_hooks_push BOOLEAN
,repo_hooks_tags BOOLEAN
,repo_params BLOB
,repo_hash VARCHAR
2015-06-13 23:48:06 +00:00
);
`
const stmtRepoRepoFullNameIndex = `
CREATE UNIQUE INDEX IF NOT EXISTS ux_repo_full_name ON repos (repo_full_name);
`
2015-06-19 01:50:57 +00:00
const stmtRepoRepoUserIdIndex = `
CREATE INDEX IF NOT EXISTS ix_repo_user_id ON repos (repo_user_id);
`
2015-06-13 23:48:06 +00:00
const stmtRepoRepoOwnerNameIndex = `
CREATE UNIQUE INDEX IF NOT EXISTS ux_repo_owner_name ON repos (repo_owner,repo_name);
`