Skip to content

Commit

Permalink
fix some
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jan 2, 2022
1 parent b277aa4 commit 89d1883
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/Model2Inner.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ protected function init(): void
continue;
}

// TODO calculated fields, needs to copy (and maybe update some) more properties
if ($oField instanceof Field\SqlExpressionField) {
continue;
}

$fieldDefaults = [get_class($oField)];
foreach ([
'type',
Expand Down
10 changes: 5 additions & 5 deletions tests/ExpressionSqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testBasic(): void

if ($this->getDatabasePlatform() instanceof SqlitePlatform) {
$this->assertSame(
'select "id", "total_net", "total_vat", ("total_net"+"total_vat") "total_gross" from "invoice"',
'select "id", "total_net", "total_vat", ("total_net"+"total_vat") "total_gross" from (select "id", "total_net", "total_vat" from "invoice") "__inner__"',
$i->action('select')->render()[0]
);
}
Expand All @@ -51,7 +51,7 @@ public function testBasic(): void

if ($this->getDatabasePlatform() instanceof SqlitePlatform) {
$this->assertEquals(
'select "id", "total_net", "total_vat", ("total_net"+"total_vat") "total_gross", (("total_net"+"total_vat")*2) "double_total_gross" from "invoice"',
'select "id", "total_net", "total_vat", ("total_net"+"total_vat") "total_gross", (("total_net"+"total_vat")*2) "double_total_gross" from (select "id", "total_net", "total_vat" from "invoice") "__inner__"',
$i->action('select')->render()[0]
);
}
Expand All @@ -76,7 +76,7 @@ public function testBasicCallback(): void

if ($this->getDatabasePlatform() instanceof SqlitePlatform) {
$this->assertSame(
'select "id", "total_net", "total_vat", ("total_net"+"total_vat") "total_gross" from "invoice"',
'select "id", "total_net", "total_vat", ("total_net"+"total_vat") "total_gross" from (select "id", "total_net", "total_vat" from "invoice") "__inner__"',
$i->action('select')->render()[0]
);
}
Expand Down Expand Up @@ -104,7 +104,7 @@ public function testQuery(): void

if ($this->getDatabasePlatform() instanceof SqlitePlatform) {
$this->assertSame(
'select "id", "total_net", "total_vat", (select sum("total_net") from "invoice") "sum_net" from "invoice"',
'select "id", "total_net", "total_vat", (select sum("total_net") from (select "id", "total_net", "total_vat" from "invoice") "__inner__") "sum_net" from (select "id", "total_net", "total_vat" from "invoice") "__inner__"',
$i->action('select')->render()[0]
);
}
Expand Down Expand Up @@ -151,7 +151,7 @@ public function testExpressions(): void
}

$this->assertSameSql(
'select "id", "name", "surname", "cached_name", (' . $concatSql . ') "full_name" from "user" where ((' . $concatSql . ') != "cached_name")',
'select "id", "name", "surname", "cached_name", (' . $concatSql . ') "full_name" from (select "id", "name", "surname", "cached_name" from "user") "__inner__" where ((' . $concatSql . ') != "cached_name")',
$m->action('select')->render()[0]
);

Expand Down

0 comments on commit 89d1883

Please sign in to comment.