Skip to content

Commit 844c667

Browse files
committed
Working on #592
1 parent a18209b commit 844c667

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

src/Tqdev/PhpCrudApi/Database/TypeConverter.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,25 @@ public function __construct(string $driver)
1414
private $fromJdbc = [
1515
'mysql' => [
1616
'clob' => 'longtext',
17-
'boolean' => 'tinyint',
17+
'boolean' => 'tinyint(1)',
1818
'blob' => 'longblob',
1919
'timestamp' => 'datetime',
2020
],
2121
'pgsql' => [
2222
'clob' => 'text',
2323
'blob' => 'bytea',
24+
'float' => 'real',
25+
'double' => 'double precision',
26+
'varbinary(*)' => 'bytea',
2427
],
2528
'sqlsrv' => [
2629
'boolean' => 'bit',
2730
'varchar' => 'nvarchar',
2831
'clob' => 'ntext',
2932
'blob' => 'image',
33+
'timestamp' => 'datetime2',
34+
'double' => 'float',
35+
'float' => 'real',
3036
],
3137
];
3238

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
skip-for-pgsql: varbinary is not properly supported yet
2+
skip-for-sqlite: float is returned as string
3+
skip-for-sqlsrv: float has high precision and time and datetime have microseconds
4+
===
5+
POST /columns
6+
7+
{"name":"types","type":"table","columns":[
8+
{"name":"id","type":"integer","pk":true},
9+
{"name":"integer","type":"integer"},
10+
{"name":"bigint","type":"bigint"},
11+
{"name":"varchar","type":"varchar","length":10},
12+
{"name":"decimal","type":"decimal","precision":10,"scale":4},
13+
{"name":"float","type":"float"},
14+
{"name":"double","type":"double"},
15+
{"name":"boolean","type":"boolean"},
16+
{"name":"date","type":"date"},
17+
{"name":"time","type":"time"},
18+
{"name":"timestamp","type":"timestamp"},
19+
{"name":"clob","type":"clob"},
20+
{"name":"blob","type":"blob"},
21+
{"name":"varbinary","type":"varbinary","length":10},
22+
{"name":"geometry","type":"geometry"}
23+
]}
24+
===
25+
200
26+
Content-Type: application/json
27+
Content-Length: 4
28+
29+
true
30+
===
31+
POST /records/types
32+
Content-Type: application/json
33+
34+
{"integer":2,"bigint":3,"varchar":"abc","decimal":"1.23","float":2.34,"double":3.45,"boolean":true,"date":"1970-01-01","time":"00:00:01","timestamp":"2001-02-03 04:05:06","clob":"a","blob":"YQ==","varbinary":"YQ==","geometry":"POINT(1 2)"}
35+
===
36+
200
37+
Content-Type: application/json
38+
Content-Length: 1
39+
40+
1
41+
===
42+
GET /records/types/1
43+
===
44+
200
45+
Content-Type: application/json
46+
Content-Length: 248
47+
48+
{"id":1,"integer":2,"bigint":3,"varchar":"abc","decimal":"1.2300","float":2.34,"double":3.45,"boolean":true,"date":"1970-01-01","time":"00:00:01","timestamp":"2001-02-03 04:05:06","clob":"a","blob":"YQ==","varbinary":"YQ==","geometry":"POINT(1 2)"}
49+
===
50+
DELETE /columns/types
51+
===
52+
200
53+
Content-Type: application/json
54+
Content-Length: 4
55+
56+
true

0 commit comments

Comments
 (0)