Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom joins #691

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d39cf66
Added support for parsing join configurations for aggregations
cmacmackin Nov 18, 2023
c5f5f20
Collect data on how to join schemas
cmacmackin Apr 8, 2023
d224d1c
Updated tests to include JOIN ON logic
cmacmackin Nov 18, 2023
e3fd32b
Complete processing of JOIN configurations
cmacmackin Nov 18, 2023
70ec5d2
Add (empty) join data to schema data
cmacmackin Apr 9, 2023
8df3799
Initial implementation of custom JOINs for simple types
cmacmackin Nov 18, 2023
a1c85df
Move logic for selecting columns inside column types
cmacmackin Apr 10, 2023
395df62
Refactored selecting columns to hide complexity
cmacmackin Nov 18, 2023
59b0a86
Add tests that page exists and is accessible for custom joins
cmacmackin Nov 18, 2023
4ff5cce
Refactored filtering so can reuse logic for joins
cmacmackin Nov 18, 2023
3605876
Refactor how join conditions are handled
cmacmackin Nov 18, 2023
d452b99
Fixed regression from rebasing
cmacmackin Nov 19, 2023
3cbc3ab
Further regression-fixes from rebasing
cmacmackin Nov 19, 2023
096529f
Fixed bug building searches with custom joins
cmacmackin Nov 19, 2023
4ebe1fc
Updated test in line with refactoring
cmacmackin Nov 19, 2023
e1da59c
Fixed code-sniffer issues
cmacmackin Nov 19, 2023
8d0bdc3
Separated additional joins from getSqlCompareValue
cmacmackin Nov 29, 2023
5d60c3b
Decided not to support joins over multi-valued columns
cmacmackin Nov 30, 2023
2e6f73c
Attempt to implement joins against page titles
cmacmackin Nov 30, 2023
38630c3
Improved robustness of addLeftJoin
cmacmackin Nov 30, 2023
de60ccf
Fixed style problems flagged on CI
cmacmackin Nov 30, 2023
9df21fc
Shortened long line
cmacmackin Nov 30, 2023
2e02e3c
Fixed code style issues
cmacmackin Nov 30, 2023
330a612
Added tests for joining against page titles and summaries
cmacmackin Nov 30, 2023
f4d9287
Move page-type-specific join logic into separate method
cmacmackin Nov 30, 2023
474f0ea
Make sure can wrap either scalar or arrays of values
cmacmackin Nov 30, 2023
bbd6891
Removed trailing whitespace
cmacmackin Nov 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions _test/AccessTableDataSQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public static function buildGetDataSQL_testdata()
"SELECT DATA.pid AS PID,
DATA.col1 AS out1,
DATA.col2 AS out2,
GROUP_CONCAT_DISTINCT(M3.value,'" . Search::CONCAT_SEPARATOR . "') AS out3
GROUP_CONCAT_DISTINCT(M1.value,'" . Search::CONCAT_SEPARATOR . "') AS out3
FROM data_testtable AS DATA
LEFT OUTER JOIN multi_testtable AS M3
ON DATA.pid = M3.pid
AND DATA.rev = M3.rev
AND M3.colref = 3
LEFT OUTER JOIN multi_testtable AS M1
ON DATA.pid = M1.pid
AND DATA.rev = M1.rev
AND M1.colref = 3
WHERE (DATA.pid = ?
AND DATA.rev = ?)
GROUP BY DATA.pid,out1,out2",
Expand Down
5 changes: 4 additions & 1 deletion _test/ConfigParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ConfigParserTest extends StructTest
public function test_simple()
{
$lines = [
"schema : testtable, another, foo bar",
"schema : testtable, another ON field = %pageid%, foo bar",
"cols : %pageid%, count",
"sort : ^count",
"sort : %pageid%, ^bam",
Expand Down Expand Up @@ -49,16 +49,19 @@ public function test_simple()
[
0 => 'testtable',
1 => '',
2 => [],
],
1 =>
[
0 => 'another',
1 => '',
2 => ['field', '=', '%pageid%'],
],
2 =>
[
0 => 'foo',
1 => 'bar',
2 => [],
],
],
'cols' =>
Expand Down
8 changes: 4 additions & 4 deletions _test/InlineConfigParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InlineConfigParserTest extends StructTest
public function test_simple()
{
// Same initial setup as ConfigParser.test
$inline = '"testtable, another, foo bar"."%pageid%, count" ';
$inline = '"testtable, another ON another.a = testtable.b, foo bar ON bar.a = testtable.a"."%pageid%, count" ';
$inline .= '?sort: ^count sort: "%pageid%, ^bam" align: "r,l,center,foo"';
// Add InlineConfigParser-specific tests:
$inline .= ' & "%pageid% != start" | "count = 1"';
Expand All @@ -38,9 +38,9 @@ public function test_simple()
'limit' => 0,
'rownumbers' => false,
'schemas' => [
['testtable', ''],
['another', ''],
['foo', 'bar'],
['testtable', '', []],
['another', '', ['another.a', '=', 'testtable.b']],
['foo', 'bar', ['bar.a', '=', 'testtable.a']],
],
'sepbyheaders' => false,
'sort' => [
Expand Down
14 changes: 7 additions & 7 deletions _test/SearchConfigParameterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public function test_constructor()

$data = [
'schemas' => [
['schema1', 'alias1'],
['schema2', 'alias2'],
['schema1', 'alias1', []],
['schema2', 'alias2', []],
],
'cols' => [
'%pageid%',
Expand Down Expand Up @@ -142,8 +142,8 @@ public function test_filter()
{
$data = [
'schemas' => [
['schema1', 'alias1'],
['schema2', 'alias2'],
['schema1', 'alias1', []],
['schema2', 'alias2', []],
],
'cols' => [
'%pageid%',
Expand Down Expand Up @@ -194,8 +194,8 @@ public function test_sort()
{
$data = [
'schemas' => [
['schema1', 'alias1'],
['schema2', 'alias2'],
['schema1', 'alias1', []],
['schema2', 'alias2', []],
],
'cols' => [
'%pageid%',
Expand Down Expand Up @@ -228,7 +228,7 @@ public function test_pagination()

$data = [
'schemas' => [
['schema2', 'alias2'],
['schema2', 'alias2', []],
],
'cols' => [
'afirst'
Expand Down
5 changes: 3 additions & 2 deletions _test/SearchConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public function test_filtervars_struct()
]
);

$searchConfig = new SearchConfig(['schemas' => [['schema1', 'alias']]]);
$searchConfig = new SearchConfig(['schemas' => [['schema1', 'alias', []]]]);

$this->assertEquals('test', $searchConfig->applyFilterVars('$STRUCT.first$'));
$this->assertEquals('test', $searchConfig->applyFilterVars('$STRUCT.alias.first$'));
$this->assertEquals('test', $searchConfig->applyFilterVars('$STRUCT.schema1.first$'));
Expand Down Expand Up @@ -94,7 +95,7 @@ public function test_filtervars_struct_other()
]
);

$searchConfig = new SearchConfig(['schemas' => [['schema3', 'alias']]]);
$searchConfig = new SearchConfig(['schemas' => [['schema3', 'alias', []]]]);
$this->assertEquals('', $searchConfig->applyFilterVars('$STRUCT.afirst$'));
$this->assertEquals('test', $searchConfig->applyFilterVars('$STRUCT.schema2.afirst$'));

Expand Down
Loading
Loading