Req #81550 [Opn]: getColumnMeta should also return org_table and org_column
| From: | daniel dot garcia dot fidalgo at gmail dot com | Date: | Tue, 26 Oct 2021 17:44:09 +0000 |
| Subject: | Req #81550 [Opn]: getColumnMeta should also return org_table and org_column | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237389@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81550&edit=1
ID: 81550
User updated by: daniel dot garcia dot fidalgo at gmail dot com
Reported by: daniel dot garcia dot fidalgo at gmail dot com
Summary: getColumnMeta should also return org_table and
org_column
Status: Open
Type: Feature/Change Request
Package: PDO MySQL
Operating System: CentOS 7
PHP Version: next minor
Block user comment: N
Private report: N
New Comment:
How come the DB know about the aliases when they do not exist up until the programmer sets the query
and runs it.
That is user set information and thus aliases are not in the DB schema and can't be known about
on advance for the same reason that I can't predict the future.
You may be talking about the database engine or database server, who knows about them only after
having processed the query and never before.
Previous Comments:
------------------------------------------------------------------------
[2021-10-25 17:22:31] requinix@php.net
> The database knows nothing about the aliases,
The database server absolutely does know about the aliases. Look at the link I gave earlier.
------------------------------------------------------------------------
[2021-10-25 16:36:44] daniel dot garcia dot fidalgo at gmail dot com
From the getColumnMeta() manual:
name The name of this column as returned by the database.
table The name of this column's table as returned by the database.
The alias is indeed the name of the column returned by the SQL statement, not the database. The
database knows nothing about the aliases, they are higher level information set by the user in the
very same query.
The alias is already accessible via the query returned data, what is the point in returning the same
via a function that promises meta-information?.
------------------------------------------------------------------------
[2021-10-25 16:31:48] cmb@php.net
> Looking at this from the feature request view, [â¦]
While this ticket is categorized as feature request, the OP looks
more like a bug report. Anyhow, let's treat it as feature
request.
> [â¦] what about adding the original table (org_table) and column
> names (org_name) to the array?
I'd be fine with this, but this should probably be discussed on
the internals mailing list and might need an RFC[1], because it is
unclear what exactly should be returned by getColumnMeta().
[1] <https://wiki.php.net/rfc/howto>
------------------------------------------------------------------------
[2021-10-25 15:31:10] requinix@php.net
See MYSQL_FIELD in https://dev.mysql.com/doc/c-api/8.0/en/c-api-data-structures.html
Looking at this from the feature request view, what about adding the original table (org_table) and
column names (org_name) to the array?
Not sure how it applies to other drivers, like pdo_pgsql/PostgreSQL seems to do identifiers instead
of names, but the original names could be one more of PDO's "...if supported by the
driver" features.
At the least there does seem to be some precedent for driver-specific values in the returned array:
pdo_pgsql adds a "pgsql:table_oid" to the array. So pdo_mysql could potentially do
"mysql:org_name/org_table" if it had to.
------------------------------------------------------------------------
[2021-10-25 13:54:49] cmb@php.net
> The aliased names as set in the query are returned.
Right. And the documentation states[1]:
| The name of this column as returned by the database.
So where's the problem?
[1] <https://www.php.net/manual/en/pdostatement.getcolumnmeta.php#refsect1-pdostatement.getcolumnmeta-returnvalues>
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=81550
--
Edit this bug report at https://bugs.php.net/bug.php?id=81550&edit=1