-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 indexed properties to RowDataPacket #2164
Comments
I forgot to mention, the suggested property definition is deliberately non-enumerable so that looping over the properties doesn't cause values to be returned twice. |
there is #1637 proposed which does this via |
It's easy to be added, it was suggested many times and there is pull requests as well. |
Those alternatives are all rather more complex than my suggestion (and address a different concern — returning an actual array). There is no reason to have this behind an options flag, as SQL field names (and AS … aliases) cannot begin with a digit, so there could not be any clashes with existing code. I think adding it is cheap, unproblematic, and beneficial. |
That seems inaccurate. From the docs: "Identifiers may begin with a digit but unless quoted may not consist solely of digits." |
I have another case for index-based access to RowDataPacket: Result set with duplicates in column names. For example, I want to parse result set of a query:
A result of the query should be 3 columns, but RowDataPacket has only one value. |
I would like to be able to access fields by their index in the query, without having to modify the query to include an 'AS' field alias. For example, given:
I want to be able to refer to the results like this:
Instead of:
You can imagine how these field names can get very long and unwieldy.
The solution is to add one line to the end of the
for
loop in theparse
function ofRowDataPacket
(after line 49 in the current code):The text was updated successfully, but these errors were encountered: