Skip to content

handle <null> type in query results #177

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pynuodb/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ def __cmp__(self, other):
NUMBER = TypeObject(int, decimal.Decimal)
DATETIME = TypeObject(Timestamp, Date, Time)
ROWID = TypeObject()
NULL = TypeObject(None)

TYPEMAP = {"<null>": None,
TYPEMAP = {"<null>": NULL,
"string": STRING,
"char": STRING,
"varchar": STRING,
Expand Down
13 changes: 13 additions & 0 deletions tests/nuodb_types_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,16 @@ def test_datetime_types(self):
assert row[1] == datetime.time(5, 44, 33, 221100)
assert row[2] == datetime.datetime(2000, 1, 1, 5, 44, 33, 221100)
assert row[3] == datetime.datetime(2000, 1, 1, 5, 44, 33, 221100)

def test_null_type(self):
con = self._connect()
cursor = con.cursor()

null_type = self.driver.TypeObjectFromNuodb('<null>')

cursor.execute("SELECT NULL from dual")
row = cursor.fetchone()

assert len(row) == 1
assert cursor.description[0][1] == null_type
assert row[0] is None