chooper / restful-sqlite

Automatically exported from code.google.com/p/restful-sqlite
0 stars 0 forks source link

list_columns fails if table is empty #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a new table, do not add any records
2. Call list_columns on the new table

What is the expected output? What do you see instead?
The expected output is the names of the columns in the table. Instead you
will get an AttributeError.

Traceback (most recent call last):
  File "./test.py", line 66, in test_list_columns
    res = db.list_columns(TEST_DB,TEST_TABLE)
  File "/home/chooper/restful-sqlite/db.py", line 59, in list_columns
    columns = c.keys()
AttributeError: 'NoneType' object has no attribute 'keys'

This is the result of fetchone() returning None. Instead of using the
sqlite3 Row obj to get column names we should probably query the schema
table instead.

Original issue reported on code.google.com by hoop...@gmail.com on 28 Dec 2009 at 5:34

GoogleCodeExporter commented 9 years ago
Fixed in rev 3049ba9bee

Original comment by hoop...@gmail.com on 28 Dec 2009 at 6:12