Skip to content
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

Added an option to return resultsets as an array type. #1637

Closed
wants to merge 3 commits into from
Closed

Added an option to return resultsets as an array type. #1637

wants to merge 3 commits into from

Conversation

ifsnow
Copy link
Contributor

@ifsnow ifsnow commented Feb 1, 2017

This is for #770

You can use the rowsAsArray option(global, per query) to get the resultsets as an array type.

I hope this helps.

@Stavanger75
Copy link

@ifsnow any progress on the merger?

@ifsnow
Copy link
Contributor Author

ifsnow commented Mar 4, 2017

@Stavanger75 I'm afraid I don't know much about the merging plan.

Copy link
Member

@dougwilson dougwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, meant to review earlier

@@ -13,6 +13,22 @@ Object.defineProperty(RowDataPacket.prototype, 'parse', {
value : parse
});

Object.defineProperty(RowDataPacket.prototype, 'isArray', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be at least underscore-prefixed? Whatever we add here will shadow any column someone may be trying to query, so need to be careful adding anything new.

@@ -410,6 +411,14 @@ Parser.prototype.packetLength = function packetLength() {
return this._packetHeader.length + this._longPacketBuffers.size;
};

Parser.prototype.setArrayRowMode = function(rowsAsArray) {
this._isArrayRowMode = typeof rowsAsArray === 'undefined' ? this._globalRowsAsArray : rowsAsArray;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you hoist this to prevent the hidden class change this is triggering?

assert.ifError(err);
assert.deepEqual(rows, [{1: 1}]);
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that verifies the connection is reset back to the mode from the connection config here?

@dougwilson dougwilson self-assigned this Mar 4, 2017
@ifsnow
Copy link
Contributor Author

ifsnow commented Mar 4, 2017

@dougwilson added some work to apply your feedback. Please let me know if you need more.

@Stavanger75
Copy link

@ifsnow and @dougwilson. Thanks for working on this one :-)

@Stavanger75
Copy link

@dougwilson have you checked @ifsnow last changes ?

@ifsnow it looks like "eslint" test is failing on missing spaces in the file "test-query-rows-as-array.js"

mysql@2.13.0 lint /home/travis/build/mysqljs/mysql
eslint .
/home/travis/build/mysqljs/mysql/test/integration/connection/test-query-rows-as-array.js
18:5 error Missing space after key 'sql' key-spacing
19:5 error Missing space after key 'rowsAsArray' key-spacing

@ifsnow
Copy link
Contributor Author

ifsnow commented Mar 18, 2017

@Stavanger75 Yes, I'm done with this. eslint errors were fixed. Thank you for letting me know.

@Stavanger75
Copy link

Stavanger75 commented Mar 18, 2017

Great !!!
Thanks so mutch for the work on this @ifsnow :-)

@Stavanger75
Copy link

Hi @dougwilson,

have you had the time to look at the changes @ifsnow made ? It would be so great if this could be merged into the project.

Thanks

@dougwilson dougwilson force-pushed the master branch 2 times, most recently from 638d79d to 88bade0 Compare June 29, 2017 18:13
@sidorares sidorares marked this as a duplicate of #1784 Jul 25, 2017
@pdiniz13
Copy link

Are there plans to merge this in anytime soon?

@DedDorito
Copy link

Any chance this can be merged sometime in the near future?

@fabianfiorotto
Copy link

What about a fork? 🍴 Is someone encouraged?

@kwent
Copy link

kwent commented Dec 4, 2017

Also interested by this feature ! What else need to be done to see this merge ?

@dougwilson
Copy link
Member

So taking a look, there is still an outstanding requested change above that hasn't yet been made. But in addition to that, I think the biggest issue here is how the option is tracked: it is being tracked as a property of the parser, even though the parser has nothing to do with this behavior. It should be tracked on the Query sequence, which is the object that manages the life cycle of each Query, which is what the scope of the option is being implemented in.

There is also a long-standing issue about putting any properties on the RowDataPacket prototype, as it will conflict with any row names a user may be using. Eventually the existing ones will get removed in the next major, but unless someone can clarify the reason there are new ones being added here and how there is absoltely no other way to accomplish the task, no new properties should be added to RowDataPacket prototype.

I will take a closer look into these issues as well, to see what I can do to help this along, but if someone can provide details here about these, that would help speed it along as well.

@kwent
Copy link

kwent commented Dec 9, 2017

Awesome let us know ! I'm not sure how i can help when reading what you just said but i'm craving for this feature

@kwent
Copy link

kwent commented Feb 8, 2018

@dougwilson Did you get some time to take a look into that issue ? I'm not sure i'm able to provide advices or how we should do it by myself...

@dougwilson
Copy link
Member

I have not, no.

@fabianfiorotto
Copy link

@dougwilson Since this pull request is almost dead I created my own solution to this.

#2092

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

7 participants