mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
743 B
39 lines
743 B
8 years ago
|
package testfixtures
|
||
|
|
||
|
import (
|
||
|
"database/sql"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
paramTypeDollar = iota + 1
|
||
|
paramTypeQuestion
|
||
|
paramTypeColon
|
||
|
)
|
||
|
|
||
|
type loadFunction func(tx *sql.Tx) error
|
||
|
|
||
|
// Helper is the generic interface for the database helper
|
||
|
type Helper interface {
|
||
|
init(*sql.DB) error
|
||
|
disableReferentialIntegrity(*sql.DB, loadFunction) error
|
||
|
paramType() int
|
||
|
databaseName(*sql.DB) string
|
||
|
quoteKeyword(string) string
|
||
|
whileInsertOnTable(*sql.Tx, string, func() error) error
|
||
|
}
|
||
|
|
||
|
type baseHelper struct{}
|
||
|
|
||
|
func (*baseHelper) init(_ *sql.DB) error {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (*baseHelper) quoteKeyword(str string) string {
|
||
|
return fmt.Sprintf(`"%s"`, str)
|
||
|
}
|
||
|
|
||
|
func (*baseHelper) whileInsertOnTable(_ *sql.Tx, _ string, fn func() error) error {
|
||
|
return fn()
|
||
|
}
|