Merge branch '4.3' into 4.4

This commit is contained in:
Guy Marriott 2019-05-03 09:45:25 +12:00
commit 82c8225502
No known key found for this signature in database
GPG Key ID: A80F9ACCB86D3DA7
2 changed files with 21 additions and 2 deletions

View File

@ -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, '"')) {

View File

@ -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
);
}
}