|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78596 getColumnMeta() doesn't return native_type for JSON
Submitted: 2019-09-25 14:23 UTC Modified: 2019-09-25 15:48 UTC
From: phpbug at discosucks dot it Assigned:
Status: Analyzed Package: PDO MySQL
PHP Version: 7.2.22 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: phpbug at discosucks dot it
New email:
PHP Version: OS:


 [2019-09-25 14:23 UTC] phpbug at discosucks dot it
PDOStatement::getColumnMeta() doesn't return native_type for JSON type columns (i suppose it should be "string"). 

Test script:
$DB=new PDO('mysql:host=localhost;dbname=test','user','pass');
$DB->exec('CREATE TABLE `test` (`a` JSON)');
$DB->exec("INSERT INTO `test` VALUES('[]')");
$statement=$DB->query('SELECT `a` FROM `test`');


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-25 15:48 UTC]
-Status: Open +Status: Analyzed
 [2019-09-25 15:48 UTC]
PHP is testing for the field type (reported by MySQL) using a variety of #defined FIELD_TYPE_* constants: (Ctrl+F)
Note there is no constant for JSON. No constant means PHP can't identify the type.

However those FIELD_TYPEs are aliases for MYSQL_TYPE_* constants:
In that list there is a JSON type; it's documented as "used for replication only" but it seems like other projects are using it.

Perhaps pdo_mysql should switch to using the MYSQL_TYPEs?
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Feb 06 00:05:48 2023 UTC