Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit 7babecd

Browse files
committed
Fix-xDbType
1 parent 51853d5 commit 7babecd

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/lib/AttributeResolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ protected function resolveProperty(PropertySchema $property, bool $isRequired):v
203203
->setDescription($property->getAttr('description', ''))
204204
->setReadOnly($property->isReadonly())
205205
->setDefault($property->guessDefault())
206+
->setXDbType($property->getAttr('x-db-type', null))
206207
->setIsPrimary($property->isPrimaryKey());
207208
if ($property->isReference()) {
208209
if ($property->isVirtual()) {

src/lib/items/Attribute.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class Attribute extends BaseObject
4646
*/
4747
public $dbType = 'string';
4848

49+
/**
50+
* Custom db type
51+
*/
52+
public $xDbType;
53+
4954
/**
5055
* @var string
5156
*/
@@ -117,6 +122,17 @@ public function setDbType(string $dbType):Attribute
117122
return $this;
118123
}
119124

125+
public function setXDbType($xDbType):Attribute
126+
{
127+
$this->xDbType = $xDbType;
128+
return $this;
129+
}
130+
131+
public function getXDbType($xDbType)
132+
{
133+
return $this->xDbType;
134+
}
135+
120136
public function setDescription(string $description):Attribute
121137
{
122138
$this->description = $description;
@@ -270,6 +286,13 @@ public function toColumnSchema():ColumnSchema
270286

271287
private function dbTypeAbstract(string $type):string
272288
{
289+
/**
290+
* Custom db type
291+
*/
292+
if ($this->xDbType){
293+
return $this->xDbType;
294+
}
295+
273296
if (stripos($type, 'int') === 0) {
274297
return 'integer';
275298
}

0 commit comments

Comments
 (0)