-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathCockroachDBCommon.java
More file actions
34 lines (27 loc) · 1.08 KB
/
CockroachDBCommon.java
File metadata and controls
34 lines (27 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package sqlancer.cockroachdb;
import java.util.ArrayList;
import java.util.List;
import sqlancer.Randomly;
import sqlancer.cockroachdb.CockroachDBSchema.CockroachDBTable;
import sqlancer.cockroachdb.ast.CockroachDBExpression;
import sqlancer.cockroachdb.ast.CockroachDBIndexReference;
import sqlancer.cockroachdb.ast.CockroachDBTableReference;
public final class CockroachDBCommon {
private CockroachDBCommon() {
}
public static String getRandomCollate() {
return Randomly.fromOptions("en", "de", "es", "cmn");
}
public static List<CockroachDBExpression> getTableReferences(List<CockroachDBTableReference> tableList) {
List<CockroachDBExpression> from = new ArrayList<>();
for (CockroachDBTableReference t : tableList) {
CockroachDBTable table = t.getTable();
if (!table.getIndexes().isEmpty() && Randomly.getBooleanWithSmallProbability()) {
from.add(new CockroachDBIndexReference(t, table.getRandomIndex()));
} else {
from.add(t);
}
}
return from;
}
}