@@ -101,6 +101,32 @@ private function getColumns()
101
101
'notNull ' => true ,
102
102
'default ' => 'CURRENT_TIMESTAMP ' ,
103
103
)),
104
+ 'column14 ' => new Column ("column14 " , array (
105
+ 'type ' => Column::TYPE_TINYBLOB ,
106
+ 'notNull ' => true
107
+ )),
108
+ 'column15 ' => new Column ("column15 " , array (
109
+ 'type ' => Column::TYPE_MEDIUMBLOB ,
110
+ 'notNull ' => true
111
+ )),
112
+ 'column16 ' => new Column ("column16 " , array (
113
+ 'type ' => Column::TYPE_BLOB ,
114
+ 'notNull ' => true
115
+ )),
116
+ 'column17 ' => new Column ("column17 " , array (
117
+ 'type ' => Column::TYPE_LONGBLOB ,
118
+ 'notNull ' => true
119
+ )),
120
+ 'column18 ' => new Column ("column18 " , array (
121
+ 'type ' => Column::TYPE_BOOLEAN ,
122
+ )),
123
+ 'column19 ' => new Column ("column19 " , array (
124
+ 'type ' => Column::TYPE_DOUBLE ,
125
+ )),
126
+ 'column20 ' => new Column ("column20 " , array (
127
+ 'type ' => Column::TYPE_DOUBLE ,
128
+ 'unsigned ' => true
129
+ ))
104
130
);
105
131
}
106
132
@@ -286,6 +312,47 @@ public function testDbColumn()
286
312
$ this ->assertEquals ($ column13 ->getType (), Column::TYPE_TIMESTAMP );
287
313
$ this ->assertTrue ($ column13 ->isNotNull ());
288
314
$ this ->assertEquals ($ column13 ->getDefault (), 'CURRENT_TIMESTAMP ' );
315
+
316
+ //Tinyblob column
317
+ $ column14 = $ columns ['column14 ' ];
318
+ $ this ->assertEquals ($ column14 ->getName (), 'column14 ' );
319
+ $ this ->assertEquals ($ column14 ->getType (), Column::TYPE_TINYBLOB );
320
+ $ this ->assertTrue ($ column14 ->isNotNull ());
321
+
322
+ //Mediumblob column
323
+ $ column15 = $ columns ['column15 ' ];
324
+ $ this ->assertEquals ($ column15 ->getName (), 'column15 ' );
325
+ $ this ->assertEquals ($ column15 ->getType (), Column::TYPE_MEDIUMBLOB );
326
+ $ this ->assertTrue ($ column15 ->isNotNull ());
327
+
328
+ //Blob column
329
+ $ column16 = $ columns ['column16 ' ];
330
+ $ this ->assertEquals ($ column16 ->getName (), 'column16 ' );
331
+ $ this ->assertEquals ($ column16 ->getType (), Column::TYPE_BLOB );
332
+ $ this ->assertTrue ($ column16 ->isNotNull ());
333
+
334
+ //Longblob column
335
+ $ column17 = $ columns ['column17 ' ];
336
+ $ this ->assertEquals ($ column17 ->getName (), 'column17 ' );
337
+ $ this ->assertEquals ($ column17 ->getType (), Column::TYPE_LONGBLOB );
338
+ $ this ->assertTrue ($ column17 ->isNotNull ());
339
+
340
+ //Boolean column
341
+ $ column18 = $ columns ['column18 ' ];
342
+ $ this ->assertEquals ($ column18 ->getName (), 'column18 ' );
343
+ $ this ->assertEquals ($ column18 ->getType (), Column::TYPE_BOOLEAN );
344
+
345
+ //Double column
346
+ $ column19 = $ columns ['column19 ' ];
347
+ $ this ->assertEquals ($ column19 ->getName (), 'column19 ' );
348
+ $ this ->assertEquals ($ column19 ->getType (), Column::TYPE_DOUBLE );
349
+ $ this ->assertFalse ($ column19 ->isUnsigned ());
350
+
351
+ //Unsigned double column
352
+ $ column20 = $ columns ['column20 ' ];
353
+ $ this ->assertEquals ($ column20 ->getName (), 'column20 ' );
354
+ $ this ->assertEquals ($ column20 ->getType (), Column::TYPE_DOUBLE );
355
+ $ this ->assertTrue ($ column20 ->isUnsigned ());
289
356
}
290
357
291
358
public function testIndexes ()
@@ -835,6 +902,13 @@ public function testSQLiteDialect()
835
902
$ this ->assertEquals ($ dialect ->getColumnDefinition ($ columns ['column9 ' ]), 'VARCHAR(10) ' );
836
903
$ this ->assertEquals ($ dialect ->getColumnDefinition ($ columns ['column10 ' ]), 'INTEGER ' );
837
904
$ this ->assertEquals ($ dialect ->getColumnDefinition ($ columns ['column13 ' ]), 'TIMESTAMP ' );
905
+ $ this ->assertEquals ($ dialect ->getColumnDefinition ($ columns ['column14 ' ]), 'TINYBLOB ' );
906
+ $ this ->assertEquals ($ dialect ->getColumnDefinition ($ columns ['column15 ' ]), 'MEDIUMBLOB ' );
907
+ $ this ->assertEquals ($ dialect ->getColumnDefinition ($ columns ['column16 ' ]), 'BLOB ' );
908
+ $ this ->assertEquals ($ dialect ->getColumnDefinition ($ columns ['column17 ' ]), 'LONGBLOB ' );
909
+ $ this ->assertEquals ($ dialect ->getColumnDefinition ($ columns ['column18 ' ]), 'TINYINT ' );
910
+ $ this ->assertEquals ($ dialect ->getColumnDefinition ($ columns ['column19 ' ]), 'DOUBLE ' );
911
+ $ this ->assertEquals ($ dialect ->getColumnDefinition ($ columns ['column20 ' ]), 'DOUBLE UNSIGNED ' );
838
912
839
913
//Add Columns
840
914
$ this ->assertEquals ($ dialect ->addColumn ('table ' , null , $ columns ['column1 ' ]), 'ALTER TABLE "table" ADD COLUMN "column1" VARCHAR(10) ' );
@@ -859,6 +933,20 @@ public function testSQLiteDialect()
859
933
$ this ->assertEquals ($ dialect ->addColumn ('table ' , 'schema ' , $ columns ['column10 ' ]), 'ALTER TABLE "schema"."table" ADD COLUMN "column10" INTEGER DEFAULT "10" ' );
860
934
$ this ->assertEquals ($ dialect ->addColumn ('table ' , null , $ columns ['column13 ' ]), 'ALTER TABLE "table" ADD COLUMN "column13" TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL ' );
861
935
$ this ->assertEquals ($ dialect ->addColumn ('table ' , 'schema ' , $ columns ['column13 ' ]), 'ALTER TABLE "schema"."table" ADD COLUMN "column13" TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL ' );
936
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , null , $ columns ['column14 ' ]), 'ALTER TABLE "table" ADD COLUMN "column14" TINYBLOB NOT NULL ' );
937
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , 'schema ' , $ columns ['column14 ' ]), 'ALTER TABLE "schema"."table" ADD COLUMN "column14" TINYBLOB NOT NULL ' );
938
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , null , $ columns ['column15 ' ]), 'ALTER TABLE "table" ADD COLUMN "column15" MEDIUMBLOB NOT NULL ' );
939
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , 'schema ' , $ columns ['column15 ' ]), 'ALTER TABLE "schema"."table" ADD COLUMN "column15" MEDIUMBLOB NOT NULL ' );
940
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , null , $ columns ['column16 ' ]), 'ALTER TABLE "table" ADD COLUMN "column16" BLOB NOT NULL ' );
941
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , 'schema ' , $ columns ['column16 ' ]), 'ALTER TABLE "schema"."table" ADD COLUMN "column16" BLOB NOT NULL ' );
942
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , null , $ columns ['column17 ' ]), 'ALTER TABLE "table" ADD COLUMN "column17" LONGBLOB NOT NULL ' );
943
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , 'schema ' , $ columns ['column17 ' ]), 'ALTER TABLE "schema"."table" ADD COLUMN "column17" LONGBLOB NOT NULL ' );
944
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , null , $ columns ['column18 ' ]), 'ALTER TABLE "table" ADD COLUMN "column18" TINYINT ' );
945
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , 'schema ' , $ columns ['column18 ' ]), 'ALTER TABLE "schema"."table" ADD COLUMN "column18" TINYINT ' );
946
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , null , $ columns ['column19 ' ]), 'ALTER TABLE "table" ADD COLUMN "column19" DOUBLE ' );
947
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , 'schema ' , $ columns ['column19 ' ]), 'ALTER TABLE "schema"."table" ADD COLUMN "column19" DOUBLE ' );
948
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , null , $ columns ['column20 ' ]), 'ALTER TABLE "table" ADD COLUMN "column20" DOUBLE UNSIGNED ' );
949
+ $ this ->assertEquals ($ dialect ->addColumn ('table ' , 'schema ' , $ columns ['column20 ' ]), 'ALTER TABLE "schema"."table" ADD COLUMN "column20" DOUBLE UNSIGNED ' );
862
950
863
951
//Modify Columns
864
952
try {
@@ -1017,6 +1105,43 @@ public function testSQLiteDialect()
1017
1105
$ expected .= ") " ;
1018
1106
$ this ->assertEquals ($ dialect ->createTable ('table ' , null , $ definition ), $ expected );
1019
1107
1108
+ $ definition = array (
1109
+ 'columns ' => array (
1110
+ $ columns ['column14 ' ],
1111
+ $ columns ['column16 ' ],
1112
+ )
1113
+ );
1114
+
1115
+ $ expected = "CREATE TABLE \"table \" ( \n" ;
1116
+ $ expected .= " `column14` TINYBLOB NOT NULL, \n" ;
1117
+ $ expected .= " `column16` BLOB NOT NULL \n" ;
1118
+ $ expected .= ") " ;
1119
+ $ this ->assertEquals ($ dialect ->createTable ('table ' , null , $ definition ), $ expected );
1120
+
1121
+ $ definition = array (
1122
+ 'columns ' => array (
1123
+ $ columns ['column18 ' ],
1124
+ )
1125
+ );
1126
+
1127
+ $ expected = "CREATE TABLE \"table \" ( \n" ;
1128
+ $ expected .= " `column18` TINYINT \n" ;
1129
+ $ expected .= ") " ;
1130
+ $ this ->assertEquals ($ dialect ->createTable ('table ' , null , $ definition ), $ expected );
1131
+
1132
+ $ definition = array (
1133
+ 'columns ' => array (
1134
+ $ columns ['column19 ' ],
1135
+ $ columns ['column20 ' ],
1136
+ )
1137
+ );
1138
+
1139
+ $ expected = "CREATE TABLE \"table \" ( \n" ;
1140
+ $ expected .= " `column19` DOUBLE, \n" ;
1141
+ $ expected .= " `column20` DOUBLE UNSIGNED \n" ;
1142
+ $ expected .= ") " ;
1143
+ $ this ->assertEquals ($ dialect ->createTable ('table ' , null , $ definition ), $ expected );
1144
+
1020
1145
// issue 11359
1021
1146
$ this ->assertEquals ($ dialect ->describeColumns ('table ' , 'database.name.with.dots ' ), "PRAGMA table_info('table') " );
1022
1147
}
@@ -1061,19 +1186,19 @@ public function testViews()
1061
1186
1062
1187
$ this ->assertEquals ($ dialect ->listViews (), 'SELECT viewname AS view_name FROM pg_views WHERE schemaname = \'public \' ORDER BY view_name ' );
1063
1188
1064
- // SQLite
1065
- $ dialect = new \Phalcon \Db \Dialect \Sqlite ();
1189
+ // SQLite
1190
+ $ dialect = new \Phalcon \Db \Dialect \Sqlite ();
1066
1191
1067
- //Create View
1068
- $ this ->assertEquals ($ dialect ->createView ('test_view ' , $ definition , null ), 'CREATE VIEW "test_view" AS SELECT 1 ' );
1069
- $ this ->assertEquals ($ dialect ->createView ('test_view ' , $ definition , 'schema ' ), 'CREATE VIEW "schema"."test_view" AS SELECT 1 ' );
1192
+ //Create View
1193
+ $ this ->assertEquals ($ dialect ->createView ('test_view ' , $ definition , null ), 'CREATE VIEW "test_view" AS SELECT 1 ' );
1194
+ $ this ->assertEquals ($ dialect ->createView ('test_view ' , $ definition , 'schema ' ), 'CREATE VIEW "schema"."test_view" AS SELECT 1 ' );
1070
1195
1071
- //Drop View
1072
- $ this ->assertEquals ($ dialect ->dropView ('test_view ' , null , false ), 'DROP VIEW "test_view" ' );
1073
- $ this ->assertEquals ($ dialect ->dropView ('test_view ' , null , true ), 'DROP VIEW IF EXISTS "test_view" ' );
1074
- $ this ->assertEquals ($ dialect ->dropView ('test_view ' , 'schema ' , false ), 'DROP VIEW "schema"."test_view" ' );
1075
- $ this ->assertEquals ($ dialect ->dropView ('test_view ' , 'schema ' , true ), 'DROP VIEW IF EXISTS "schema"."test_view" ' );
1196
+ //Drop View
1197
+ $ this ->assertEquals ($ dialect ->dropView ('test_view ' , null , false ), 'DROP VIEW "test_view" ' );
1198
+ $ this ->assertEquals ($ dialect ->dropView ('test_view ' , null , true ), 'DROP VIEW IF EXISTS "test_view" ' );
1199
+ $ this ->assertEquals ($ dialect ->dropView ('test_view ' , 'schema ' , false ), 'DROP VIEW "schema"."test_view" ' );
1200
+ $ this ->assertEquals ($ dialect ->dropView ('test_view ' , 'schema ' , true ), 'DROP VIEW IF EXISTS "schema"."test_view" ' );
1076
1201
1077
- $ this ->assertEquals ($ dialect ->listViews (), "SELECT tbl_name FROM sqlite_master WHERE type = 'view' ORDER BY tbl_name " );
1202
+ $ this ->assertEquals ($ dialect ->listViews (), "SELECT tbl_name FROM sqlite_master WHERE type = 'view' ORDER BY tbl_name " );
1078
1203
}
1079
1204
}
0 commit comments