mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-19 08:21:01 +00:00
339 lines
4.7 KiB
Go
339 lines
4.7 KiB
Go
|
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 userDB 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 getUser(db userDB, query string, args ...interface{}) (*User, error) {
|
||
|
row := db.QueryRow(query, args...)
|
||
|
return scanUser(row)
|
||
|
}
|
||
|
|
||
|
func getUsers(db userDB, query string, args ...interface{}) ([]*User, error) {
|
||
|
rows, err := db.Query(query, args...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
defer rows.Close()
|
||
|
return scanUsers(rows)
|
||
|
}
|
||
|
|
||
|
func createUser(db userDB, query string, v *User) error {
|
||
|
var v0 string
|
||
|
var v1 string
|
||
|
var v2 string
|
||
|
var v3 string
|
||
|
var v4 string
|
||
|
var v5 string
|
||
|
var v6 bool
|
||
|
var v7 bool
|
||
|
var v8 int64
|
||
|
var v9 int64
|
||
|
v0 = v.Login
|
||
|
v1 = v.Token
|
||
|
v2 = v.Secret
|
||
|
v3 = v.Name
|
||
|
v4 = v.Email
|
||
|
v5 = v.Gravatar
|
||
|
v6 = v.Admin
|
||
|
v7 = v.Active
|
||
|
v8 = v.Created
|
||
|
v9 = v.Updated
|
||
|
|
||
|
res, err := db.Exec(query,
|
||
|
&v0,
|
||
|
&v1,
|
||
|
&v2,
|
||
|
&v3,
|
||
|
&v4,
|
||
|
&v5,
|
||
|
&v6,
|
||
|
&v7,
|
||
|
&v8,
|
||
|
&v9,
|
||
|
)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
v.ID, err = res.LastInsertId()
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func updateUser(db userDB, query string, v *User) error {
|
||
|
var v0 int64
|
||
|
var v1 string
|
||
|
var v2 string
|
||
|
var v3 string
|
||
|
var v4 string
|
||
|
var v5 string
|
||
|
var v6 string
|
||
|
var v7 bool
|
||
|
var v8 bool
|
||
|
var v9 int64
|
||
|
var v10 int64
|
||
|
v0 = v.ID
|
||
|
v1 = v.Login
|
||
|
v2 = v.Token
|
||
|
v3 = v.Secret
|
||
|
v4 = v.Name
|
||
|
v5 = v.Email
|
||
|
v6 = v.Gravatar
|
||
|
v7 = v.Admin
|
||
|
v8 = v.Active
|
||
|
v9 = v.Created
|
||
|
v10 = v.Updated
|
||
|
|
||
|
_, err := db.Exec(query,
|
||
|
&v1,
|
||
|
&v2,
|
||
|
&v3,
|
||
|
&v4,
|
||
|
&v5,
|
||
|
&v6,
|
||
|
&v7,
|
||
|
&v8,
|
||
|
&v9,
|
||
|
&v10,
|
||
|
&v0,
|
||
|
)
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func scanUser(row *sql.Row) (*User, error) {
|
||
|
var v0 int64
|
||
|
var v1 string
|
||
|
var v2 string
|
||
|
var v3 string
|
||
|
var v4 string
|
||
|
var v5 string
|
||
|
var v6 string
|
||
|
var v7 bool
|
||
|
var v8 bool
|
||
|
var v9 int64
|
||
|
var v10 int64
|
||
|
|
||
|
err := row.Scan(
|
||
|
&v0,
|
||
|
&v1,
|
||
|
&v2,
|
||
|
&v3,
|
||
|
&v4,
|
||
|
&v5,
|
||
|
&v6,
|
||
|
&v7,
|
||
|
&v8,
|
||
|
&v9,
|
||
|
&v10,
|
||
|
)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
v := &User{}
|
||
|
v.ID = v0
|
||
|
v.Login = v1
|
||
|
v.Token = v2
|
||
|
v.Secret = v3
|
||
|
v.Name = v4
|
||
|
v.Email = v5
|
||
|
v.Gravatar = v6
|
||
|
v.Admin = v7
|
||
|
v.Active = v8
|
||
|
v.Created = v9
|
||
|
v.Updated = v10
|
||
|
|
||
|
return v, nil
|
||
|
}
|
||
|
|
||
|
func scanUsers(rows *sql.Rows) ([]*User, error) {
|
||
|
var err error
|
||
|
var vv []*User
|
||
|
for rows.Next() {
|
||
|
var v0 int64
|
||
|
var v1 string
|
||
|
var v2 string
|
||
|
var v3 string
|
||
|
var v4 string
|
||
|
var v5 string
|
||
|
var v6 string
|
||
|
var v7 bool
|
||
|
var v8 bool
|
||
|
var v9 int64
|
||
|
var v10 int64
|
||
|
err = rows.Scan(
|
||
|
&v0,
|
||
|
&v1,
|
||
|
&v2,
|
||
|
&v3,
|
||
|
&v4,
|
||
|
&v5,
|
||
|
&v6,
|
||
|
&v7,
|
||
|
&v8,
|
||
|
&v9,
|
||
|
&v10,
|
||
|
)
|
||
|
if err != nil {
|
||
|
return vv, err
|
||
|
}
|
||
|
|
||
|
v := &User{}
|
||
|
v.ID = v0
|
||
|
v.Login = v1
|
||
|
v.Token = v2
|
||
|
v.Secret = v3
|
||
|
v.Name = v4
|
||
|
v.Email = v5
|
||
|
v.Gravatar = v6
|
||
|
v.Admin = v7
|
||
|
v.Active = v8
|
||
|
v.Created = v9
|
||
|
v.Updated = v10
|
||
|
vv = append(vv, v)
|
||
|
}
|
||
|
return vv, rows.Err()
|
||
|
}
|
||
|
|
||
|
const stmtUserSelectList = `
|
||
|
SELECT
|
||
|
user_id
|
||
|
,user_login
|
||
|
,user_token
|
||
|
,user_secret
|
||
|
,user_name
|
||
|
,user_email
|
||
|
,user_gravatar
|
||
|
,user_admin
|
||
|
,user_active
|
||
|
,user_created
|
||
|
,user_updated
|
||
|
FROM users
|
||
|
`
|
||
|
|
||
|
const stmtUserSelectRange = `
|
||
|
SELECT
|
||
|
user_id
|
||
|
,user_login
|
||
|
,user_token
|
||
|
,user_secret
|
||
|
,user_name
|
||
|
,user_email
|
||
|
,user_gravatar
|
||
|
,user_admin
|
||
|
,user_active
|
||
|
,user_created
|
||
|
,user_updated
|
||
|
FROM users
|
||
|
LIMIT ? OFFSET ?
|
||
|
`
|
||
|
|
||
|
const stmtUserSelect = `
|
||
|
SELECT
|
||
|
user_id
|
||
|
,user_login
|
||
|
,user_token
|
||
|
,user_secret
|
||
|
,user_name
|
||
|
,user_email
|
||
|
,user_gravatar
|
||
|
,user_admin
|
||
|
,user_active
|
||
|
,user_created
|
||
|
,user_updated
|
||
|
FROM users
|
||
|
WHERE user_id = ?
|
||
|
`
|
||
|
|
||
|
const stmtUserSelectUserLogin = `
|
||
|
SELECT
|
||
|
user_id
|
||
|
,user_login
|
||
|
,user_token
|
||
|
,user_secret
|
||
|
,user_name
|
||
|
,user_email
|
||
|
,user_gravatar
|
||
|
,user_admin
|
||
|
,user_active
|
||
|
,user_created
|
||
|
,user_updated
|
||
|
FROM users
|
||
|
WHERE user_login = ?
|
||
|
`
|
||
|
|
||
|
const stmtUserSelectCount = `
|
||
|
SELECT count(1)
|
||
|
FROM users
|
||
|
`
|
||
|
|
||
|
const stmtUserInsert = `
|
||
|
INSERT INTO users (
|
||
|
user_login
|
||
|
,user_token
|
||
|
,user_secret
|
||
|
,user_name
|
||
|
,user_email
|
||
|
,user_gravatar
|
||
|
,user_admin
|
||
|
,user_active
|
||
|
,user_created
|
||
|
,user_updated
|
||
|
) VALUES (?,?,?,?,?,?,?,?,?,?);
|
||
|
`
|
||
|
|
||
|
const stmtUserUpdate = `
|
||
|
UPDATE users SET
|
||
|
user_login = ?
|
||
|
,user_token = ?
|
||
|
,user_secret = ?
|
||
|
,user_name = ?
|
||
|
,user_email = ?
|
||
|
,user_gravatar = ?
|
||
|
,user_admin = ?
|
||
|
,user_active = ?
|
||
|
,user_created = ?
|
||
|
,user_updated = ?
|
||
|
WHERE user_id = ?
|
||
|
`
|
||
|
|
||
|
const stmtUserDelete = `
|
||
|
DELETE FROM users
|
||
|
WHERE user_id = ?
|
||
|
`
|
||
|
|
||
|
const stmtUserTable = `
|
||
|
CREATE TABLE IF NOT EXISTS users (
|
||
|
user_id INTEGER PRIMARY KEY AUTOINCREMENT
|
||
|
,user_login VARCHAR
|
||
|
,user_token VARCHAR
|
||
|
,user_secret VARCHAR
|
||
|
,user_name VARCHAR
|
||
|
,user_email VARCHAR
|
||
|
,user_gravatar VARCHAR
|
||
|
,user_admin BOOLEAN
|
||
|
,user_active BOOLEAN
|
||
|
,user_created INTEGER
|
||
|
,user_updated INTEGER
|
||
|
);
|
||
|
`
|
||
|
|
||
|
const stmtUserUserLoginIndex = `
|
||
|
CREATE UNIQUE INDEX IF NOT EXISTS ux_user_login ON users (user_login);
|
||
|
`
|