assignValues assigns the values that were returned from sql.Rows (after scanning) to the User fields.
(columns []string, values []any)
| 88 | // assignValues assigns the values that were returned from sql.Rows (after scanning) |
| 89 | // to the User fields. |
| 90 | func (_m *User) assignValues(columns []string, values []any) error { |
| 91 | if m, n := len(values), len(columns); m < n { |
| 92 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) |
| 93 | } |
| 94 | for i := range columns { |
| 95 | switch columns[i] { |
| 96 | case user.FieldID: |
| 97 | if value, ok := values[i].(*uuid.UUID); !ok { |
| 98 | return fmt.Errorf("unexpected type %T for field id", values[i]) |
| 99 | } else if value != nil { |
| 100 | _m.ID = *value |
| 101 | } |
| 102 | case user.FieldEmail: |
| 103 | if value, ok := values[i].(*sql.NullString); !ok { |
| 104 | return fmt.Errorf("unexpected type %T for field email", values[i]) |
| 105 | } else if value.Valid { |
| 106 | _m.Email = value.String |
| 107 | } |
| 108 | case user.FieldCreatedAt: |
| 109 | if value, ok := values[i].(*sql.NullTime); !ok { |
| 110 | return fmt.Errorf("unexpected type %T for field created_at", values[i]) |
| 111 | } else if value.Valid { |
| 112 | _m.CreatedAt = value.Time |
| 113 | } |
| 114 | case user.FieldUpdatedAt: |
| 115 | if value, ok := values[i].(*sql.NullTime); !ok { |
| 116 | return fmt.Errorf("unexpected type %T for field updated_at", values[i]) |
| 117 | } else if value.Valid { |
| 118 | _m.UpdatedAt = value.Time |
| 119 | } |
| 120 | case user.FieldHasRestrictedAccess: |
| 121 | if value, ok := values[i].(*sql.NullBool); !ok { |
| 122 | return fmt.Errorf("unexpected type %T for field has_restricted_access", values[i]) |
| 123 | } else if value.Valid { |
| 124 | _m.HasRestrictedAccess = new(bool) |
| 125 | *_m.HasRestrictedAccess = value.Bool |
| 126 | } |
| 127 | case user.FieldFirstName: |
| 128 | if value, ok := values[i].(*sql.NullString); !ok { |
| 129 | return fmt.Errorf("unexpected type %T for field first_name", values[i]) |
| 130 | } else if value.Valid { |
| 131 | _m.FirstName = value.String |
| 132 | } |
| 133 | case user.FieldLastName: |
| 134 | if value, ok := values[i].(*sql.NullString); !ok { |
| 135 | return fmt.Errorf("unexpected type %T for field last_name", values[i]) |
| 136 | } else if value.Valid { |
| 137 | _m.LastName = value.String |
| 138 | } |
| 139 | default: |
| 140 | _m.selectValues.Set(columns[i], values[i]) |
| 141 | } |
| 142 | } |
| 143 | return nil |
| 144 | } |
| 145 | |
| 146 | // Value returns the ent.Value that was dynamically selected and assigned to the User. |
| 147 | // This includes values selected through modifiers, order, etc. |