Skip to content

Commit

Permalink
return field label instead of name, which contains any alias instead …
Browse files Browse the repository at this point in the history
…of the source.

Fixes baztian#81
Fixes baztian#169

Signed-off-by: reinvantveer <rein@vantveer.me>
  • Loading branch information
reinvantveer committed May 26, 2022
1 parent 53b2d6a commit fb883e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jaydebeapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def description(self):
dbapi_type = None
else:
dbapi_type = DBAPITypeObject._map_jdbc_type_to_dbapi(jdbc_type)
col_desc = ( m.getColumnName(col),
col_desc = ( m.getColumnLabel(col),
dbapi_type,
size,
size,
Expand Down
7 changes: 7 additions & 0 deletions test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ def test_execute_and_fetch_no_data(self):
result = cursor.fetchall()
self.assertEqual(result, [])

def test_execute_and_fetch_alias(self):
with self.conn.cursor() as cursor:
stmt = "select ACCOUNT_ID as `a_id` from ACCOUNT"
cursor.execute(stmt)
field_names = cursor.description
self.assertEqual(field_names[0], 'a_id')

def test_execute_and_fetch(self):
with self.conn.cursor() as cursor:
cursor.execute("select ACCOUNT_ID, ACCOUNT_NO, BALANCE, BLOCKING " \
Expand Down

0 comments on commit fb883e2

Please sign in to comment.