From fb883e2a7411e75974b31cea18f6a61dd5644313 Mon Sep 17 00:00:00 2001 From: reinvantveer Date: Thu, 26 May 2022 19:50:50 +0200 Subject: [PATCH 1/3] return field label instead of name, which contains any alias instead of the source. Fixes https://github.com/baztian/jaydebeapi/issues/81 Fixes https://github.com/baztian/jaydebeapi/issues/169 Signed-off-by: reinvantveer --- jaydebeapi/__init__.py | 2 +- test/test_integration.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/jaydebeapi/__init__.py b/jaydebeapi/__init__.py index a890c3d..54693ed 100644 --- a/jaydebeapi/__init__.py +++ b/jaydebeapi/__init__.py @@ -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, diff --git a/test/test_integration.py b/test/test_integration.py index e795339..78c8d69 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -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 " \ From 77b49a9e7f7bb104884cd9ac501dd5c7f5080a39 Mon Sep 17 00:00:00 2001 From: reinvantveer Date: Thu, 26 May 2022 20:12:37 +0200 Subject: [PATCH 2/3] bump version, add release notes Signed-off-by: reinvantveer --- .bumpversion.cfg | 2 +- .github/workflows/tests.yml | 2 +- README.rst | 4 ++++ jaydebeapi/__init__.py | 2 +- setup.py | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index f9aa4ea..3a16013 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.2.3 +current_version = 1.2.4 commit = True tag = True diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b420de5..4ff91c4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/README.rst b/README.rst index f4a1d61..dacc327 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/jaydebeapi/__init__.py b/jaydebeapi/__init__.py index 54693ed..24c9111 100644 --- a/jaydebeapi/__init__.py +++ b/jaydebeapi/__init__.py @@ -17,7 +17,7 @@ # License along with JayDeBeApi. If not, see # . -__version_info__ = (1, 2, 3) +__version_info__ = (1, 2, 4) __version__ = ".".join(str(i) for i in __version_info__) import datetime diff --git a/setup.py b/setup.py index 67a2d1d..1395b11 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ setup( #basic package data name = 'JayDeBeApi', - version = '1.2.3', + version = '1.2.4', author = 'Bastian Bowe', author_email = 'bastian.dev@gmail.com', license = 'GNU LGPL', From 99f0698ff3b9efcc5b8dda9d49bd4c11af81ffc5 Mon Sep 17 00:00:00 2001 From: reinvantveer Date: Thu, 26 May 2022 20:24:59 +0200 Subject: [PATCH 3/3] add missing subindex to get column label from result description Signed-off-by: reinvantveer --- test/test_integration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_integration.py b/test/test_integration.py index 78c8d69..5375455 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -84,7 +84,7 @@ def test_execute_and_fetch_alias(self): stmt = "select ACCOUNT_ID as `a_id` from ACCOUNT" cursor.execute(stmt) field_names = cursor.description - self.assertEqual(field_names[0], 'a_id') + self.assertEqual(field_names[0][0], 'a_id') def test_execute_and_fetch(self): with self.conn.cursor() as cursor: