@@ -884,20 +884,26 @@ func (s *Schema) genMultiplePartitionQuery(t *Table, g *Generator, r *rand.Rand,
884
884
tableName = t .MaterializedViews [view ].Name
885
885
partitionKeys = t .MaterializedViews [view ].PartitionKeys
886
886
}
887
- pkNum := r .Intn (len (partitionKeys ))
888
- if pkNum == 0 {
889
- pkNum = 1
887
+ numQueryPKs := r .Intn (len (partitionKeys ))
888
+ if numQueryPKs == 0 {
889
+ numQueryPKs = 1
890
890
}
891
891
builder := qb .Select (s .Keyspace .Name + "." + tableName )
892
892
for i , pk := range partitionKeys {
893
- builder = builder .Where (qb .InTuple (pk .Name , pkNum ))
894
- for j := 0 ; j < pkNum ; j ++ {
893
+ builder = builder .Where (qb .InTuple (pk .Name , numQueryPKs ))
894
+ for j := 0 ; j < numQueryPKs ; j ++ {
895
895
vs , ok := g .GetOld ()
896
896
if ! ok {
897
897
return nil
898
898
}
899
- values = append (values , vs .Value [i ])
900
- typs = append (typs , pk .Type )
899
+ numMVKeys := len (partitionKeys ) - len (vs .Value )
900
+ if i < numMVKeys {
901
+ values = appendValue (pk .Type , r , p , values )
902
+ typs = append (typs , pk .Type )
903
+ } else {
904
+ values = append (values , vs .Value [i - numMVKeys ])
905
+ typs = append (typs , pk .Type )
906
+ }
901
907
}
902
908
}
903
909
return & Stmt {
@@ -976,20 +982,26 @@ func (s *Schema) genMultiplePartitionClusteringRangeQuery(t *Table, g *Generator
976
982
partitionKeys = t .MaterializedViews [view ].PartitionKeys
977
983
clusteringKeys = t .MaterializedViews [view ].ClusteringKeys
978
984
}
979
- pkNum := r .Intn (len (partitionKeys ))
980
- if pkNum == 0 {
981
- pkNum = 1
985
+ numQueryPKs := r .Intn (len (partitionKeys ))
986
+ if numQueryPKs == 0 {
987
+ numQueryPKs = 1
982
988
}
983
989
builder := qb .Select (s .Keyspace .Name + "." + tableName )
984
990
for i , pk := range partitionKeys {
985
- builder = builder .Where (qb .InTuple (pk .Name , pkNum ))
986
- for j := 0 ; j < pkNum ; j ++ {
991
+ builder = builder .Where (qb .InTuple (pk .Name , numQueryPKs ))
992
+ for j := 0 ; j < numQueryPKs ; j ++ {
987
993
vs , ok := g .GetOld ()
988
994
if ! ok {
989
995
return nil
990
996
}
991
- values = append (values , vs .Value [i ])
992
- typs = append (typs , pk .Type )
997
+ numMVKeys := len (partitionKeys ) - len (vs .Value )
998
+ if i < numMVKeys {
999
+ values = appendValue (pk .Type , r , p , values )
1000
+ typs = append (typs , pk .Type )
1001
+ } else {
1002
+ values = append (values , vs .Value [i - numMVKeys ])
1003
+ typs = append (typs , pk .Type )
1004
+ }
993
1005
}
994
1006
}
995
1007
if len (clusteringKeys ) > 0 {
0 commit comments