Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions proofs/connection/pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
static function($assert) use ($connection) {
$table = Table\Name::of('test_lazy_load');

$connection(DropTable::ifExists($table));
$connection(CreateTable::named(
$_ = $connection(DropTable::ifExists($table));
$_ = $connection(CreateTable::named(
$table,
Column::of(
Column\Name::of('i'),
Expand All @@ -61,7 +61,7 @@ static function($assert) use ($connection) {
));

for ($i = 0; $i < 100_000; $i++) {
$connection(Insert::into(
$_ = $connection(Insert::into(
$table,
Row::of([
'i' => $i,
Expand All @@ -86,7 +86,7 @@ static function($assert) use ($connection) {
->inLessThan()
->megaBytes(3);

$connection(DropTable::named($table));
$_ = $connection(DropTable::named($table));
},
);

Expand All @@ -96,15 +96,15 @@ static function($assert) use ($connection) {
static function($assert) use ($connection, $dsn) {
$table = Table\Name::of('test_charset');

$connection(CreateTable::ifNotExists(
$_ = $connection(CreateTable::ifNotExists(
$table,
Column::of(
Column\Name::of('str'),
Column\Type::longtext(),
),
));

$connection(Insert::into(
$_ = $connection(Insert::into(
$table,
Row::of([
'str' => 'gelé',
Expand Down Expand Up @@ -139,7 +139,7 @@ static function($assert) use ($connection, $dsn) {
),
);

$connection(DropTable::named($table));
$_ = $connection(DropTable::named($table));
},
);
}
Expand All @@ -148,7 +148,7 @@ static function($assert) use ($connection, $dsn) {
"Select join({$driver->name})",
static function($assert) use ($connection) {
$table = Table\Name::of('test_left_join');
$connection(CreateTable::ifNotExists(
$_ = $connection(CreateTable::ifNotExists(
$table,
Column::of(
Column\Name::of('id'),
Expand All @@ -163,14 +163,14 @@ static function($assert) use ($connection) {
Column\Type::int()->nullable(),
),
));
$connection(Delete::from($table));
$_ = $connection(Delete::from($table));
$insert = MultipleInsert::into(
$table,
Column\Name::of('id'),
Column\Name::of('name'),
Column\Name::of('parent'),
);
$connection($insert(Sequence::of(
$_ = $connection($insert(Sequence::of(
Row::of([
'id' => 1,
'name' => 'value_1',
Expand Down Expand Up @@ -246,7 +246,7 @@ public function value(): int
->toList(),
);

$connection(DropTable::named($table));
$_ = $connection(DropTable::named($table));
},
);

Expand All @@ -255,14 +255,14 @@ public function value(): int
static function($assert) use ($connection) {
$parent = Table\Name::of('test_cascade_delete_parent');
$child = Table\Name::of('test_cascade_delete_child');
$connection(CreateTable::ifNotExists(
$_ = $connection(CreateTable::ifNotExists(
$parent,
Column::of(
Column\Name::of('id'),
Column\Type::int(),
),
)->primaryKey(Column\Name::of('id')));
$connection(CreateTable::ifNotExists(
$_ = $connection(CreateTable::ifNotExists(
$child,
Column::of(
Column\Name::of('id'),
Expand All @@ -275,9 +275,9 @@ static function($assert) use ($connection) {
)->constraint(
ForeignKey::of(Column\Name::of('parent'), $parent, Column\Name::of('id'))->onDeleteCascade(),
));
$connection(Delete::from($child));
$connection(Delete::from($parent));
$connection(Insert::into(
$_ = $connection(Delete::from($child));
$_ = $connection(Delete::from($parent));
$_ = $connection(Insert::into(
$parent,
Row::of([
'id' => 1,
Expand All @@ -288,7 +288,7 @@ static function($assert) use ($connection) {
Column\Name::of('id'),
Column\Name::of('parent'),
);
$connection($insert(Sequence::of(
$_ = $connection($insert(Sequence::of(
Row::of([
'id' => 1,
'parent' => 1,
Expand All @@ -299,13 +299,13 @@ static function($assert) use ($connection) {
]),
)));

$connection(Delete::from($parent));
$_ = $connection(Delete::from($parent));
$rows = $connection(Select::from($child));

$assert->same(0, $rows->size());

$connection(DropTable::named($child));
$connection(DropTable::named($parent));
$_ = $connection(DropTable::named($child));
$_ = $connection(DropTable::named($parent));
},
);

Expand All @@ -314,14 +314,14 @@ static function($assert) use ($connection) {
static function($assert) use ($connection) {
$parent = Table\Name::of('test_set_null_delete_parent');
$child = Table\Name::of('test_set_null_delete_child');
$connection(CreateTable::ifNotExists(
$_ = $connection(CreateTable::ifNotExists(
$parent,
Column::of(
Column\Name::of('id'),
Column\Type::int(),
),
)->primaryKey(Column\Name::of('id')));
$connection(CreateTable::ifNotExists(
$_ = $connection(CreateTable::ifNotExists(
$child,
Column::of(
Column\Name::of('id'),
Expand All @@ -334,9 +334,9 @@ static function($assert) use ($connection) {
)->constraint(
ForeignKey::of(Column\Name::of('parent'), $parent, Column\Name::of('id'))->onDeleteSetNull(),
));
$connection(Delete::from($child));
$connection(Delete::from($parent));
$connection(Insert::into(
$_ = $connection(Delete::from($child));
$_ = $connection(Delete::from($parent));
$_ = $connection(Insert::into(
$parent,
Row::of([
'id' => 1,
Expand All @@ -347,7 +347,7 @@ static function($assert) use ($connection) {
Column\Name::of('id'),
Column\Name::of('parent'),
);
$connection($insert(Sequence::of(
$_ = $connection($insert(Sequence::of(
Row::of([
'id' => 1,
'parent' => 1,
Expand All @@ -358,7 +358,7 @@ static function($assert) use ($connection) {
]),
)));

$connection(Delete::from($parent));
$_ = $connection(Delete::from($parent));
$rows = $connection(Select::from($child))
->map(static fn($row) => $row->toArray())
->toList();
Expand All @@ -370,8 +370,8 @@ static function($assert) use ($connection) {
])
->same($rows);

$connection(DropTable::named($child));
$connection(DropTable::named($parent));
$_ = $connection(DropTable::named($child));
$_ = $connection(DropTable::named($parent));
},
);

Expand All @@ -397,14 +397,14 @@ static function($assert) use ($driver) {
static function($assert) use ($connection) {
$parent = Table\Name::of('test_join_delete_parent')->as('parent');
$child = Table\Name::of('test_join_delete_child')->as('child');
$connection(CreateTable::ifNotExists(
$_ = $connection(CreateTable::ifNotExists(
$child->name(),
Column::of(
Column\Name::of('id'),
Column\Type::int(),
),
)->primaryKey(Column\Name::of('id')));
$connection(
$_ = $connection(
CreateTable::ifNotExists(
$parent->name(),
Column::of(
Expand All @@ -423,23 +423,23 @@ static function($assert) use ($connection) {
Column\Name::of('id'),
),
);
$connection(Delete::from($parent->name()));
$connection(Delete::from($child->name()));
$connection(Insert::into(
$_ = $connection(Delete::from($parent->name()));
$_ = $connection(Delete::from($child->name()));
$_ = $connection(Insert::into(
$child->name(),
Row::of([
'id' => 2,
]),
));
$connection(Insert::into(
$_ = $connection(Insert::into(
$parent->name(),
Row::of([
'id' => 1,
'child' => 2,
]),
));

$connection(
$_ = $connection(
Delete::from($parent)
->join(
Join::left($child)->on(
Expand All @@ -460,8 +460,8 @@ static function($assert) use ($connection) {
$rows = $connection(Select::from($parent));
$assert->same(0, $rows->size());

$connection(DropTable::named($parent->name()));
$connection(DropTable::named($child->name()));
$_ = $connection(DropTable::named($parent->name()));
$_ = $connection(DropTable::named($child->name()));
},
);

Expand All @@ -470,7 +470,7 @@ static function($assert) use ($connection) {
given(Set::integers()->between(0, 1_000_000)),
static function($assert, $int) use ($connection) {
$table = Table\Name::of('test_unique');
$connection(CreateTable::ifNotExists(
$_ = $connection(CreateTable::ifNotExists(
$table,
Column::of(
Column\Name::of('id'),
Expand All @@ -482,14 +482,14 @@ static function($assert, $int) use ($connection) {
),
)->unique(Column\Name::of('id'), Column\Name::of('other')));

$connection(Insert::into(
$_ = $connection(Insert::into(
$table,
Row::of([
'id' => $int,
'other' => 'foo',
]),
));
$connection(Insert::into(
$_ = $connection(Insert::into(
$table,
Row::of([
'id' => $int,
Expand All @@ -505,7 +505,7 @@ static function($assert, $int) use ($connection) {
]),
)));

$connection(DropTable::named($table));
$_ = $connection(DropTable::named($table));
},
);

Expand Down
8 changes: 4 additions & 4 deletions properties/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public static function list(): array

public static function seed(Concrete $connection): void
{
$connection(DropTable::ifExists(Name::of('test')));
$connection(DropTable::ifExists(Name::of('test_values')));
$connection(CreateTable::named(
$_ = $connection(DropTable::ifExists(Name::of('test')));
$_ = $connection(DropTable::ifExists(Name::of('test_values')));
$_ = $connection(CreateTable::named(
Name::of('test'),
Column::of(Column\Name::of('id'), Column\Type::char(36)),
Column::of(Column\Name::of('username'), Column\Type::varchar(255)),
Column::of(Column\Name::of('registerNumber'), Column\Type::bigint()),
)->primaryKey(Column\Name::of('id')));
$connection(CreateTable::named(
$_ = $connection(CreateTable::named(
Name::of('test_values'),
Column::of(Column\Name::of('id'), Column\Type::char(36)),
Column::of(Column\Name::of('value'), Column\Type::varchar(255)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function ensureHeldBy(Assert $assert, object $connection): object
{
try {
$query = SQL::of('INSERT INTO test VALUES (:uuid, :username, :registerNumber);');
$connection($query);
$_ = $connection($query);
$assert->fail('it should throw an exception');
} catch (QueryFailed $e) {
$assert->same($query, $e->query());
Expand Down
2 changes: 1 addition & 1 deletion properties/Connection/AllowToStartTwoQueriesInParallel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function ensureHeldBy(Assert $assert, object $connection): object
{
// Insert at least one value to make sure the any() call will always
// return true
$connection(Insert::into(
$_ = $connection(Insert::into(
Name::of('test'),
Row::of([
'id' => $this->uuid,
Expand Down
2 changes: 1 addition & 1 deletion properties/Connection/AnInvalidQueryMustThrow.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function ensureHeldBy(Assert $assert, object $connection): object
{
try {
$query = SQL::of('INSERT');
$connection($query);
$_ = $connection($query);
$assert->fail('it should throw an exception');
} catch (QueryFailed $e) {
$assert->same($query, $e->query());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function ensureHeldBy(Assert $assert, object $connection): object
{
try {
$query = Transaction::commit;
$connection($query);
$_ = $connection($query);
$assert->fail('it should throw an exception');
} catch (QueryFailed $e) {
$assert->same($query, $e->query());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function applicableTo(object $connection): bool

public function ensureHeldBy(Assert $assert, object $connection): object
{
$connection(Transaction::start);
$_ = $connection(Transaction::start);

$connection(Insert::into(
$_ = $connection(Insert::into(
Name::of('test'),
Row::of([
'id' => $this->uuid,
Expand Down Expand Up @@ -97,7 +97,7 @@ public function ensureHeldBy(Assert $assert, object $connection): object
),
);

$connection(Transaction::commit);
$_ = $connection(Transaction::commit);

return $connection;
}
Expand Down
6 changes: 3 additions & 3 deletions properties/Connection/ContentIsAccessibleAfterCommit.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function applicableTo(object $connection): bool

public function ensureHeldBy(Assert $assert, object $connection): object
{
$connection(Transaction::start);
$_ = $connection(Transaction::start);

$connection(Insert::into(
$_ = $connection(Insert::into(
Name::of('test'),
Row::of([
'id' => $this->uuid,
Expand All @@ -63,7 +63,7 @@ public function ensureHeldBy(Assert $assert, object $connection): object
]),
));

$connection(Transaction::commit);
$_ = $connection(Transaction::commit);

$rows = $connection(SQL::of("SELECT * FROM test WHERE id = '{$this->uuid}'"));

Expand Down
Loading