@@ -72,37 +72,31 @@ public SQLite3Select getQuery() throws SQLException {
7272 List <SQLite3Table > tables = randomFromTables .getTables ();
7373
7474 pivotRow = randomFromTables .getRandomRowValue (globalState .getConnection ());
75-
7675 globalState .getState ().queryTargetedTablesString = randomFromTables .tableNamesAsString ();
7776 SQLite3Select selectStatement = new SQLite3Select ();
7877 selectStatement .setSelectType (Randomly .fromOptions (SQLite3Select .SelectType .values ()));
7978 List <SQLite3Column > columns = randomFromTables .getColumns ();
80- for (SQLite3Table t : tables ) {
81- if (t .getRowid () != null ) {
82- columns .add (t .getRowid ());
83- }
84- }
85-
86- List <Join > joinStatements = getJoinStatements (globalState , tables , columns );
87- selectStatement .setJoinClauses (joinStatements );
88- selectStatement .setFromTables (SQLite3Common .getTableRefs (tables , globalState .getSchema ()));
89-
9079 // TODO: also implement a wild-card check (*)
9180 // filter out row ids from the select because the hinder the reduction process
9281 // once a bug is found
9382 List <SQLite3Column > columnsWithoutRowid = columns .stream ()
9483 .filter (c -> !SQLite3Schema .ROWID_STRINGS .contains (c .getName ())).collect (Collectors .toList ());
84+ List <Join > joinStatements = getJoinStatements (globalState , tables , columnsWithoutRowid );
85+ selectStatement .setJoinClauses (joinStatements );
86+ selectStatement .setFromTables (SQLite3Common .getTableRefs (tables , globalState .getSchema ()));
87+
9588 fetchColumns = Randomly .nonEmptySubset (columnsWithoutRowid );
9689 List <SQLite3Table > allTables = new ArrayList <>();
9790 allTables .addAll (tables );
9891 allTables .addAll (joinStatements .stream ().map (join -> join .getTable ()).collect (Collectors .toList ()));
9992 boolean allTablesContainOneRow = allTables .stream ().allMatch (t -> t .getNrRows (globalState ) == 1 );
10093 boolean testAggregateFunctions = allTablesContainOneRow && globalState .getOptions ().testAggregateFunctionsPQS ();
101- pivotRowExpression = getColExpressions (testAggregateFunctions , columns , columnsWithoutRowid );
94+ pivotRowExpression = getColExpressions (testAggregateFunctions , columnsWithoutRowid , columnsWithoutRowid );
10295 selectStatement .setFetchColumns (pivotRowExpression );
103- SQLite3Expression whereClause = generateRectifiedExpression (columns , pivotRow , false );
96+ SQLite3Expression whereClause = generateRectifiedExpression (columnsWithoutRowid , pivotRow , false );
10497 selectStatement .setWhereClause (whereClause );
105- List <SQLite3Expression > groupByClause = generateGroupByClause (columns , pivotRow , allTablesContainOneRow );
98+ List <SQLite3Expression > groupByClause = generateGroupByClause (columnsWithoutRowid , pivotRow ,
99+ allTablesContainOneRow );
106100 selectStatement .setGroupByClause (groupByClause );
107101 SQLite3Expression limitClause = generateLimit ((long ) (Math .pow (globalState .getOptions ().getMaxNumberInserts (),
108102 joinStatements .size () + randomFromTables .getTables ().size ())));
0 commit comments