Skip to content

Commit 7c5fb25

Browse files
authored
Merge pull request #5 from moufmouf/expose_dbal_types
Exposing DBAL objects for fine-grained control
2 parents 2d13bcc + 4f783a6 commit 7c5fb25

File tree

6 files changed

+35
-3
lines changed

6 files changed

+35
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"prefer-stable": true,
3232
"extra": {
3333
"branch-alias": {
34-
"dev-master": "1.3.x-dev"
34+
"dev-master": "1.4.x-dev"
3535
}
3636
}
3737
}

src/FluidColumn.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,13 @@ private function getOptions(): FluidColumnOptions
244244
{
245245
return new FluidColumnOptions($this->fluidTable, $this->column, $this->namingStrategy);
246246
}
247+
248+
/**
249+
* Returns the underlying DBAL column.
250+
* @return Column
251+
*/
252+
public function getDbalColumn(): Column
253+
{
254+
return $this->column;
255+
}
247256
}

src/FluidTable.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,13 @@ public function extends(string $tableName): FluidTable
130130
$this->column($pk->getName())->references($tableName)->primaryKey();
131131
return $this;
132132
}
133+
134+
/**
135+
* Returns the underlying DBAL table.
136+
* @return Table
137+
*/
138+
public function getDbalTable(): Table
139+
{
140+
return $this->table;
141+
}
133142
}

tests/FluidColumnTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ public function testTypes()
9797
$column->datetimeTzImmutable();
9898
$this->assertSame(Type::getType(Type::DATETIMETZ_IMMUTABLE), $dbalColumn->getType());
9999

100+
$column->time();
101+
$this->assertSame(Type::getType(Type::TIME), $dbalColumn->getType());
102+
100103
$column->timeImmutable();
101104
$this->assertSame(Type::getType(Type::TIME_IMMUTABLE), $dbalColumn->getType());
102105

@@ -106,6 +109,8 @@ public function testTypes()
106109
$column->json();
107110
$this->assertSame(Type::getType(Type::JSON), $dbalColumn->getType());
108111
}
112+
113+
$this->assertSame('foo', $column->getDbalColumn()->getName());
109114
}
110115

111116
public function testReference()

tests/FluidSchemaTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,12 @@ public function testJunctionTable()
4444
$this->assertNotNull($schema->getTable('users_roles')->getColumn('user_id'));
4545
$this->assertNotNull($schema->getTable('users_roles')->getColumn('role_id'));
4646
}
47+
48+
public function testGetDbalSchema()
49+
{
50+
$schema = new Schema();
51+
$fluid = new FluidSchema($schema);
52+
53+
$this->assertSame($schema, $fluid->getDbalSchema());
54+
}
4755
}

tests/FluidTableTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,12 @@ public function testInherits()
137137
$this->assertSame(['id'], $fk->getLocalColumns());
138138
}
139139

140-
public function testGetDbalSchema()
140+
public function testGetDbalTable()
141141
{
142142
$schema = new Schema();
143143
$fluid = new FluidSchema($schema);
144144

145-
$this->assertSame($schema, $fluid->getDbalSchema());
145+
$contacts = $fluid->table('contacts');
146+
$this->assertSame('contacts', $contacts->getDbalTable()->getName());
146147
}
147148
}

0 commit comments

Comments
 (0)