Skip to content

Commit

Permalink
Not more equal/unequal sign, "in" and "not in" are now used exclusive…
Browse files Browse the repository at this point in the history
…ly in queries.
  • Loading branch information
Omar Othman committed Jan 11, 2021
1 parent c4c1139 commit f9cd922
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions filter/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ func ExampleFilters() {
// Output:
// `MOCK_FAKE_DRIVER` is not officially supported, running under compatibility mode.
// true
// &{SELECT * FROM "" WHERE ("bmc_type" = ?) [iLO4]}
// &{SELECT * FROM "" WHERE ("bmc_type" in (?)) [iLO4]}
// true
// &{SELECT * FROM "" WHERE ("bmc_type" != ?) [iLO4]}
// &{SELECT * FROM "" WHERE ("bmc_type" not in (?)) [iLO4]}
// &{SELECT * FROM "" []}
// false
}
Expand Down
10 changes: 5 additions & 5 deletions filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ var testSet = []struct {
urlString string
sqlQuery string
}{
{"filter[model]=dell", "&{SELECT * FROM \"\" WHERE (\"model\" = ?) [dell]}"},
{"filter[status]!=bad", "&{SELECT * FROM \"\" WHERE (\"status\" != ?) [bad]}"},
{"filter[model][eq]=dell", "&{SELECT * FROM \"\" WHERE (\"model\" = ?) [dell]}"},
{"filter[status][ne]=bad", "&{SELECT * FROM \"\" WHERE (\"status\" != ?) [bad]}"},
{"filter[model]=dell", "&{SELECT * FROM \"\" WHERE (\"model\" in (?)) [dell]}"},
{"filter[status]!=bad", "&{SELECT * FROM \"\" WHERE (\"status\" not in (?)) [bad]}"},
{"filter[model][eq]=dell", "&{SELECT * FROM \"\" WHERE (\"model\" in (?)) [dell]}"},
{"filter[status][ne]=bad", "&{SELECT * FROM \"\" WHERE (\"status\" not in (?)) [bad]}"},
{"filter[temp_c][le]=3", "&{SELECT * FROM \"\" WHERE (\"temp_c\" <= ?) [3]}"},
{"filter[temp_c][lt]=3", "&{SELECT * FROM \"\" WHERE (\"temp_c\" < ?) [3]}"},
{"filter[temp_c][ge]=3", "&{SELECT * FROM \"\" WHERE (\"temp_c\" >= ?) [3]}"},
{"filter[temp_c][gt]=3", "&{SELECT * FROM \"\" WHERE (\"temp_c\" > ?) [3]}"},
{"filter[temp_c][gt]=3&filter[vendor]=Dell", "&{SELECT * FROM \"\" WHERE (\"temp_c\" > ?) AND (\"vendor\" = ?) [3 Dell]}"},
{"filter[temp_c][gt]=3&filter[vendor]=Dell", "&{SELECT * FROM \"\" WHERE (\"temp_c\" > ?) AND (\"vendor\" in (?)) [3 Dell]}"},
}

func setupDB() *gorm.DB {
Expand Down
2 changes: 1 addition & 1 deletion storage/storage_chassis.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (c ChassisStorage) GetAllByPsusID(offset string, limit string, serials []st

// GetOne Chassis
func (c ChassisStorage) GetOne(serial string) (chassis model.Chassis, err error) {
if err = c.db.Where("serial = ?", serial).Preload("Blades").Preload("Blades.Nics").Preload("StorageBlades").Preload("Nics").Preload("Psus").First(&chassis).Error; err != nil {
if err = c.db.Where("serial in (?)", serial).Preload("Blades").Preload("Blades.Nics").Preload("StorageBlades").Preload("Nics").Preload("Psus").First(&chassis).Error; err != nil {
return chassis, err
}
return chassis, err
Expand Down

0 comments on commit f9cd922

Please sign in to comment.