Skip to content

Commit

Permalink
Add json column definition (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankay authored Apr 30, 2020
1 parent 6b40fdd commit d274d74
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/schema/product.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CREATE TABLE `product` (
`weight` decimal(11,2) NOT NULL,
`launch_date` date DEFAULT NULL,
`internal_note` text,
`properties` json NULL,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`added` datetime NOT NULL,
`deleted` datetime DEFAULT NULL,
Expand Down
1 change: 1 addition & 0 deletions src/Parse/ColumnDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class ColumnDefinition
'longtext' => [ 'blob', [0 ], null, false, true, true, null, ],
'enum' => [ 'enum', [0 ], null, false, false, true, 0, ],
'set' => [ 'set', [0 ], null, false, false, true, '', ],
'json' => [ 'json', [0 ], null, false, false, false, null, ],
];
/** @var array */
private static $typeInfoCache = [];
Expand Down
4 changes: 4 additions & 0 deletions tests/Parse/ColumnDefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ public function parseDatatypesProvider()
["x real", "`x` double DEFAULT NULL"],
["x real(8,3)", "`x` double(8,3) DEFAULT NULL"],

["x json", "`x` json"],
["x json NULL", "`x` json"],
["x json NOT NULL", "`x` json NOT NULL"],

// Ignore unrecognised column options
["x int foo", "`x` int(11) DEFAULT NULL"],
];
Expand Down

0 comments on commit d274d74

Please sign in to comment.