Skip to content

Commit 57cd6de

Browse files
committed
improve test for #592
1 parent b360a18 commit 57cd6de

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Tqdev/PhpCrudApi/Database/DataConverter.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@ public function __construct(string $driver)
1616

1717
private function convertRecordValue($conversion, $value)
1818
{
19-
switch ($conversion) {
19+
$args = explode('|', $conversion);
20+
$type = array_shift($args);
21+
switch ($type) {
2022
case 'boolean':
2123
return $value ? true : false;
2224
case 'integer':
2325
return (int) $value;
26+
case 'float':
27+
return (float) $value;
28+
case 'decimal':
29+
return sprintf('%.' . $args[0] . 'f', $value);
2430
}
2531
return $value;
2632
}
@@ -33,6 +39,12 @@ private function getRecordValueConversion(ReflectedColumn $column): string
3339
if (in_array($this->driver, ['sqlsrv', 'sqlite']) && in_array($column->getType(), ['integer', 'bigint'])) {
3440
return 'integer';
3541
}
42+
if (in_array($this->driver, ['sqlite']) && in_array($column->getType(), ['float', 'double'])) {
43+
return 'float';
44+
}
45+
if (in_array($this->driver, ['sqlite']) && in_array($column->getType(), ['decimal'])) {
46+
return 'decimal|' . $column->getScale();
47+
}
3648
return 'none';
3749
}
3850

tests/functional/003_columns/014_create_types_table.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
skip-for-pgsql: varbinary is not properly supported yet
2-
skip-for-sqlite: float is returned as string, decimal does not respect scale
2+
#skip-for-sqlite: float is returned as string, decimal does not respect scale
33
skip-for-sqlsrv: float has high precision and time and datetime have microseconds
44
===
55
POST /columns

0 commit comments

Comments
 (0)