Browse Source

Support JSON as strings

Maurits van der Schee 6 years ago
parent
commit
60d672a825
4 changed files with 7 additions and 3 deletions
  1. 2
    2
      README.md
  2. 2
    0
      api.php
  3. 2
    0
      src/Tqdev/PhpCrudApi/Database/TypeConverter.php
  4. 1
    1
      tests/fixtures/blog_mysql.sql

+ 2
- 2
README.md View File

104
   - [x] Supports POST variables as input (x-www-form-urlencoded)
104
   - [x] Supports POST variables as input (x-www-form-urlencoded)
105
   - [x] Supports a JSON object as input
105
   - [x] Supports a JSON object as input
106
   - [x] Supports a JSON array as input (batch insert)
106
   - [x] Supports a JSON array as input (batch insert)
107
-  - [ ] Supports file upload from web forms (multipart/form-data)
107
+  - [x] Supports file upload from web forms (multipart/form-data)
108
   - [ ] ~~Condensed JSON output: first row contains field names~~
108
   - [ ] ~~Condensed JSON output: first row contains field names~~
109
   - [x] Sanitize and validate input using callbacks
109
   - [x] Sanitize and validate input using callbacks
110
   - [x] Permission system for databases, tables, columns and records
110
   - [x] Permission system for databases, tables, columns and records
118
   - [x] Atomic increment support via PATCH (for counters)
118
   - [x] Atomic increment support via PATCH (for counters)
119
   - [x] Binary fields supported with base64 encoding
119
   - [x] Binary fields supported with base64 encoding
120
   - [x] Spatial/GIS fields and filters supported with WKT
120
   - [x] Spatial/GIS fields and filters supported with WKT
121
-  - [ ] Unstructured data support through JSON/JSONB
121
+  - [ ] ~~Unstructured data support through JSON/JSONB~~
122
   - [x] Generate API documentation using OpenAPI tools
122
   - [x] Generate API documentation using OpenAPI tools
123
   - [x] Authentication via JWT token or username/password
123
   - [x] Authentication via JWT token or username/password
124
   - [ ] ~~SQLite support~~
124
   - [ ] ~~SQLite support~~

+ 2
- 0
api.php View File

2621
             'point' => 'geometry',
2621
             'point' => 'geometry',
2622
             'datetime' => 'timestamp',
2622
             'datetime' => 'timestamp',
2623
             'enum' => 'varchar',
2623
             'enum' => 'varchar',
2624
+            'json' => 'clob',
2624
         ],
2625
         ],
2625
         'pgsql' => [
2626
         'pgsql' => [
2626
             'bigserial' => 'bigint',
2627
             'bigserial' => 'bigint',
2633
             'circle' => 'geometry',
2634
             'circle' => 'geometry',
2634
             'double precision' => 'double',
2635
             'double precision' => 'double',
2635
             'inet' => 'integer',
2636
             'inet' => 'integer',
2637
+            'json' => 'clob',
2636
             'jsonb' => 'clob',
2638
             'jsonb' => 'clob',
2637
             'line' => 'geometry',
2639
             'line' => 'geometry',
2638
             'lseg' => 'geometry',
2640
             'lseg' => 'geometry',

+ 2
- 0
src/Tqdev/PhpCrudApi/Database/TypeConverter.php View File

62
             'point' => 'geometry',
62
             'point' => 'geometry',
63
             'datetime' => 'timestamp',
63
             'datetime' => 'timestamp',
64
             'enum' => 'varchar',
64
             'enum' => 'varchar',
65
+            'json' => 'clob',
65
         ],
66
         ],
66
         'pgsql' => [
67
         'pgsql' => [
67
             'bigserial' => 'bigint',
68
             'bigserial' => 'bigint',
75
             'double precision' => 'double',
76
             'double precision' => 'double',
76
             'inet' => 'integer',
77
             'inet' => 'integer',
77
             //'interval [ fields ]'
78
             //'interval [ fields ]'
79
+            'json' => 'clob',
78
             'jsonb' => 'clob',
80
             'jsonb' => 'clob',
79
             'line' => 'geometry',
81
             'line' => 'geometry',
80
             'lseg' => 'geometry',
82
             'lseg' => 'geometry',

+ 1
- 1
tests/fixtures/blog_mysql.sql View File

125
   `id` int(11) NOT NULL AUTO_INCREMENT,
125
   `id` int(11) NOT NULL AUTO_INCREMENT,
126
   `name` varchar(255) NOT NULL,
126
   `name` varchar(255) NOT NULL,
127
   `price` decimal(10,2) NOT NULL,
127
   `price` decimal(10,2) NOT NULL,
128
-  `properties` LONGTEXT NOT NULL,
128
+  `properties` JSON NOT NULL,
129
   `created_at` datetime NOT NULL,
129
   `created_at` datetime NOT NULL,
130
   `deleted_at` datetime NULL,
130
   `deleted_at` datetime NULL,
131
   PRIMARY KEY (`id`)
131
   PRIMARY KEY (`id`)

Loading…
Cancel
Save