mirror of
https://github.com/rancher/steve.git
synced 2025-09-05 01:12:09 +00:00
Handle int64 field type when adding index fields (#671)
* Handle int64 field type when adding index fields * add support for float64
This commit is contained in:
@@ -499,7 +499,7 @@ func (l *ListOptionIndexer) addIndexFields(key string, obj any, tx transaction.C
|
|||||||
switch typedValue := value.(type) {
|
switch typedValue := value.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
args = append(args, "")
|
args = append(args, "")
|
||||||
case int, bool, string:
|
case int, bool, string, int64, float64:
|
||||||
args = append(args, fmt.Sprint(typedValue))
|
args = append(args, fmt.Sprint(typedValue))
|
||||||
case []string:
|
case []string:
|
||||||
args = append(args, strings.Join(typedValue, "|"))
|
args = append(args, strings.Join(typedValue, "|"))
|
||||||
|
@@ -1855,7 +1855,11 @@ func TestWatchMany(t *testing.T) {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
|
||||||
opts := ListOptionIndexerOptions{
|
opts := ListOptionIndexerOptions{
|
||||||
Fields: [][]string{{"metadata", "somefield"}},
|
Fields: [][]string{
|
||||||
|
{"metadata", "somefield"},
|
||||||
|
{"spec", "replicas"},
|
||||||
|
{"spec", "minReplicas"},
|
||||||
|
},
|
||||||
IsNamespaced: true,
|
IsNamespaced: true,
|
||||||
}
|
}
|
||||||
loi, err := makeListOptionIndexer(ctx, opts)
|
loi, err := makeListOptionIndexer(ctx, opts)
|
||||||
@@ -1902,6 +1906,10 @@ func TestWatchMany(t *testing.T) {
|
|||||||
"metadata": map[string]any{
|
"metadata": map[string]any{
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
},
|
},
|
||||||
|
"spec": map[string]any{
|
||||||
|
"replicas": int64(1),
|
||||||
|
"minReplicas": float64(1.0),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
foo.SetResourceVersion("100")
|
foo.SetResourceVersion("100")
|
||||||
|
Reference in New Issue
Block a user