diff --git a/src/Persistence/Sql.php b/src/Persistence/Sql.php index c3b3410e53..74703dbcca 100644 --- a/src/Persistence/Sql.php +++ b/src/Persistence/Sql.php @@ -433,7 +433,7 @@ public function lastInsertId(Model $model): string $query = $this->connection->dsql()->table($model->table); $query->field($query->expr('max({id_col})', ['id_col' => $model->id_field]), 'max_id'); - return $query->getOne(); + return (string) $query->getOne(); } return $this->connection->lastInsertId($this->getIdSequenceName($model)); diff --git a/src/Persistence/Sql/Query.php b/src/Persistence/Sql/Query.php index 297762be7f..78e52a3f32 100644 --- a/src/Persistence/Sql/Query.php +++ b/src/Persistence/Sql/Query.php @@ -226,6 +226,11 @@ protected function doGetOne() return $this->dsql->getOne(); } + public function getIterator(): iterable + { + return $this->dsql->getIterator(); + } + public function getDsqlExpression($expression = null) { return $this->dsql; diff --git a/tests/ExpressionSqlTest.php b/tests/ExpressionSqlTest.php index fddc3f3960..1a197ff878 100644 --- a/tests/ExpressionSqlTest.php +++ b/tests/ExpressionSqlTest.php @@ -160,7 +160,7 @@ public function testExpressions() } elseif ($this->getDatabasePlatform() instanceof OraclePlatform) { $this->assertSame( 'select "id","name","surname","cached_name",("name" || \' \' || "surname") "full_name" from "user" where (("name" || \' \' || "surname") != "cached_name")', - $m->action('select')->render() + $m->toQuery()->select()->render() ); } elseif ($this->getDatabasePlatform() instanceof MySQLPlatform) { $this->assertSame(