Skip to content

Commit cc72a28

Browse files
butsonmadscientist
authored andcommitted
Use column label instead of column name in column description
1 parent a2d997e commit cc72a28

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

pynuodb/encodedsession.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ def _parse_result_set_description(self):
512512
self.getString() # catalog_name
513513
self.getString() # schema_name
514514
self.getString() # table_name
515-
column_name = self.getString()
516-
self.getString() # column_label
515+
self.getString() # column_name
516+
column_label = self.getString() # column_label
517517
self.getValue() # collation_sequence
518518
column_type_name = self.getString()
519519
self.getInt() # column_type
@@ -524,7 +524,7 @@ def _parse_result_set_description(self):
524524

525525
# TODO: type information should be derived from the type
526526
# (column_type) not the typename.
527-
description[i] = [column_name,
527+
description[i] = [column_label,
528528
datatype.TypeObjectFromNuodb(column_type_name),
529529
column_display_size, None, precision, scale, None]
530530

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
(C) Copyright 2025 Dassault Systemes SE. All Rights Reserved.
3+
4+
This software is licensed under a BSD 3-Clause License.
5+
See the LICENSE file provided with this software.
6+
"""
7+
8+
import decimal
9+
import datetime
10+
11+
from . import nuodb_base
12+
13+
14+
class TestNuoDBDescription(nuodb_base.NuoBase):
15+
16+
def test_description(self):
17+
con = self._connect()
18+
cursor = con.cursor()
19+
20+
cursor.execute("CREATE TEMPORARY TABLE tmp (v1 INTEGER, v2 STRING)" )
21+
cursor.execute("INSERT INTO tmp VALUES (1,'a'), (2,'b')")
22+
cursor.execute("SELECT v1 AS c1, concat(v2,'') as c2 FROM tmp")
23+
row = cursor.fetchone()
24+
d = cursor.description
25+
26+
assert d[0][0].lower() == 'c1'
27+
assert d[1][0].lower() == 'c2'

0 commit comments

Comments
 (0)