// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Grant fields.
assignValues assigns the values that were returned from sql.Rows (after scanning)
to the Grant fields.
// assignValues assigns the values that were returned from sql . Rows ( after scanning ) // to the Grant fields .
func (gr *Grant) assignValues(columns []string, values []interface{}) error {
	if m, n := len(values), len(columns); m < n {
		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
	}
	for i := range columns {
		switch columns[i] {
		case grant.FieldID:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field id", values[i])
			} else if value.Valid {
				gr.ID = value.String
			}
		case grant.FieldCreatedAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field created_at", values[i])
			} else if value.Valid {
				gr.CreatedAt = value.Time
			}
		case grant.FieldUpdatedAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field updated_at", values[i])
			} else if value.Valid {
				gr.UpdatedAt = value.Time
			}
		case grant.FieldDeletedAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
			} else if value.Valid {
				gr.DeletedAt = new(time.Time)
				*gr.DeletedAt = value.Time
			}
		case grant.FieldHashedGrantToken:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field hashed_grant_token", values[i])
			} else if value.Valid {
				gr.HashedGrantToken = value.String
			}
		case grant.FieldDomain:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field domain", values[i])
			} else if value.Valid {
				gr.Domain = value.String
			}
		case grant.FieldVersion:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field version", values[i])
			} else if value.Valid {
				gr.Version = value.String
			}
		case grant.FieldAllowedHTTPMethods:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field allowed_http_methods", values[i])
			} else if value.Valid {
				gr.AllowedHTTPMethods = value.String
			}
		case grant.FieldPaths:
			if value, ok := values[i].(*[]byte); !ok {
				return fmt.Errorf("unexpected type %T for field paths", values[i])
			} else if value != nil && len(*value) > 0 {
				if err := json.Unmarshal(*value, &gr.Paths); err != nil {
					return fmt.Errorf("unmarshal field paths: %w", err)
				}
			}
		}
	}
	return nil
}
func ( gr * Grant ) assignValues ( columns [ ] string , values [ ] interface { } ) error { if m , n := len ( values ) , len ( columns ) ; m < n { return fmt . Errorf ( " " , m , n ) } for i := range columns { switch columns [ i ] { case grant . FieldID : if value , ok := values [ i ] . ( * sql . NullString ) ; ! ok { return fmt . Errorf ( " " , values [ i ] ) } else if value . Valid { gr . ID = value . String } case grant . FieldCreatedAt : if value , ok := values [ i ] . ( * sql . NullTime ) ; ! ok { return fmt . Errorf ( " " , values [ i ] ) } else if value . Valid { gr . CreatedAt = value . Time } case grant . FieldUpdatedAt : if value , ok := values [ i ] . ( * sql . NullTime ) ; ! ok { return fmt . Errorf ( " " , values [ i ] ) } else if value . Valid { gr . UpdatedAt = value . Time } case grant . FieldDeletedAt : if value , ok := values [ i ] . ( * sql . NullTime ) ; ! ok { return fmt . Errorf ( " " , values [ i ] ) } else if value . Valid { gr . DeletedAt = new ( time . Time ) * gr . DeletedAt = value . Time } case grant . FieldHashedGrantToken : if value , ok := values [ i ] . ( * sql . NullString ) ; ! ok { return fmt . Errorf ( " " , values [ i ] ) } else if value . Valid { gr . HashedGrantToken = value . String } case grant . FieldDomain : if value , ok := values [ i ] . ( * sql . NullString ) ; ! ok { return fmt . Errorf ( " " , values [ i ] ) } else if value . Valid { gr . Domain = value . String } case grant . FieldVersion : if value , ok := values [ i ] . ( * sql . NullString ) ; ! ok { return fmt . Errorf ( " " , values [ i ] ) } else if value . Valid { gr . Version = value . String } case grant . FieldAllowedHTTPMethods : if value , ok := values [ i ] . ( * sql . NullString ) ; ! ok { return fmt . Errorf ( " " , values [ i ] ) } else if value . Valid { gr . AllowedHTTPMethods = value . String } case grant . FieldPaths : if value , ok := values [ i ] . ( * [ ] byte ) ; ! ok { return fmt . Errorf ( " " , values [ i ] ) } else if value != nil && len ( * value ) > 0 { if err := json . Unmarshal ( * value , & gr . Paths ) ; err != nil { return fmt . Errorf ( " " , err ) } } } } return nil }
assignValues assigns the values that were returned from sql.Rows (after scanning)
to the Grant fields.
assignValues assigns the values that were returned from sql . Rows ( after scanning ) to the Grant fields .