mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.3' into 4.4
This commit is contained in:
commit
82c8225502
@ -287,6 +287,13 @@ abstract class SQLConditionalExpression extends SQLExpression
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match('/AS\s+(?:"[^"]+"|[A-Z0-9_]+)\s*$/i', $join)) {
|
||||
// custom aliases override the ones defined through array keys
|
||||
// this is only meant to keep backward compatibility with SS <= 4.3,
|
||||
// to be removed in SS5
|
||||
continue;
|
||||
}
|
||||
|
||||
$trimmedAlias = trim($alias, '"');
|
||||
|
||||
if ($trimmedAlias !== trim($join, '"')) {
|
||||
|
@ -841,10 +841,22 @@ class SQLSelectTest extends SapphireTest
|
||||
$sql = $query->sql();
|
||||
|
||||
$this->assertSQLEquals(
|
||||
'SELECT *
|
||||
FROM "MyTable" AS "MyTableAlias"
|
||||
'SELECT *
|
||||
FROM "MyTable" AS "MyTableAlias"
|
||||
LEFT JOIN "OtherTable" AS "OtherTableAlias" ON "Thing" = "OtherThing"',
|
||||
$sql
|
||||
);
|
||||
|
||||
$query = SQLSelect::create('*', [
|
||||
'MyTableAlias' => '"MyTable"',
|
||||
'ignoredAlias' => ', (SELECT * FROM "MyTable" where "something" = "whatever") as "CrossJoin"'
|
||||
]);
|
||||
$sql = $query->sql();
|
||||
|
||||
$this->assertSQLEquals(
|
||||
'SELECT * FROM "MyTable" AS "MyTableAlias" , '.
|
||||
'(SELECT * FROM "MyTable" where "something" = "whatever") as "CrossJoin"',
|
||||
$sql
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user