Skip to content

Commit aacb9ea

Browse files
committed
update
1 parent 83c903f commit aacb9ea

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

api.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5166,11 +5166,17 @@ public function __construct(string $driver)
51665166

51675167
private function convertRecordValue($conversion, $value)
51685168
{
5169-
switch ($conversion) {
5169+
$args = explode('|', $conversion);
5170+
$type = array_shift($args);
5171+
switch ($type) {
51705172
case 'boolean':
51715173
return $value ? true : false;
51725174
case 'integer':
51735175
return (int) $value;
5176+
case 'float':
5177+
return (float) $value;
5178+
case 'decimal':
5179+
return number_format($value, $args[0], '.', '');
51745180
}
51755181
return $value;
51765182
}
@@ -5183,6 +5189,12 @@ private function getRecordValueConversion(ReflectedColumn $column): string
51835189
if (in_array($this->driver, ['sqlsrv', 'sqlite']) && in_array($column->getType(), ['integer', 'bigint'])) {
51845190
return 'integer';
51855191
}
5192+
if (in_array($this->driver, ['sqlite', 'pgsql']) && in_array($column->getType(), ['float', 'double'])) {
5193+
return 'float';
5194+
}
5195+
if (in_array($this->driver, ['sqlite']) && in_array($column->getType(), ['decimal'])) {
5196+
return 'decimal|' . $column->getScale();
5197+
}
51865198
return 'none';
51875199
}
51885200

@@ -5656,7 +5668,7 @@ private function getColumnAutoIncrement(ReflectedColumn $column, bool $update):
56565668
return $column->getPk() ? ' AUTO_INCREMENT' : '';
56575669
case 'pgsql':
56585670
case 'sqlsrv':
5659-
return '';
5671+
return $column->getPk() ? ' IDENTITY(1,1)' : '';
56605672
case 'sqlite':
56615673
return $column->getPk() ? ' AUTOINCREMENT' : '';
56625674
}
@@ -6024,7 +6036,7 @@ public function removeColumn(string $tableName, string $columnName)
60246036
private function query(string $sql, array $arguments): bool
60256037
{
60266038
$stmt = $this->pdo->prepare($sql);
6027-
//echo "- $sql -- " . json_encode($arguments) . "\n";
6039+
// echo "- $sql -- " . json_encode($arguments) . "\n";
60286040
return $stmt->execute($arguments);
60296041
}
60306042
}
@@ -6377,19 +6389,26 @@ public function __construct(string $driver)
63776389
private $fromJdbc = [
63786390
'mysql' => [
63796391
'clob' => 'longtext',
6380-
'boolean' => 'tinyint',
6392+
'boolean' => 'tinyint(1)',
63816393
'blob' => 'longblob',
63826394
'timestamp' => 'datetime',
63836395
],
63846396
'pgsql' => [
63856397
'clob' => 'text',
63866398
'blob' => 'bytea',
6399+
'float' => 'real',
6400+
'double' => 'double precision',
6401+
'varbinary' => 'bytea',
63876402
],
63886403
'sqlsrv' => [
63896404
'boolean' => 'bit',
63906405
'varchar' => 'nvarchar',
63916406
'clob' => 'ntext',
63926407
'blob' => 'image',
6408+
'time' => 'time(0)',
6409+
'timestamp' => 'datetime2(0)',
6410+
'double' => 'float',
6411+
'float' => 'real',
63936412
],
63946413
];
63956414

0 commit comments

Comments
 (0)