Skip to content

Commit a5b1336

Browse files
committed
Improve JSON parsing
1 parent 93520ec commit a5b1336

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

api.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,11 +3619,11 @@ public static function fromJson(/* object */$json): ReflectedColumn
36193619
{
36203620
$name = $json->name;
36213621
$type = $json->type;
3622-
$length = isset($json->length) ? $json->length : 0;
3623-
$precision = isset($json->precision) ? $json->precision : 0;
3624-
$scale = isset($json->scale) ? $json->scale : 0;
3625-
$nullable = isset($json->nullable) ? $json->nullable : false;
3626-
$pk = isset($json->pk) ? $json->pk : false;
3622+
$length = isset($json->length) ? (int) $json->length : 0;
3623+
$precision = isset($json->precision) ? (int) $json->precision : 0;
3624+
$scale = isset($json->scale) ? (int) $json->scale : 0;
3625+
$nullable = isset($json->nullable) ? (bool) $json->nullable : false;
3626+
$pk = isset($json->pk) ? (bool) $json->pk : false;
36273627
$fk = isset($json->fk) ? $json->fk : '';
36283628
return new ReflectedColumn($name, $type, $length, $precision, $scale, $nullable, $pk, $fk);
36293629
}
@@ -3882,7 +3882,7 @@ public static function fromReflection(GenericReflection $reflection, string $nam
38823882
public static function fromJson(/* object */$json): ReflectedTable
38833883
{
38843884
$name = $json->name;
3885-
$type = $json->type;
3885+
$type = isset($json->type) ? $json->type : 'table';
38863886
$columns = [];
38873887
if (isset($json->columns) && is_array($json->columns)) {
38883888
foreach ($json->columns as $column) {
@@ -6297,6 +6297,7 @@ public function __construct(string $driver)
62976297
'smallint' => 'integer',
62986298
'real' => 'float',
62996299
'numeric' => 'decimal',
6300+
'nclob' => 'clob',
63006301
'time_with_timezone' => 'time',
63016302
'timestamp_with_timezone' => 'timestamp',
63026303
],
@@ -6389,7 +6390,7 @@ public function __construct(string $driver)
63896390
//'datalink' => true,
63906391
'date' => true,
63916392
'decimal' => true,
6392-
'distinct' => true,
6393+
//'distinct' => true,
63936394
'double' => true,
63946395
'float' => true,
63956396
'integer' => true,

src/Tqdev/PhpCrudApi/Column/Reflection/ReflectedTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function fromReflection(GenericReflection $reflection, string $nam
6868
public static function fromJson(/* object */$json): ReflectedTable
6969
{
7070
$name = $json->name;
71-
$type = $json->type;
71+
$type = isset($json->type) ? $json->type : 'table';
7272
$columns = [];
7373
if (isset($json->columns) && is_array($json->columns)) {
7474
foreach ($json->columns as $column) {

0 commit comments

Comments
 (0)