From 754b20ecbc2638dddd2395a2ef3cf5ccc37a67ba Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Fri, 8 Mar 2024 16:23:59 +0100 Subject: [PATCH] fix repeated QueryBuilder::from() call [closes #230] --- src/QueryBuilder/QueryBuilder.php | 1 + tests/cases/unit/QueryBuilderTest.from.php | 25 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/cases/unit/QueryBuilderTest.from.php diff --git a/src/QueryBuilder/QueryBuilder.php b/src/QueryBuilder/QueryBuilder.php index 073967a..13e86c5 100644 --- a/src/QueryBuilder/QueryBuilder.php +++ b/src/QueryBuilder/QueryBuilder.php @@ -178,6 +178,7 @@ public function from(string $fromExpression, ?string $alias = null, ...$args): s { $this->dirty(); $this->from = [$fromExpression, $alias]; + $this->args['from'] = []; $this->pushArgs('from', $args); return $this; } diff --git a/tests/cases/unit/QueryBuilderTest.from.php b/tests/cases/unit/QueryBuilderTest.from.php new file mode 100644 index 0000000..9325e9c --- /dev/null +++ b/tests/cases/unit/QueryBuilderTest.from.php @@ -0,0 +1,25 @@ +assertBuilder( + ['SELECT * FROM foo'], + $this->builder() + ->from('%table', 'alias', 'tableName') + ->from('foo') + ); + } +} + + +$test = new QueryBuilderFromTest(); +$test->run();