|
32 | 32 | import unittest
|
33 | 33 | import time
|
34 | 34 | import sys
|
| 35 | +import phoenixdb |
35 | 36 |
|
36 | 37 | def str2bytes(sval):
|
37 | 38 | if sys.version_info < (3,0) and isinstance(sval, str):
|
@@ -74,7 +75,7 @@ class mytest(dbapi20.DatabaseAPI20Test):
|
74 | 75 | insert = 'insert'
|
75 | 76 |
|
76 | 77 | lowerfunc = 'lower' # Name of stored procedure to convert string->lowercase
|
77 |
| - |
| 78 | + |
78 | 79 | # Some drivers may need to override these helpers, for example adding
|
79 | 80 | # a 'commit' after the execute.
|
80 | 81 | def executeDDL1(self,cursor):
|
@@ -208,7 +209,7 @@ def test_rollback(self):
|
208 | 209 | con.rollback()
|
209 | 210 | except self.driver.NotSupportedError:
|
210 | 211 | pass
|
211 |
| - |
| 212 | + |
212 | 213 | def test_cursor(self):
|
213 | 214 | con = self._connect()
|
214 | 215 | try:
|
@@ -399,12 +400,12 @@ def _paraminsert(self,cur):
|
399 | 400 | trouble = "thi%s :may ca%(u)se? troub:1e"
|
400 | 401 | self.assertEqual(res[0][1], trouble,
|
401 | 402 | 'cursor.fetchall retrieved incorrect data, or data inserted '
|
402 |
| - 'incorrectly. Got=%s, Expected=%s' % (repr(res[0][1]), repr(trouble))) |
| 403 | + 'incorrectly. Got=%s, Expected=%s' % (repr(res[0][1]), repr(trouble))) |
403 | 404 | self.assertEqual(res[1][1], trouble,
|
404 | 405 | 'cursor.fetchall retrieved incorrect data, or data inserted '
|
405 | 406 | 'incorrectly. Got=%s, Expected=%s' % (repr(res[1][1]), repr(trouble)
|
406 | 407 | ))
|
407 |
| - |
| 408 | + |
408 | 409 | def test_executemany(self):
|
409 | 410 | con = self._connect()
|
410 | 411 | try:
|
@@ -575,7 +576,7 @@ def test_fetchmany(self):
|
575 | 576 | self.assertEqual(len(rows),6)
|
576 | 577 | rows = [r[0] for r in rows]
|
577 | 578 | rows.sort()
|
578 |
| - |
| 579 | + |
579 | 580 | # Make sure we get the right data back out
|
580 | 581 | for i in range(0,6):
|
581 | 582 | self.assertEqual(rows[i],self.samples[i],
|
@@ -646,10 +647,10 @@ def test_fetchall(self):
|
646 | 647 | 'cursor.fetchall should return an empty list if '
|
647 | 648 | 'a select query returns no rows'
|
648 | 649 | )
|
649 |
| - |
| 650 | + |
650 | 651 | finally:
|
651 | 652 | con.close()
|
652 |
| - |
| 653 | + |
653 | 654 | def test_mixedfetch(self):
|
654 | 655 | con = self._connect()
|
655 | 656 | try:
|
@@ -832,3 +833,17 @@ def test_ROWID(self):
|
832 | 833 | self.assertTrue(hasattr(self.driver,'ROWID'),
|
833 | 834 | 'module.ROWID must be defined.'
|
834 | 835 | )
|
| 836 | + |
| 837 | + # https://issues.apache.org/jira/browse/PHOENIX-6917 |
| 838 | + def test_alias(self): |
| 839 | + con = self._connect() |
| 840 | + try: |
| 841 | + cur = con.cursor(cursor_factory=phoenixdb.cursor.DictCursor) |
| 842 | + self.executeDDL1(cur) |
| 843 | + for sql in self._populate(): |
| 844 | + cur.execute(sql) |
| 845 | + cur.execute('select name as beverages from %sbooze' % self.table_prefix) |
| 846 | + self.assertEqual(cur.description[0][0], 'BEVERAGES') |
| 847 | + self.assertEqual(cur.fetchone()['BEVERAGES'], 'Carlton Cold') |
| 848 | + finally: |
| 849 | + con.close() |
0 commit comments