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

Column labels to fix skipping query return aliases #217

Open
wants to merge 3 commits 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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.2.3
current_version = 1.2.4
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.8]
python-version: [2.7, 3.5, 3.6, 3.8, 3.9, 3.10]
plattform: ["Python"]
include:
- python-version: 3.8
Expand Down
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ Changelog
=========

- Next version - unreleased
- 1.2.4 - 2022-05-26
- Fix returning the column label instead of the name, which accounts for
column aliasing in sql queries

- 1.2.3 - 2020-06-12

- Make pip install for Python 2 work by changing JPype1 requirement to older
Expand Down
4 changes: 2 additions & 2 deletions jaydebeapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# License along with JayDeBeApi. If not, see
# <http://www.gnu.org/licenses/>.

__version_info__ = (1, 2, 3)
__version_info__ = (1, 2, 4)
__version__ = ".".join(str(i) for i in __version_info__)

import datetime
Expand Down 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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
setup(
#basic package data
name = 'JayDeBeApi',
version = '1.2.3',
version = '1.2.4',
author = 'Bastian Bowe',
author_email = '[email protected]',
license = 'GNU LGPL',
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][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