diff options
Diffstat (limited to 'cmd/mi/models')
| -rw-r--r-- | cmd/mi/models/dao.go | 2 | ||||
| -rw-r--r-- | cmd/mi/models/switch.go | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/cmd/mi/models/dao.go b/cmd/mi/models/dao.go index 3241d5e..b00ed96 100644 --- a/cmd/mi/models/dao.go +++ b/cmd/mi/models/dao.go @@ -129,7 +129,7 @@ func (d *DAO) GetSwitch(ctx context.Context, id string) (*Switch, error) { var sw Switch if err := d.db.WithContext(ctx). Joins("Member"). - Where("id = ?", id). + Where("switches.id = ?", id). First(&sw).Error; err != nil { return nil, err } diff --git a/cmd/mi/models/switch.go b/cmd/mi/models/switch.go index ec85a1c..5a16dd6 100644 --- a/cmd/mi/models/switch.go +++ b/cmd/mi/models/switch.go @@ -17,7 +17,11 @@ type Switch struct { } // AsProto converts a Switch to its protobuf representation. -func (s Switch) AsProto() *pb.Switch { +func (s *Switch) AsProto() *pb.Switch { + if s == nil { + return nil + } + var endedAt string if s.EndedAt != nil { |
