From f9cd92267565295ed92ef0629a4914fe13264484 Mon Sep 17 00:00:00 2001 From: Omar Othman Date: Tue, 5 Jan 2021 20:25:32 +0100 Subject: [PATCH] Not more equal/unequal sign, "in" and "not in" are now used exclusively in queries. --- filter/example_test.go | 4 ++-- filter/filter_test.go | 10 +++++----- storage/storage_chassis.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/filter/example_test.go b/filter/example_test.go index a2f48113..d75014c5 100644 --- a/filter/example_test.go +++ b/filter/example_test.go @@ -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 } diff --git a/filter/filter_test.go b/filter/filter_test.go index 829c2b19..c157ba09 100644 --- a/filter/filter_test.go +++ b/filter/filter_test.go @@ -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 { diff --git a/storage/storage_chassis.go b/storage/storage_chassis.go index 7c667f51..7f00c860 100644 --- a/storage/storage_chassis.go +++ b/storage/storage_chassis.go @@ -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