-
Notifications
You must be signed in to change notification settings - Fork 49
Implement column metadata #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fec56d7
to
163fc67
Compare
d877817
to
6b05356
Compare
@adamziel I've got this to a point where I think we can merge it, including plenty of tests. It would be useful to advance the Adminer, phpMyAdmin, and other tool support. I can also create a follow-up ticket for what can be further improved (MySQLi flags, etc.). Maybe also all the |
* This is used to compute the column metadata from the information schema. | ||
*/ | ||
const COLUMN_INFO_MYSQL_TO_NATIVE_TYPES_MAP = array( | ||
// Numeric data types: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we sort it by mysqli type within each datatype group (int, string etc)? It seems like we'll be looking up entries in this mapping by that number a little bit. Alternatively, we could create a bunch of named constants and reference them here, e.g. self::MYSQLI_BIT etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamziel As we already have multiple maps in the form of mysql-type-to-something
, I was thinking about consolidating them into something like this:

It would be all in one place then, and likely more readable. Usage:
$sqlite_type = self::MYSQL_TYPE_MAP[$type][self::KEY_SQLITE_TYPE];
$implicit_default = self::MYSQL_TYPE_MAP[$type][self::KEY_MYSQL_IMPLICIT_DEFAULT];
...
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ticket: #259
* that have no records in the information schema (i.e., expressions). | ||
*/ | ||
const COLUMN_INFO_SQLITE_TO_NATIVE_TYPES_MAP = array( | ||
'NULL' => array( 'NULL', 6, 0, 0 ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto for those numbers
Nice! Yeah let's get it in. The limitations would be also nice to document in a comment within the code as that's where we'll be looking for this information. |
This PR implements emulation of
PDOStatement::getColumnMeta()
values and adds support for$wpdb::get_col_info()
.This feature is necessary for support of MySQL tools like Adminer, phpMyAdmin, and others, as well as for any plugins that may rely on this functionality.
Resolves #190.