Skip to content

Commit

Permalink
add Scan
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhan005 committed Jan 12, 2024
1 parent 9b7df54 commit 9141394
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/dbutil/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package dbutil

import (
"database/sql"

"gorm.io/gorm"
"gorm.io/gorm/schema"
)
Expand All @@ -21,6 +23,15 @@ func (ContentCensorPass) GormDBDataType(db *gorm.DB, field *schema.Field) string
return ""
}

func (c *ContentCensorPass) Scan(value interface{}) error {
var i sql.NullBool
if err := i.Scan(value); err != nil {
return err
}
*c = ContentCensorPass(i.Bool)
return nil
}

type AnswerCensorPass bool

func (AnswerCensorPass) GormDBDataType(db *gorm.DB, field *schema.Field) string {
Expand All @@ -32,3 +43,12 @@ func (AnswerCensorPass) GormDBDataType(db *gorm.DB, field *schema.Field) string
}
return ""
}

func (c *AnswerCensorPass) Scan(value interface{}) error {
var i sql.NullBool
if err := i.Scan(value); err != nil {
return err
}
*c = AnswerCensorPass(i.Bool)
return nil
}

0 comments on commit 9141394

Please sign in to comment.