woodpecker/pkg/store/builtin/commit_sql.go

521 lines
8 KiB
Go
Raw Normal View History

2015-06-14 01:40:07 +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 commitDB 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 getCommit(db commitDB, query string, args ...interface{}) (*Commit, error) {
row := db.QueryRow(query, args...)
return scanCommit(row)
}
func getCommits(db commitDB, query string, args ...interface{}) ([]*Commit, error) {
rows, err := db.Query(query, args...)
if err != nil {
return nil, err
}
defer rows.Close()
return scanCommits(rows)
}
func createCommit(db commitDB, query string, v *Commit) error {
var v0 int64
var v1 int
var v2 string
var v3 int64
var v4 int64
var v5 string
var v6 string
var v7 string
var v8 string
var v9 string
var v10 string
var v11 string
var v12 string
var v13 string
var v14 string
var v15 string
var v16 int64
var v17 int64
v0 = v.RepoID
v1 = v.Sequence
v2 = v.State
v3 = v.Started
v4 = v.Finished
v5 = v.Sha
v6 = v.Ref
v7 = v.PullRequest
v8 = v.Branch
v9 = v.Author
v10 = v.Gravatar
v11 = v.Timestamp
v12 = v.Message
v13 = v.SourceRemote
v14 = v.SourceBranch
v15 = v.SourceSha
v16 = v.Created
v17 = v.Updated
res, err := db.Exec(query,
&v0,
&v1,
&v2,
&v3,
&v4,
&v5,
&v6,
&v7,
&v8,
&v9,
&v10,
&v11,
&v12,
&v13,
&v14,
&v15,
&v16,
&v17,
)
if err != nil {
return err
}
v.ID, err = res.LastInsertId()
return err
}
func updateCommit(db commitDB, query string, v *Commit) error {
var v0 int64
var v1 int64
var v2 int
var v3 string
var v4 int64
var v5 int64
var v6 string
var v7 string
var v8 string
var v9 string
var v10 string
var v11 string
var v12 string
var v13 string
var v14 string
var v15 string
var v16 string
var v17 int64
var v18 int64
v0 = v.ID
v1 = v.RepoID
v2 = v.Sequence
v3 = v.State
v4 = v.Started
v5 = v.Finished
v6 = v.Sha
v7 = v.Ref
v8 = v.PullRequest
v9 = v.Branch
v10 = v.Author
v11 = v.Gravatar
v12 = v.Timestamp
v13 = v.Message
v14 = v.SourceRemote
v15 = v.SourceBranch
v16 = v.SourceSha
v17 = v.Created
v18 = v.Updated
_, err := db.Exec(query,
&v1,
&v2,
&v3,
&v4,
&v5,
&v6,
&v7,
&v8,
&v9,
&v10,
&v11,
&v12,
&v13,
&v14,
&v15,
&v16,
&v17,
&v18,
&v0,
)
return err
}
func scanCommit(row *sql.Row) (*Commit, error) {
var v0 int64
var v1 int64
var v2 int
var v3 string
var v4 int64
var v5 int64
var v6 string
var v7 string
var v8 string
var v9 string
var v10 string
var v11 string
var v12 string
var v13 string
var v14 string
var v15 string
var v16 string
var v17 int64
var v18 int64
err := row.Scan(
&v0,
&v1,
&v2,
&v3,
&v4,
&v5,
&v6,
&v7,
&v8,
&v9,
&v10,
&v11,
&v12,
&v13,
&v14,
&v15,
&v16,
&v17,
&v18,
)
if err != nil {
return nil, err
}
v := &Commit{}
v.ID = v0
v.RepoID = v1
v.Sequence = v2
v.State = v3
v.Started = v4
v.Finished = v5
v.Sha = v6
v.Ref = v7
v.PullRequest = v8
v.Branch = v9
v.Author = v10
v.Gravatar = v11
v.Timestamp = v12
v.Message = v13
v.SourceRemote = v14
v.SourceBranch = v15
v.SourceSha = v16
v.Created = v17
v.Updated = v18
return v, nil
}
func scanCommits(rows *sql.Rows) ([]*Commit, error) {
var err error
var vv []*Commit
for rows.Next() {
var v0 int64
var v1 int64
var v2 int
var v3 string
var v4 int64
var v5 int64
var v6 string
var v7 string
var v8 string
var v9 string
var v10 string
var v11 string
var v12 string
var v13 string
var v14 string
var v15 string
var v16 string
var v17 int64
var v18 int64
err = rows.Scan(
&v0,
&v1,
&v2,
&v3,
&v4,
&v5,
&v6,
&v7,
&v8,
&v9,
&v10,
&v11,
&v12,
&v13,
&v14,
&v15,
&v16,
&v17,
&v18,
)
if err != nil {
return vv, err
}
v := &Commit{}
v.ID = v0
v.RepoID = v1
v.Sequence = v2
v.State = v3
v.Started = v4
v.Finished = v5
v.Sha = v6
v.Ref = v7
v.PullRequest = v8
v.Branch = v9
v.Author = v10
v.Gravatar = v11
v.Timestamp = v12
v.Message = v13
v.SourceRemote = v14
v.SourceBranch = v15
v.SourceSha = v16
v.Created = v17
v.Updated = v18
vv = append(vv, v)
}
return vv, rows.Err()
}
const stmtCommitSelectList = `
SELECT
commit_id
,commit_repo_id
,commit_sequence
,commit_state
,commit_started
,commit_finished
,commit_sha
,commit_ref
,commit_pull_request
,commit_branch
,commit_author
,commit_gravatar
,commit_timestamp
,commit_message
,commit_source_remote
,commit_source_branch
,commit_source_sha
,commit_created
,commit_updated
FROM commits
`
const stmtCommitSelectRange = `
SELECT
commit_id
,commit_repo_id
,commit_sequence
,commit_state
,commit_started
,commit_finished
,commit_sha
,commit_ref
,commit_pull_request
,commit_branch
,commit_author
,commit_gravatar
,commit_timestamp
,commit_message
,commit_source_remote
,commit_source_branch
,commit_source_sha
,commit_created
,commit_updated
FROM commits
LIMIT ? OFFSET ?
`
const stmtCommitSelect = `
SELECT
commit_id
,commit_repo_id
,commit_sequence
,commit_state
,commit_started
,commit_finished
,commit_sha
,commit_ref
,commit_pull_request
,commit_branch
,commit_author
,commit_gravatar
,commit_timestamp
,commit_message
,commit_source_remote
,commit_source_branch
,commit_source_sha
,commit_created
,commit_updated
FROM commits
WHERE commit_id = ?
`
const stmtCommitSelectCommitSeq = `
SELECT
commit_id
,commit_repo_id
,commit_sequence
,commit_state
,commit_started
,commit_finished
,commit_sha
,commit_ref
,commit_pull_request
,commit_branch
,commit_author
,commit_gravatar
,commit_timestamp
,commit_message
,commit_source_remote
,commit_source_branch
,commit_source_sha
,commit_created
,commit_updated
FROM commits
WHERE commit_repo_id = ?
AND commit_sequence = ?
`
const stmtCommitSelectCommitRepoId = `
SELECT
commit_id
,commit_repo_id
,commit_sequence
,commit_state
,commit_started
,commit_finished
,commit_sha
,commit_ref
,commit_pull_request
,commit_branch
,commit_author
,commit_gravatar
,commit_timestamp
,commit_message
,commit_source_remote
,commit_source_branch
,commit_source_sha
,commit_created
,commit_updated
FROM commits
WHERE commit_repo_id = ?
`
const stmtCommitSelectCount = `
SELECT count(1)
FROM commits
`
const stmtCommitInsert = `
INSERT INTO commits (
commit_repo_id
,commit_sequence
,commit_state
,commit_started
,commit_finished
,commit_sha
,commit_ref
,commit_pull_request
,commit_branch
,commit_author
,commit_gravatar
,commit_timestamp
,commit_message
,commit_source_remote
,commit_source_branch
,commit_source_sha
,commit_created
,commit_updated
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
`
const stmtCommitUpdate = `
UPDATE commits SET
commit_repo_id = ?
,commit_sequence = ?
,commit_state = ?
,commit_started = ?
,commit_finished = ?
,commit_sha = ?
,commit_ref = ?
,commit_pull_request = ?
,commit_branch = ?
,commit_author = ?
,commit_gravatar = ?
,commit_timestamp = ?
,commit_message = ?
,commit_source_remote = ?
,commit_source_branch = ?
,commit_source_sha = ?
,commit_created = ?
,commit_updated = ?
WHERE commit_id = ?
`
const stmtCommitDelete = `
DELETE FROM commits
WHERE commit_id = ?
`
const stmtCommitTable = `
CREATE TABLE IF NOT EXISTS commits (
commit_id INTEGER PRIMARY KEY AUTOINCREMENT
,commit_repo_id INTEGER
,commit_sequence INTEGER
,commit_state VARCHAR
,commit_started INTEGER
,commit_finished INTEGER
,commit_sha VARCHAR
,commit_ref VARCHAR
,commit_pull_request VARCHAR
,commit_branch VARCHAR
,commit_author VARCHAR
,commit_gravatar VARCHAR
,commit_timestamp VARCHAR
,commit_message VARCHAR
,commit_source_remote VARCHAR
,commit_source_branch VARCHAR
,commit_source_sha VARCHAR
,commit_created INTEGER
,commit_updated INTEGER
);
`
const stmtCommitCommitSeqIndex = `
CREATE UNIQUE INDEX IF NOT EXISTS ux_commit_seq ON commits (commit_repo_id,commit_sequence);
`
const stmtCommitCommitRepoIdIndex = `
CREATE INDEX IF NOT EXISTS ix_commit_repo_id ON commits (commit_repo_id);
`