Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot authored and roxblnfk committed Feb 2, 2024
1 parent 7f610a4 commit 89c67df
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Command/Database/Insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ public function execute(): void
$returning = $this->mapper->mapColumns($returningFields);
// Array of [field name => column name]
$returning = \array_combine(\array_keys($returningFields), \array_keys($returning));
// TODO remove:
$returning = \array_slice($returning, 0, 1); // only one returning field is supported

$insert->returning(...array_values($returning));
// TODO replace:
// $insert->returning(...\array_values($returning));
$insert->returning(\array_values($returning)[0]);

$insertID = $insert->run();

if (count($returning) === 1) {
Expand All @@ -123,9 +124,8 @@ public function execute(): void
$field,
$this->mapper === null ? $insertID : $this->mapper->cast([$field => $insertID])[$field],
);
} else {
// todo multiple returning
}
// todo multiple returning
} else {
$insertID = $insert->run();

Expand Down
1 change: 0 additions & 1 deletion src/SchemaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ interface SchemaInterface
public const GENERATED_PHP_INSERT = 2; // generated by PHP code on insert like uuid
public const GENERATED_PHP_UPDATE = 4; // generated by PHP code on update like time


/**
* Return all roles defined within the schema.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Cycle\ORM\Tests\Functional\Driver\Common\Integration\Case321;

use Cycle\ORM\Select;
use Cycle\ORM\Tests\Functional\Driver\Common\BaseTest;
use Cycle\ORM\Tests\Functional\Driver\Common\Integration\IntegrationTestTrait;
use Cycle\ORM\Tests\Traits\TableTrait;
Expand Down
5 changes: 5 additions & 0 deletions tests/ORM/Unit/Command/InsertCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ public function testCommandWithReturningInterfaceShouldUseIt()
->with(['foo' => 'baaar'])
->andReturn(['baz' => 'bar']);

$this->mapper->shouldReceive('mapColumns')
->once()
->with(['id' => 'foo_id'])
->andReturn(['foo_id' => 'foo_id']);

$this->mapper->shouldReceive('cast')
->once()
->with(['id' => 234])
Expand Down

0 comments on commit 89c67df

Please sign in to comment.