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

pymssql.pyx: Check self.description not None before looking at column names #168

Merged
merged 2 commits into from Jan 10, 2014

Conversation

msabramo
Copy link
Contributor

@msabramo msabramo commented Jan 9, 2014

Prevents errors or crashes when as_dict=True and executing queries with no results like CREATE TABLE, INSERT, etc. This problem was introduced by #160, because I forgot to check that self.description is not None.

E.g.:

>>> cursor = conn.cursor(as_dict=True)
>>> cursor.execute("""
... CREATE TABLE dates_and_times (
...     datetime DATETIME,
...     date DATE,
...     time TIME,
... )
...  """)
Traceback (most recent call last):
  File "<stdin>", line 7, in <module>
  File "pymssql.pyx", line 424, in pymssql.Cursor.execute (pymssql.c:5808)
    if len(column_descriptor[0]) == 0
TypeError: 'type' object has no attribute '__getitem__'

before looking at column names

Prevents errors or crashes when as_dict=True and executing queries with
no results like CREATE TABLE, INSERT, etc.
msabramo added a commit that referenced this pull request Jan 10, 2014
…eption2

pymssql.pyx: Check self.description not None before looking at column names
@msabramo msabramo merged commit 90aa30f into master Jan 10, 2014
@msabramo msabramo deleted the as_dict_No_column_name_raise_exception2 branch January 10, 2014 07:53
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.

None yet

1 participant