1
0

models.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // versions:
  3. // sqlc v1.27.0
  4. package booktest
  5. import (
  6. "database/sql/driver"
  7. "fmt"
  8. "github.com/jackc/pgx/v5/pgtype"
  9. )
  10. type BookType string
  11. const (
  12. BookTypeFICTION BookType = "FICTION"
  13. BookTypeNONFICTION BookType = "NONFICTION"
  14. )
  15. func (e *BookType) Scan(src interface{}) error {
  16. switch s := src.(type) {
  17. case []byte:
  18. *e = BookType(s)
  19. case string:
  20. *e = BookType(s)
  21. default:
  22. return fmt.Errorf("unsupported scan type for BookType: %T", src)
  23. }
  24. return nil
  25. }
  26. type NullBookType struct {
  27. BookType BookType
  28. Valid bool // Valid is true if BookType is not NULL
  29. }
  30. // Scan implements the Scanner interface.
  31. func (ns *NullBookType) Scan(value interface{}) error {
  32. if value == nil {
  33. ns.BookType, ns.Valid = "", false
  34. return nil
  35. }
  36. ns.Valid = true
  37. return ns.BookType.Scan(value)
  38. }
  39. // Value implements the driver Valuer interface.
  40. func (ns NullBookType) Value() (driver.Value, error) {
  41. if !ns.Valid {
  42. return nil, nil
  43. }
  44. return string(ns.BookType), nil
  45. }
  46. type Author struct {
  47. AuthorID int32
  48. Name string
  49. }
  50. type Book struct {
  51. BookID int32
  52. AuthorID int32
  53. Isbn string
  54. BookType BookType
  55. Title string
  56. Year int32
  57. Available pgtype.Timestamptz
  58. Tags []string
  59. }