Maurits van der Schee 5 years ago
parent
commit
0f6ed92ddf

+ 4
- 4
src/Tqdev/PhpCrudApi/Database/GenericReflection.php View File

@@ -106,7 +106,7 @@ class GenericReflection
106 106
                 return 'SELECT c.name AS "COLUMN_NAME", c.is_nullable AS "IS_NULLABLE", t.Name AS "DATA_TYPE", (c.max_length/2) AS "CHARACTER_MAXIMUM_LENGTH", c.precision AS "NUMERIC_PRECISION", c.scale AS "NUMERIC_SCALE", \'\' AS "COLUMN_TYPE" FROM sys.columns c INNER JOIN sys.types t ON c.user_type_id = t.user_type_id WHERE c.object_id = OBJECT_ID(?) AND \'\' <> ?';
107 107
             case 'sqlite':
108 108
                 $this->updateSqlLiteReflectionTables();
109
-                return 'SELECT "name" AS "COLUMN_NAME", case when "notnull"==1 then \'no\' else \'yes\' end as "IS_NULLABLE", "type" AS "DATA_TYPE", 2147483647 AS "CHARACTER_MAXIMUM_LENGTH", 0 AS "NUMERIC_PRECISION", 0 AS "NUMERIC_SCALE", \'\' AS "COLUMN_TYPE" FROM "sys/columns" WHERE "self" = ? AND \'\' <> ?';
109
+                return 'SELECT "name" AS "COLUMN_NAME", case when "notnull"==1 then \'no\' else \'yes\' end as "IS_NULLABLE", lower("type") AS "DATA_TYPE", 2147483647 AS "CHARACTER_MAXIMUM_LENGTH", 0 AS "NUMERIC_PRECISION", 0 AS "NUMERIC_SCALE", \'\' AS "COLUMN_TYPE" FROM "sys/columns" WHERE "self" = ? AND \'\' <> ?';
110 110
         }
111 111
     }
112 112
 
@@ -184,7 +184,7 @@ class GenericReflection
184 184
         if ($this->driver == 'mysql') {
185 185
             foreach ($results as &$result) {
186 186
                 // mysql does not properly reflect display width of types
187
-                preg_match('|([a-zA-Z]+)(\(([0-9]+)(,([0-9]+))?\))?|', $result['DATA_TYPE'], $matches);
187
+                preg_match('|([a-z]+)(\(([0-9]+)(,([0-9]+))?\))?|', $result['DATA_TYPE'], $matches);
188 188
                 $result['DATA_TYPE'] = $matches[1];
189 189
                 if (!$result['CHARACTER_MAXIMUM_LENGTH']) {
190 190
                     if (isset($matches[3])) {
@@ -198,8 +198,8 @@ class GenericReflection
198 198
         }
199 199
         if ($this->driver == 'sqlite') {
200 200
             foreach ($results as &$result) {
201
-                // mysql does not properly reflect display width of types
202
-                preg_match('|([a-zA-Z]+)(\(([0-9]+)(,([0-9]+))?\))?|', $result['DATA_TYPE'], $matches);
201
+                // sqlite does not properly reflect display width of types
202
+                preg_match('|([a-z]+)(\(([0-9]+)(,([0-9]+))?\))?|', $result['DATA_TYPE'], $matches);
203 203
                 if (isset($matches[1])) {
204 204
                     $result['DATA_TYPE'] = $matches[1];
205 205
                 } else {

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

@@ -17,7 +17,7 @@ DROP TABLE IF EXISTS "comments";
17 17
 CREATE TABLE "comments" (
18 18
   "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
19 19
   "post_id" integer NOT NULL,
20
-  "message" varchar(255) NOT NULL,
20
+  "message" VARCHAR(255) NOT NULL,
21 21
   "category_id" integer NOT NULL,
22 22
   FOREIGN KEY ("post_id") REFERENCES "posts" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT,
23 23
   FOREIGN KEY ("category_id") REFERENCES "categories" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT

Loading…
Cancel
Save