本站源代码
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

76 lines
1.7KB

  1. package testfixtures
  2. import (
  3. "database/sql"
  4. )
  5. type (
  6. // DataBaseHelper is the helper interface
  7. // Deprecated: Use Helper instead
  8. DataBaseHelper Helper
  9. // PostgreSQLHelper is the PostgreSQL helper
  10. // Deprecated: Use PostgreSQL{} instead
  11. PostgreSQLHelper struct {
  12. PostgreSQL
  13. UseAlterConstraint bool
  14. }
  15. // MySQLHelper is the MySQL helper
  16. // Deprecated: Use MySQL{} instead
  17. MySQLHelper struct {
  18. MySQL
  19. }
  20. // SQLiteHelper is the SQLite helper
  21. // Deprecated: Use SQLite{} instead
  22. SQLiteHelper struct {
  23. SQLite
  24. }
  25. // SQLServerHelper is the SQLServer helper
  26. // Deprecated: Use SQLServer{} instead
  27. SQLServerHelper struct {
  28. SQLServer
  29. }
  30. // OracleHelper is the Oracle helper
  31. // Deprecated: Use Oracle{} instead
  32. OracleHelper struct {
  33. Oracle
  34. }
  35. )
  36. func (h *PostgreSQLHelper) disableReferentialIntegrity(db *sql.DB, loadFn loadFunction) error {
  37. h.PostgreSQL.UseAlterConstraint = h.UseAlterConstraint
  38. return h.PostgreSQL.disableReferentialIntegrity(db, loadFn)
  39. }
  40. // LoadFixtureFiles load all specified fixtures files into database:
  41. // LoadFixtureFiles(db, &PostgreSQL{},
  42. // "fixtures/customers.yml", "fixtures/orders.yml")
  43. // // add as many files you want
  44. //
  45. // Deprecated: Use NewFiles() and Load() instead.
  46. func LoadFixtureFiles(db *sql.DB, helper Helper, files ...string) error {
  47. c, err := NewFiles(db, helper, files...)
  48. if err != nil {
  49. return err
  50. }
  51. return c.Load()
  52. }
  53. // LoadFixtures loads all fixtures in a given folder into the database:
  54. // LoadFixtures("myfixturesfolder", db, &PostgreSQL{})
  55. //
  56. // Deprecated: Use NewFolder() and Load() instead.
  57. func LoadFixtures(folderName string, db *sql.DB, helper Helper) error {
  58. c, err := NewFolder(db, helper, folderName)
  59. if err != nil {
  60. return err
  61. }
  62. return c.Load()
  63. }
上海开阖软件有限公司 沪ICP备12045867号-1