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

Removed superfluous second setting of SQL_ATTR_ACCESS_MODE in connect() #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FenderJazz
Copy link

Removed the call to SQLSetConnectAttr that set SQL_ATTR_ACCESS_MODE every time connect() was called. Kept the call that sets SQL_ATTR_ACCESS_MODE only when the user specifies a read-only connection. My rationale for this choice is (1) that it is better practice not to explicitly set attributes that equate to default behaviour, because it plays better for our user if a (poorly designed) ODBC driver has not implemented the attribute, and (2) that this is how I believe pyodbc behaves with 'readonly'.

I think the same arguments would lead to only setting SQL_ATTR_AUTOCOMMIT if autocommit is false, but I don't have the nerve to make that change as well, or to search for other similar cases!

Removed the call to SQLSetConnectAttr that set SQL_ATTR_ACCESS_MODE every time connect() was called.  Kept the call that sets SQL_ATTR_ACCESS_MODE only when the user specifies a read-only connection.  My rationale for this choice is (1) that it is better practice not to explicitly set attributes that equate to default behaviour, because it plays better for our user if a (poorly designed) ODBC driver has not implemented the attribute, and (2) that this is how I believe pyodbc behaves with 'readonly'.

I think the same arguments would lead to only setting SQL_ATTR_AUTOCOMMIT if autocommit is false, but I don't have the nerve to make that change as well, or to search for other similar cases!
@FenderJazz FenderJazz closed this Aug 4, 2019
@FenderJazz FenderJazz reopened this Aug 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant