Skip to content

Commit 6dd59b6

Browse files
committed
- Support simple arrays like [1, 2, 3, 4, 5] as table-names which will result in a UNION-chain-subquery
1 parent 0585ed6 commit 6dd59b6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Builder/Traits/TableNameBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected function buildTableName($alias, $name) {
2626
$parts = [];
2727
foreach($name as $index => $bucket) {
2828
if(ctype_digit((string) $index) && is_scalar($bucket)) {
29-
$parts[] = "SELECT {$this->db()->quote($bucket)}";
29+
$parts[] = "SELECT {$this->db()->quote($bucket)} AS {$this->db()->quoteField('value')}";
3030
} else {
3131
$values = [];
3232
foreach($bucket as $field => $value) {

tests/Builder/SelectTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public function testParametrizedVirtualTables() {
395395
public function testArrayTables() {
396396
$vt1 = TestSelect::create()
397397
->field('a.field1')
398-
->from('a', range(1, 9))
398+
->from('a', range(1, 9))->debug()
399399
->asString();
400400

401401
$this->assertEquals("SELECT\n\ta.field1\nFROM\n\t(SELECT '1'\n\tUNION\n\tSELECT '2'\n\tUNION\n\tSELECT '3'\n\tUNION\n\tSELECT '4'\n\tUNION\n\tSELECT '5'\n\tUNION\n\tSELECT '6'\n\tUNION\n\tSELECT '7'\n\tUNION\n\tSELECT '8'\n\tUNION\n\tSELECT '9') a\n", $vt1);

0 commit comments

Comments
 (0)