@@ -5861,14 +5861,24 @@ public function testDropIndex(): void {
58615861 }
58625862
58635863 public function testColumnInfo (): void {
5864- $ this ->assertQuery ( 'CREATE TABLE t (id INT, name TEXT, score DOUBLE, data BLOB) ' );
5864+ $ this ->assertQuery ( '
5865+ CREATE TABLE t (
5866+ id INT,
5867+ name TEXT,
5868+ score DOUBLE,
5869+ data BLOB,
5870+ PRIMARY KEY (id),
5871+ UNIQUE KEY (name)
5872+ ) '
5873+ );
58655874 $ this ->assertQuery ( 'SELECT * FROM t ' );
58665875
58675876 $ this ->assertEquals ( 4 , $ this ->engine ->get_last_column_count () );
58685877
58695878 $ column_info = $ this ->engine ->get_last_column_meta ();
58705879 $ this ->assertCount ( 4 , $ column_info );
58715880
5881+ // INT
58725882 $ this ->assertSame (
58735883 array (
58745884 'native_type ' => 'LONG ' ,
@@ -5878,7 +5888,7 @@ public function testColumnInfo(): void {
58785888 'name ' => 'id ' ,
58795889 'len ' => 11 ,
58805890 'precision ' => 0 ,
5881- 'sqlite:decl_type ' => 'INTEGER ' ,
5891+ 'sqlite:decl_type ' => 'INT ' ,
58825892 ),
58835893 $ column_info [0 ]
58845894 );
@@ -5925,4 +5935,337 @@ public function testColumnInfo(): void {
59255935 $ column_info [3 ]
59265936 );
59275937 }
5938+
5939+ public function testColumnInfoForIntegerDataTypes (): void {
5940+ $ this ->assertQuery ( '
5941+ CREATE TABLE t (
5942+ col_bit BIT,
5943+ col_bool BOOL,
5944+ col_tinyint TINYINT,
5945+ col_smallint SMALLINT,
5946+ col_mediumint MEDIUMINT,
5947+ col_int INT,
5948+ col_bigint BIGINT
5949+ ) '
5950+ );
5951+
5952+ $ this ->assertQuery ( 'SELECT * FROM t ' );
5953+ $ this ->assertEquals ( 7 , $ this ->engine ->get_last_column_count () );
5954+
5955+ $ column_info = $ this ->engine ->get_last_column_meta ();
5956+
5957+ // INT
5958+ $ this ->assertSame (
5959+ array (
5960+ array (
5961+ 'native_type ' => 'BIT ' ,
5962+ 'pdo_type ' => PDO ::PARAM_INT ,
5963+ 'flags ' => array (),
5964+ 'table ' => 't ' ,
5965+ 'name ' => 'col_bit ' ,
5966+ 'len ' => 1 ,
5967+ 'precision ' => 0 ,
5968+ 'sqlite:decl_type ' => 'INTEGER ' ,
5969+ ),
5970+ array (
5971+ 'native_type ' => 'TINY ' ,
5972+ 'pdo_type ' => PDO ::PARAM_INT ,
5973+ 'flags ' => array (),
5974+ 'table ' => 't ' ,
5975+ 'name ' => 'col_bool ' ,
5976+ 'len ' => 1 ,
5977+ 'precision ' => 0 ,
5978+ 'sqlite:decl_type ' => 'INTEGER ' ,
5979+ ),
5980+ array (
5981+ 'native_type ' => 'TINY ' ,
5982+ 'pdo_type ' => PDO ::PARAM_INT ,
5983+ 'flags ' => array (),
5984+ 'table ' => 't ' ,
5985+ 'name ' => 'col_tinyint ' ,
5986+ 'len ' => 4 ,
5987+ 'precision ' => 0 ,
5988+ 'sqlite:decl_type ' => 'INTEGER ' ,
5989+ ),
5990+ array (
5991+ 'native_type ' => 'SHORT ' ,
5992+ 'pdo_type ' => PDO ::PARAM_INT ,
5993+ 'flags ' => array (),
5994+ 'table ' => 't ' ,
5995+ 'name ' => 'col_smallint ' ,
5996+ 'len ' => 6 ,
5997+ 'precision ' => 0 ,
5998+ 'sqlite:decl_type ' => 'INTEGER ' ,
5999+ ),
6000+ array (
6001+ 'native_type ' => 'INT24 ' ,
6002+ 'pdo_type ' => PDO ::PARAM_INT ,
6003+ 'flags ' => array (),
6004+ 'table ' => 't ' ,
6005+ 'name ' => 'col_mediumint ' ,
6006+ 'len ' => 9 ,
6007+ 'precision ' => 0 ,
6008+ 'sqlite:decl_type ' => 'INTEGER ' ,
6009+ ),
6010+ array (
6011+ 'native_type ' => 'LONG ' ,
6012+ 'pdo_type ' => PDO ::PARAM_INT ,
6013+ 'flags ' => array (),
6014+ 'table ' => 't ' ,
6015+ 'name ' => 'col_int ' ,
6016+ 'len ' => 11 ,
6017+ 'precision ' => 0 ,
6018+ 'sqlite:decl_type ' => 'INTEGER ' ,
6019+ ),
6020+ array (
6021+ 'native_type ' => 'LONGLONG ' ,
6022+ 'pdo_type ' => PDO ::PARAM_INT ,
6023+ 'flags ' => array (),
6024+ 'table ' => 't ' ,
6025+ 'name ' => 'col_bigint ' ,
6026+ 'len ' => 20 ,
6027+ 'precision ' => 0 ,
6028+ 'sqlite:decl_type ' => 'INTEGER ' ,
6029+ ),
6030+ ),
6031+ $ column_info
6032+ );
6033+ }
6034+
6035+ public function testColumnInfoForFloatingPointDataTypes (): void {
6036+ $ this ->assertQuery ( '
6037+ CREATE TABLE t (
6038+ col_float FLOAT,
6039+ col_double DOUBLE,
6040+ col_real REAL,
6041+ col_decimal DECIMAL(10,2),
6042+ col_dec DEC(10,2),
6043+ col_fixed FIXED(10,2),
6044+ col_numeric NUMERIC(10,2)
6045+ ) '
6046+ );
6047+
6048+ $ this ->assertQuery ( 'SELECT * FROM t ' );
6049+ $ this ->assertEquals ( 7 , $ this ->engine ->get_last_column_count () );
6050+
6051+ $ column_info = $ this ->engine ->get_last_column_meta ();
6052+
6053+ // INT
6054+ $ this ->assertSame (
6055+ array (
6056+ array (
6057+ 'native_type ' => 'REAL ' ,
6058+ 'pdo_type ' => PDO ::PARAM_STR ,
6059+ 'flags ' => array (),
6060+ 'table ' => 't ' ,
6061+ 'name ' => 'col_float ' ,
6062+ 'len ' => 12 ,
6063+ 'precision ' => 31 ,
6064+ 'sqlite:decl_type ' => 'REAL ' ,
6065+ ),
6066+ array (
6067+ 'native_type ' => 'DOUBLE ' ,
6068+ 'pdo_type ' => PDO ::PARAM_STR ,
6069+ 'flags ' => array (),
6070+ 'table ' => 't ' ,
6071+ 'name ' => 'col_double ' ,
6072+ 'len ' => 22 ,
6073+ 'precision ' => 31 ,
6074+ 'sqlite:decl_type ' => 'REAL ' ,
6075+ ),
6076+ array (
6077+ 'native_type ' => 'DOUBLE ' ,
6078+ 'pdo_type ' => PDO ::PARAM_STR ,
6079+ 'flags ' => array (),
6080+ 'table ' => 't ' ,
6081+ 'name ' => 'col_real ' ,
6082+ 'len ' => 22 ,
6083+ 'precision ' => 31 ,
6084+ 'sqlite:decl_type ' => 'REAL ' ,
6085+ ),
6086+ array (
6087+ 'native_type ' => 'NEWDECIMAL ' ,
6088+ 'pdo_type ' => PDO ::PARAM_STR ,
6089+ 'flags ' => array (),
6090+ 'table ' => 't ' ,
6091+ 'name ' => 'col_decimal ' ,
6092+ 'len ' => 12 ,
6093+ 'precision ' => 2 ,
6094+ 'sqlite:decl_type ' => 'REAL ' ,
6095+ ),
6096+ array (
6097+ 'native_type ' => 'NEWDECIMAL ' ,
6098+ 'pdo_type ' => PDO ::PARAM_STR ,
6099+ 'flags ' => array (),
6100+ 'table ' => 't ' ,
6101+ 'name ' => 'col_dec ' ,
6102+ 'len ' => 12 ,
6103+ 'precision ' => 2 ,
6104+ 'sqlite:decl_type ' => 'REAL ' ,
6105+ ),
6106+ array (
6107+ 'native_type ' => 'NEWDECIMAL ' ,
6108+ 'pdo_type ' => PDO ::PARAM_STR ,
6109+ 'flags ' => array (),
6110+ 'table ' => 't ' ,
6111+ 'name ' => 'col_fixed ' ,
6112+ 'len ' => 12 ,
6113+ 'precision ' => 2 ,
6114+ 'sqlite:decl_type ' => 'REAL ' ,
6115+ ),
6116+ array (
6117+ 'native_type ' => 'NEWDECIMAL ' ,
6118+ 'pdo_type ' => PDO ::PARAM_STR ,
6119+ 'flags ' => array (),
6120+ 'table ' => 't ' ,
6121+ 'name ' => 'col_numeric ' ,
6122+ 'len ' => 12 ,
6123+ 'precision ' => 2 ,
6124+ 'sqlite:decl_type ' => 'REAL ' ,
6125+ ),
6126+ ),
6127+ $ column_info
6128+ );
6129+ }
6130+
6131+
6132+ public function testColumnInfoForStringDataTypes (): void {
6133+ $ this ->assertQuery (
6134+ "CREATE TABLE t (
6135+ col_char CHAR(10),
6136+ col_varchar VARCHAR(10),
6137+ col_nchar NCHAR(10),
6138+ col_nvarchar NVARCHAR(10),
6139+ col_tinytext TINYTEXT,
6140+ col_text TEXT,
6141+ col_mediumtext MEDIUMTEXT,
6142+ col_longtext LONGTEXT,
6143+ col_enum ENUM('a', 'b', 'c'),
6144+ col_set SET('a', 'b', 'c'),
6145+ col_json JSON
6146+ ) "
6147+ );
6148+
6149+ $ this ->assertQuery ( 'SELECT * FROM t ' );
6150+ $ this ->assertEquals ( 11 , $ this ->engine ->get_last_column_count () );
6151+
6152+ $ column_info = $ this ->engine ->get_last_column_meta ();
6153+
6154+ // INT
6155+ $ this ->assertSame (
6156+ array (
6157+ array (
6158+ 'native_type ' => 'STRING ' ,
6159+ 'pdo_type ' => PDO ::PARAM_STR ,
6160+ 'flags ' => array (),
6161+ 'table ' => 't ' ,
6162+ 'name ' => 'col_char ' ,
6163+ 'len ' => 40 ,
6164+ 'precision ' => 0 ,
6165+ 'sqlite:decl_type ' => 'TEXT ' ,
6166+ ),
6167+ array (
6168+ 'native_type ' => 'VAR_STRING ' ,
6169+ 'pdo_type ' => PDO ::PARAM_STR ,
6170+ 'flags ' => array (),
6171+ 'table ' => 't ' ,
6172+ 'name ' => 'col_varchar ' ,
6173+ 'len ' => 40 ,
6174+ 'precision ' => 0 ,
6175+ 'sqlite:decl_type ' => 'TEXT ' ,
6176+ ),
6177+ array (
6178+ 'native_type ' => 'STRING ' ,
6179+ 'pdo_type ' => PDO ::PARAM_STR ,
6180+ 'flags ' => array (),
6181+ 'table ' => 't ' ,
6182+ 'name ' => 'col_nchar ' ,
6183+ 'len ' => 40 ,
6184+ 'precision ' => 0 ,
6185+ 'sqlite:decl_type ' => 'TEXT ' ,
6186+ ),
6187+ array (
6188+ 'native_type ' => 'VAR_STRING ' ,
6189+ 'pdo_type ' => PDO ::PARAM_STR ,
6190+ 'flags ' => array (),
6191+ 'table ' => 't ' ,
6192+ 'name ' => 'col_nvarchar ' ,
6193+ 'len ' => 40 ,
6194+ 'precision ' => 0 ,
6195+ 'sqlite:decl_type ' => 'TEXT ' ,
6196+ ),
6197+ array (
6198+ 'native_type ' => 'BLOB ' ,
6199+ 'pdo_type ' => PDO ::PARAM_STR ,
6200+ 'flags ' => array ( 'blob ' ),
6201+ 'table ' => 't ' ,
6202+ 'name ' => 'col_tinytext ' ,
6203+ 'len ' => 1020 ,
6204+ 'precision ' => 0 ,
6205+ 'sqlite:decl_type ' => 'TEXT ' ,
6206+ ),
6207+ array (
6208+ 'native_type ' => 'BLOB ' ,
6209+ 'pdo_type ' => PDO ::PARAM_STR ,
6210+ 'flags ' => array ( 'blob ' ),
6211+ 'table ' => 't ' ,
6212+ 'name ' => 'col_text ' ,
6213+ 'len ' => 262140 ,
6214+ 'precision ' => 0 ,
6215+ 'sqlite:decl_type ' => 'TEXT ' ,
6216+ ),
6217+ array (
6218+ 'native_type ' => 'BLOB ' ,
6219+ 'pdo_type ' => PDO ::PARAM_STR ,
6220+ 'flags ' => array ( 'blob ' ),
6221+ 'table ' => 't ' ,
6222+ 'name ' => 'col_mediumtext ' ,
6223+ 'len ' => 67108860 ,
6224+ 'precision ' => 0 ,
6225+ 'sqlite:decl_type ' => 'TEXT ' ,
6226+ ),
6227+ array (
6228+ 'native_type ' => 'BLOB ' ,
6229+ 'pdo_type ' => PDO ::PARAM_STR ,
6230+ 'flags ' => array ( 'blob ' ),
6231+ 'table ' => 't ' ,
6232+ 'name ' => 'col_longtext ' ,
6233+ 'len ' => 4294967295 ,
6234+ 'precision ' => 0 ,
6235+ 'sqlite:decl_type ' => 'TEXT ' ,
6236+ ),
6237+ array (
6238+ 'native_type ' => 'STRING ' ,
6239+ 'pdo_type ' => PDO ::PARAM_STR ,
6240+ 'flags ' => array (),
6241+ 'table ' => 't ' ,
6242+ 'name ' => 'col_enum ' ,
6243+ 'len ' => 4 ,
6244+ 'precision ' => 0 ,
6245+ 'sqlite:decl_type ' => 'TEXT ' ,
6246+ ),
6247+ array (
6248+ 'native_type ' => 'STRING ' ,
6249+ 'pdo_type ' => PDO ::PARAM_STR ,
6250+ 'flags ' => array (),
6251+ 'table ' => 't ' ,
6252+ 'name ' => 'col_set ' ,
6253+ 'len ' => 20 ,
6254+ 'precision ' => 0 ,
6255+ 'sqlite:decl_type ' => 'TEXT ' ,
6256+ ),
6257+ array (
6258+ 'native_type ' => 'BLOB ' ,
6259+ 'pdo_type ' => PDO ::PARAM_STR ,
6260+ 'flags ' => array ( 'blob ' ),
6261+ 'table ' => 't ' ,
6262+ 'name ' => 'col_json ' ,
6263+ 'len ' => 4294967295 ,
6264+ 'precision ' => 0 ,
6265+ 'sqlite:decl_type ' => 'TEXT ' ,
6266+ ),
6267+ ),
6268+ $ column_info
6269+ );
6270+ }
59286271}
0 commit comments