mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Match multi-line JOIN statements (#10960)
This commit is contained in:
parent
157317d7ee
commit
55e42683f8
@ -802,6 +802,6 @@ abstract class SQLConditionalExpression extends SQLExpression
|
||||
*/
|
||||
public static function getJoinRegex(): string
|
||||
{
|
||||
return '/JOIN +.*? +(AS|ON|USING\(?) +/i';
|
||||
return '/JOIN\s+.*?\s+(AS|ON|USING\(?)\s+/is';
|
||||
}
|
||||
}
|
||||
|
27
tests/php/ORM/DBQueryBuilderTest.php
Normal file
27
tests/php/ORM/DBQueryBuilderTest.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Connect\DBQueryBuilder;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
|
||||
class DBQueryBuilderTest extends SapphireTest
|
||||
{
|
||||
protected $usesDatabase = false;
|
||||
|
||||
public function testMultilineJoin()
|
||||
{
|
||||
$join = <<<JOIN
|
||||
INNER JOIN
|
||||
(SELECT DISTINCT "SiteTreeLink"."ClassName", "SiteTreeLink"."LastEdited", "SiteTreeLink"."Created", "SiteTreeLink"."LinkedID",
|
||||
"SiteTreeLink"."ParentID", "SiteTreeLink"."ParentClass", "SiteTreeLink"."ID" FROM "SiteTreeLink")
|
||||
AS "SiteTreeLink" ON "SiteTreeLink"."LinkedID" = "SiteTree"."ID"
|
||||
JOIN;
|
||||
$select = new SQLSelect('*', ['SomeTable', $join]);
|
||||
$builder = new DBQueryBuilder();
|
||||
|
||||
$params = [];
|
||||
$this->assertSame('FROM SomeTable ' . $join, trim($builder->buildFromFragment($select, $params)));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user