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.

38 lines
743 B

  1. package testfixtures
  2. import (
  3. "database/sql"
  4. "fmt"
  5. )
  6. const (
  7. paramTypeDollar = iota + 1
  8. paramTypeQuestion
  9. paramTypeColon
  10. )
  11. type loadFunction func(tx *sql.Tx) error
  12. // Helper is the generic interface for the database helper
  13. type Helper interface {
  14. init(*sql.DB) error
  15. disableReferentialIntegrity(*sql.DB, loadFunction) error
  16. paramType() int
  17. databaseName(*sql.DB) string
  18. quoteKeyword(string) string
  19. whileInsertOnTable(*sql.Tx, string, func() error) error
  20. }
  21. type baseHelper struct{}
  22. func (*baseHelper) init(_ *sql.DB) error {
  23. return nil
  24. }
  25. func (*baseHelper) quoteKeyword(str string) string {
  26. return fmt.Sprintf(`"%s"`, str)
  27. }
  28. func (*baseHelper) whileInsertOnTable(_ *sql.Tx, _ string, fn func() error) error {
  29. return fn()
  30. }