-
Notifications
You must be signed in to change notification settings - Fork 102
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 rbs for mysql2-0.5 #563
Conversation
@euglena1215 Thanks for your contribution! Please follow the instructions below for each change. Available commandsYou can use the following commands by commenting on this PR.
|
/merge |
# and performance_schema.session_account_connect_attrs | ||
def parse_connect_attrs: (untyped conn_attrs) -> (::Hash[untyped, untyped] | untyped) | ||
|
||
def query: (String sql, ?::Hash[untyped, untyped] options) -> Mysql2::result |
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.
The query
method changes the type returned by the as
keyword argument.
If as: :hash
or unspecified, it returns Array[Hash]
; if as: :array
, it returns Array[Array]
.
If RBS could distinguish and overload literals rather than the type of the argument value, it should be able to uniquely determine the type.
def query: (String sql) -> Mysql2::ResultAsHash
| (String sql, as: :hash) -> Mysql2::ResultAsHash
| (String sql, as: :array) -> Mysql2::ResultAsArray
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.
The above RBS syntax was found to work correctly. I was mistaken.
On the other hand, the query
method was implemented to override the options passed in initialize
, so the query
method argument did not uniquely determine the type of the return value...
Mysql2::Client.new.query(“SELECT * FROM users”) # => Array[Hash].
Mysql2::Client.new(as: :array).query(“SELECT * FROM users”) # => maybe it should be Array[Array]
Thanks for your review, @euglena1215! @euglena1215, @euglena1215 This PR is ready to be merged. |
1 similar comment
Thanks for your review, @euglena1215! @euglena1215, @euglena1215 This PR is ready to be merged. |
https://github.com/brianmario/mysql2