-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add the Result::getColumnName method #6428
Conversation
da1b092
to
9cb8d6c
Compare
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.
Thank you. I think the portability middleware needs a special implementation of that new method.
fac07c7
to
2d8ee65
Compare
@derrabus indeed, the Portability result needed to handle the case conversion when using its case conversion feature. I added support for it. And |
This method allows introspecting the shape of results by knowing the name of columns.
* 4.1.x: Add the Result::getColumnName method (#6428)
Thank you! I've opened #6452 as a follow-up. |
Thank you @stof. This is a great addition to the API which should unblock some improvements to the result caching. Specifically, the following issues now can be addressed:
Note that the just implemented In order to address these issues, instead of accepting |
| Q | A |------------- | ----------- | Type | bug #### Summary Prior to #6428, there were two problems with caching results by design: 1. If the result contains no rows, its cached version won't return the number of columns. 2. If the result contains columns with the same name (e.g. `SELECT a.id, b.id FROM a, b`), they will clash even if fetched in the numeric mode. See #6428 (comment) for reference. The solution is: 1. Handle column names and rows in the cache result separately. This way, the column names are available even if there is no data. 2. Store rows as tuples (lists) instead of maps (associative arrays). This way, even if the result contains multiple columns with the same name, they can be correctly fetched with `fetchNumeric()`. **Additional notes**: 1. The changes in `TestUtil::generateResultSetQuery()` were necessary for the integration testing of the changes in `ArrayResult`. However, later, I realized that the modified code is database-agnostic, so running it in integration with each database platform would effectively test the same code path and would be redundant. I replaced the integration tests with the unit ones but left the change in `TestUtil` as it makes the calling code cleaner. 2. `ArrayStatementTest` was renamed to `ArrayResultTest`, which Git doesn't seem to recognize due to the amount of changes. **TODO**: - [x] Decide on the release version. This pull request changes the cache format, so the users will have to clear their cache during upgrade. I wouldn't consider it a BC break. We could also migrate the cache at runtime, but given that this cache can be cleared, I don't think it is worth the effort. - [x] Add upgrade documentation.
Summary
This method allows introspecting the shape of results by knowing the name of columns (combined with the
columnCount
which already exists).