-
Notifications
You must be signed in to change notification settings - Fork 81
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
Allow callers to pass pre-connection attributes. #353
Conversation
connection::connection and connection::connect gain an invocation that has as an argument a std::list< connection::attribute >
@detule Thank you for your work. I like the idea. Before I do detailed review, let me share high level comments first:
|
Hi @mloskot Thanks! Happy to go the route of a broader abstraction for Can you help me narrow down what the interface should look like? I had originally considered something like
Eventually moved away from it since I tried to use it with some simple attributes, and it was a bit of a chore / a lot more verbose than the tuple. I think you have something simpler / elegant in mind - let me know, happy to see it through. |
I don't think there is a need for any particular interfaces, but your tuple could be improved with using connect_attribute = std::tuple<long, long, std::variant<int, nanodbc::string, ...>>; or that tuple could be turned into plain structure with the same (public) members. |
Thanks @mloskot
Thanks again. |
Hi @mloskot : Ping - whenever you have time / an opportunity to take a second look. Thanks. |
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.
This looks good. I just added a few nitpicks about the camelCase
naming.
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.
LGTM. Thanks!
Thanks for the helpful feedback along the way - appreciate it. |
Hi @mloskot, @lexicalunit :
This PR is one approach to exposing mechanisms to the user to set pre-connection attributes ( for example, #215 ).
The high level:
connection::connection(…., std::list< attribute > )
constructor, and aconnection::connect(…., std::list< attribute > )
methods, allowing the caller to pass a list of pre-connection attributes as an argument. At the implementation level, other constructors (timeout, async) and other connect methods are routed through this one since this is intended to be the most generic one.Some more detail:
but ultimately went in a different direction for a couple of reasons.
Not done here, but we could easily expose a connection.set_attribute method; if there is a desire to do this in addition to the mechanisms for setting pre-connection attributes above (rather than replace them).
Not in-love with this; feels a little bare-metal. Tried to infer the middle argument (StringLength to SQLSetConnectAttr) based on the type of buffer. But had trouble codifying the rules since it seemed to me they are not uniform - see for example ODBC documentation for the case of ValuePtr a binary buffer and how it is treated with the attribute is ODBC- versus driver-defined. It can probably be done, but also was mindful of the “nano” in nanodbc.
Feedback is appreciated.
Thank you!