From 9641fa31b0ee90a0af28c80220acc0e150b519e3 Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Mon, 3 Oct 2022 09:14:24 -0400 Subject: [PATCH] Correct SELECT query display bug when using custom field ordering --- py_dbcn/connectors/core/display.py | 11 +- tests/connectors/core/test_display.py | 291 ++++++++++++++++++ .../mysql/expected_display_output.py | 162 ++++++++++ tests/connectors/mysql/test_display.py | 2 + .../postgresql/expected_display_output.py | 162 ++++++++++ tests/connectors/postgresql/test_display.py | 2 + 6 files changed, 625 insertions(+), 5 deletions(-) diff --git a/py_dbcn/connectors/core/display.py b/py_dbcn/connectors/core/display.py index c22ab20..e2b3c1c 100644 --- a/py_dbcn/connectors/core/display.py +++ b/py_dbcn/connectors/core/display.py @@ -6,6 +6,7 @@ Should be inherited by language-specific connectors. """ # System Imports. +import copy import textwrap # Internal Imports. @@ -317,18 +318,18 @@ class RecordDisplay: ] else: select_clause = select_clause.split(',') + table_cols = [] + table_describe = self._base.tables.describe(table_name, display_query=False, display_results=False) for index in range(len(select_clause)): + # Sanitize select clause values. clause = select_clause[index].strip() if len(clause) > 1 and clause[0] == clause[-1] and clause[0] in ['`', '"', "'"]: clause = clause[1:-1] select_clause[index] = clause # Calculate column header values, filtered by select clause. - table_cols = [ - x[col_name_index] - for x in self._base.tables.describe(table_name, display_query=False, display_results=False) - if x[col_name_index] in select_clause - ] + table_cols = copy.deepcopy(select_clause) + col_len_array = [] total_col_len = 0 for table_col in table_cols: diff --git a/tests/connectors/core/test_display.py b/tests/connectors/core/test_display.py index 6d2b1b6..aeac8f7 100644 --- a/tests/connectors/core/test_display.py +++ b/tests/connectors/core/test_display.py @@ -7,6 +7,7 @@ various specific database test classes. This ensures that all databases types ru """ # System Imports. +from datetime import datetime # Internal Imports. from py_dbcn.constants import ( @@ -650,3 +651,293 @@ class CoreDisplayRecordsMixin: self.get_logging_output(ilog, 1), '{0}{1}{2}'.format(OUTPUT_RESULTS, self.expected_output.records.SELECT__PT_15, OUTPUT_RESET), ) + + def test__display__select_records__limited(self): + """""" + select_from_query = '{0}SELECT {1} FROM category2;{2}'.format(OUTPUT_QUERY, '{0}', OUTPUT_RESET) + quoted_id = '{0}id{0}'.format(self.connector.validate._quote_identifier_format) + quoted_name = '{0}name{0}'.format(self.connector.validate._quote_identifier_format) + quoted_desc = '{0}description{0}'.format(self.connector.validate._quote_identifier_format) + + # Create table. + self.connector.tables.create('category2', self._columns_clause__basic, display_query=False) + + # Create record. + self.connector.records.insert( + 'category2', + '(1, {0}longer name value{0}, {0}short desc{0})'.format( + self.connector.validate._quote_str_literal_format, + ), + display_query=False, + ) + + with self.subTest('With basic column types - Pull all'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category2') + self.assertText(self.get_logging_output(ilog, 0), select_from_query.format('*')) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__BASIC__ALL, + OUTPUT_RESET, + ), + ) + + with self.subTest('With basic column types - Exclude id'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category2', 'name, description') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_name, quoted_desc)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__BASIC__OMIT_ID, + OUTPUT_RESET + ), + ) + + with self.subTest('With basic column types - Exclude name'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category2', 'id, description') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_id, quoted_desc)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__BASIC__OMIT_NAME, + OUTPUT_RESET, + ), + ) + + with self.subTest('With basic column types - Exclude description'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category2', 'id, name') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_id, quoted_name)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__BASIC__OMIT_DESC, + OUTPUT_RESET, + ), + ) + + with self.subTest('With basic column types - Pull all reversed'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category2', 'description, name, id') + curr_select_clause = select_from_query.format('{0}, {1}, {2}'.format(quoted_desc, quoted_name, quoted_id)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__BASIC__REVERSED_ALL, + OUTPUT_RESET, + ), + ) + + with self.subTest('With basic column types - Exclude id reversed'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category2', 'description, name') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_desc, quoted_name)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__BASIC__REVERSED_OMIT_ID, + OUTPUT_RESET + ), + ) + + with self.subTest('With basic column types - Exclude name reversed'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category2', 'description, id') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_desc, quoted_id)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__BASIC__REVERSED_OMIT_NAME, + OUTPUT_RESET, + ), + ) + + with self.subTest('With basic column types - Exclude description reversed'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category2', 'name, id') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_name, quoted_id)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__BASIC__REVERSED_OMIT_DESC, + OUTPUT_RESET, + ), + ) + + datetime_now = datetime.now() + select_from_query = '{0}SELECT {1} FROM category3;{2}'.format(OUTPUT_QUERY, '{0}', OUTPUT_RESET) + quoted_datetime = '{0}test_datetime{0}'.format(self.connector.validate._quote_identifier_format) + quoted_date = '{0}test_date{0}'.format(self.connector.validate._quote_identifier_format) + + # Create table. + self.connector.tables.create('category3', self._columns_clause__datetime, display_query=False) + + # Create record. + self.connector.records.insert('category3', [1, datetime_now, datetime_now], display_query=False) + + with self.subTest('With datetime column types - Pull all'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category3') + self.assertText(self.get_logging_output(ilog, 0), select_from_query.format('*')) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__DATETIME__ALL.format( + datetime_now.strftime('%Y-%m-%d %H:%M:%S'), + datetime_now.date(), + ), + OUTPUT_RESET, + ), + ) + + with self.subTest('With datetime column types - Exclude id'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category3', 'test_datetime, test_date') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_datetime, quoted_date)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__DATETIME__OMIT_ID.format( + datetime_now.strftime('%Y-%m-%d %H:%M:%S'), + datetime_now.date(), + ), + OUTPUT_RESET + ), + ) + + with self.subTest('With datetime column types - Exclude datetime'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category3', 'id, test_date') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_id, quoted_date)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__DATETIME__OMIT_DATETIME.format( + datetime_now.date(), + ), + OUTPUT_RESET, + ), + ) + + with self.subTest('With datetime column types - Exclude date'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category3', 'id, test_datetime') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_id, quoted_datetime)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__DATETIME__OMIT_DATE.format( + datetime_now.strftime('%Y-%m-%d %H:%M:%S'), + ), + OUTPUT_RESET, + ), + ) + + with self.subTest('With datetime column types - Pull all reversed'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category3', 'test_date, test_datetime, id') + curr_select_clause = select_from_query.format( + '{0}, {1}, {2}'.format(quoted_date, quoted_datetime, quoted_id), + ) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__DATETIME__REVERSED_ALL.format( + datetime_now.date(), + datetime_now.strftime('%Y-%m-%d %H:%M:%S'), + ), + OUTPUT_RESET, + ), + ) + + with self.subTest('With datetime column types - Exclude id reversed'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category3', 'test_date, test_datetime') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_date, quoted_datetime)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__DATETIME__REVERSED_OMIT_ID.format( + datetime_now.date(), + datetime_now.strftime('%Y-%m-%d %H:%M:%S'), + ), + OUTPUT_RESET + ), + ) + + with self.subTest('With datetime column types - Exclude datetime reversed'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category3', 'test_date, id') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_date, quoted_id)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATETIME.format( + datetime_now.date(), + ), + OUTPUT_RESET, + ), + ) + + with self.subTest('With datetime column types - Exclude date reversed'): + # Capture logging output. + with self.assertLogs(None, 'INFO') as ilog: + self.connector.records.select('category3', 'test_datetime, id') + curr_select_clause = select_from_query.format('{0}, {1}'.format(quoted_datetime, quoted_id)) + self.assertText(self.get_logging_output(ilog, 0), curr_select_clause) + self.assertText( + self.get_logging_output(ilog, 1), + '{0}{1}{2}'.format( + OUTPUT_RESULTS, + self.expected_output.records.LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATE.format( + datetime_now.strftime('%Y-%m-%d %H:%M:%S'), + ), + OUTPUT_RESET, + ), + ) diff --git a/tests/connectors/mysql/expected_display_output.py b/tests/connectors/mysql/expected_display_output.py index 792e2ee..f3c3855 100644 --- a/tests/connectors/mysql/expected_display_output.py +++ b/tests/connectors/mysql/expected_display_output.py @@ -362,6 +362,150 @@ EXPECTED__RECORD__SELECT__PT_15 = """ +---------+-----------+------------------+ """.strip() + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__ALL = """ ++----+-------------------+-------------+ +| id | name | description | ++----+-------------------+-------------+ +| 1 | longer name value | short desc | ++----+-------------------+-------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_ID = """ ++-------------------+-------------+ +| name | description | ++-------------------+-------------+ +| longer name value | short desc | ++-------------------+-------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_NAME = """ ++----+-------------+ +| id | description | ++----+-------------+ +| 1 | short desc | ++----+-------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_DESC = """ ++----+-------------------+ +| id | name | ++----+-------------------+ +| 1 | longer name value | ++----+-------------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_ALL = """ ++-------------+-------------------+----+ +| description | name | id | ++-------------+-------------------+----+ +| short desc | longer name value | 1 | ++-------------+-------------------+----+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_ID = """ ++-------------+-------------------+ +| description | name | ++-------------+-------------------+ +| short desc | longer name value | ++-------------+-------------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_NAME = """ ++-------------+----+ +| description | id | ++-------------+----+ +| short desc | 1 | ++-------------+----+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_DESC = """ ++-------------------+----+ +| name | id | ++-------------------+----+ +| longer name value | 1 | ++-------------------+----+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__ALL = """ ++----+---------------------+------------+ +| id | test_datetime | test_date | ++----+---------------------+------------+ +| 1 | {0} | {1} | ++----+---------------------+------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_ID = """ ++---------------------+------------+ +| test_datetime | test_date | ++---------------------+------------+ +| {0} | {1} | ++---------------------+------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_DATETIME = """ ++----+------------+ +| id | test_date | ++----+------------+ +| 1 | {0} | ++----+------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_DATE = """ ++----+---------------------+ +| id | test_datetime | ++----+---------------------+ +| 1 | {0} | ++----+---------------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_ALL = """ ++------------+---------------------+----+ +| test_date | test_datetime | id | ++------------+---------------------+----+ +| {0} | {1} | 1 | ++------------+---------------------+----+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_ID = """ ++------------+---------------------+ +| test_date | test_datetime | ++------------+---------------------+ +| {0} | {1} | ++------------+---------------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATETIME = """ ++------------+----+ +| test_date | id | ++------------+----+ +| {0} | 1 | ++------------+----+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATE = """ ++---------------------+----+ +| test_datetime | id | ++---------------------+----+ +| {0} | 1 | ++---------------------+----+ +""".strip() + # endregion Record Display Output @@ -397,5 +541,23 @@ class ExpectedOutput: SELECT__PT_14 = EXPECTED__RECORD__SELECT__PT_14 SELECT__PT_15 = EXPECTED__RECORD__SELECT__PT_15 + LIMITED_SELECT__BASIC__ALL = EXPECTED__RECORD__LIMITED_SELECT__BASIC__ALL + LIMITED_SELECT__BASIC__OMIT_ID = EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_ID + LIMITED_SELECT__BASIC__OMIT_NAME = EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_NAME + LIMITED_SELECT__BASIC__OMIT_DESC = EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_DESC + LIMITED_SELECT__BASIC__REVERSED_ALL = EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_ALL + LIMITED_SELECT__BASIC__REVERSED_OMIT_ID = EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_ID + LIMITED_SELECT__BASIC__REVERSED_OMIT_NAME = EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_NAME + LIMITED_SELECT__BASIC__REVERSED_OMIT_DESC = EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_DESC + + LIMITED_SELECT__DATETIME__ALL = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__ALL + LIMITED_SELECT__DATETIME__OMIT_ID = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_ID + LIMITED_SELECT__DATETIME__OMIT_DATETIME = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_DATETIME + LIMITED_SELECT__DATETIME__OMIT_DATE = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_DATE + LIMITED_SELECT__DATETIME__REVERSED_ALL = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_ALL + LIMITED_SELECT__DATETIME__REVERSED_OMIT_ID = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_ID + LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATETIME = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATETIME + LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATE = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATE + tables = Tables() records = Records() diff --git a/tests/connectors/mysql/test_display.py b/tests/connectors/mysql/test_display.py index b2ed351..05f2403 100644 --- a/tests/connectors/mysql/test_display.py +++ b/tests/connectors/mysql/test_display.py @@ -10,6 +10,7 @@ from .constants import ( SHOW_TABLES_QUERY, COLUMNS_CLAUSE__BASIC, COLUMNS_CLAUSE__MINIMAL, + COLUMNS_CLAUSE__DATETIME, ) from .test_core import TestMysqlDatabaseParent from .expected_display_output import ExpectedOutput @@ -119,3 +120,4 @@ class TestMysqlDisplayRecords(TestMysqlDatabaseParent, CoreDisplayRecordsMixin): cls._show_tables_query = SHOW_TABLES_QUERY cls._columns_clause__minimal = COLUMNS_CLAUSE__MINIMAL cls._columns_clause__basic = COLUMNS_CLAUSE__BASIC + cls._columns_clause__datetime = COLUMNS_CLAUSE__DATETIME diff --git a/tests/connectors/postgresql/expected_display_output.py b/tests/connectors/postgresql/expected_display_output.py index 5ab1c32..f94e174 100644 --- a/tests/connectors/postgresql/expected_display_output.py +++ b/tests/connectors/postgresql/expected_display_output.py @@ -362,6 +362,150 @@ EXPECTED__RECORD__SELECT__PT_15 = """ +---------+-----------+------------------+ """.strip() + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__ALL = """ ++----+-------------------+-------------+ +| id | name | description | ++----+-------------------+-------------+ +| 1 | longer name value | short desc | ++----+-------------------+-------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_ID = """ ++-------------------+-------------+ +| name | description | ++-------------------+-------------+ +| longer name value | short desc | ++-------------------+-------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_NAME = """ ++----+-------------+ +| id | description | ++----+-------------+ +| 1 | short desc | ++----+-------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_DESC = """ ++----+-------------------+ +| id | name | ++----+-------------------+ +| 1 | longer name value | ++----+-------------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_ALL = """ ++-------------+-------------------+----+ +| description | name | id | ++-------------+-------------------+----+ +| short desc | longer name value | 1 | ++-------------+-------------------+----+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_ID = """ ++-------------+-------------------+ +| description | name | ++-------------+-------------------+ +| short desc | longer name value | ++-------------+-------------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_NAME = """ ++-------------+----+ +| description | id | ++-------------+----+ +| short desc | 1 | ++-------------+----+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_DESC = """ ++-------------------+----+ +| name | id | ++-------------------+----+ +| longer name value | 1 | ++-------------------+----+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__ALL = """ ++----+---------------------+------------+ +| id | test_datetime | test_date | ++----+---------------------+------------+ +| 1 | {0} | {1} | ++----+---------------------+------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_ID = """ ++---------------------+------------+ +| test_datetime | test_date | ++---------------------+------------+ +| {0} | {1} | ++---------------------+------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_DATETIME = """ ++----+------------+ +| id | test_date | ++----+------------+ +| 1 | {0} | ++----+------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_DATE = """ ++----+---------------------+ +| id | test_datetime | ++----+---------------------+ +| 1 | {0} | ++----+---------------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_ALL = """ ++------------+---------------------+----+ +| test_date | test_datetime | id | ++------------+---------------------+----+ +| {0} | {1} | 1 | ++------------+---------------------+----+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_ID = """ ++------------+---------------------+ +| test_date | test_datetime | ++------------+---------------------+ +| {0} | {1} | ++------------+---------------------+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATETIME = """ ++------------+----+ +| test_date | id | ++------------+----+ +| {0} | 1 | ++------------+----+ +""".strip() + + +EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATE = """ ++---------------------+----+ +| test_datetime | id | ++---------------------+----+ +| {0} | 1 | ++---------------------+----+ +""".strip() + # endregion Record Display Output @@ -397,5 +541,23 @@ class ExpectedOutput: SELECT__PT_14 = EXPECTED__RECORD__SELECT__PT_14 SELECT__PT_15 = EXPECTED__RECORD__SELECT__PT_15 + LIMITED_SELECT__BASIC__ALL = EXPECTED__RECORD__LIMITED_SELECT__BASIC__ALL + LIMITED_SELECT__BASIC__OMIT_ID = EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_ID + LIMITED_SELECT__BASIC__OMIT_NAME = EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_NAME + LIMITED_SELECT__BASIC__OMIT_DESC = EXPECTED__RECORD__LIMITED_SELECT__BASIC__OMIT_DESC + LIMITED_SELECT__BASIC__REVERSED_ALL = EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_ALL + LIMITED_SELECT__BASIC__REVERSED_OMIT_ID = EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_ID + LIMITED_SELECT__BASIC__REVERSED_OMIT_NAME = EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_NAME + LIMITED_SELECT__BASIC__REVERSED_OMIT_DESC = EXPECTED__RECORD__LIMITED_SELECT__BASIC__REVERSED_OMIT_DESC + + LIMITED_SELECT__DATETIME__ALL = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__ALL + LIMITED_SELECT__DATETIME__OMIT_ID = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_ID + LIMITED_SELECT__DATETIME__OMIT_DATETIME = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_DATETIME + LIMITED_SELECT__DATETIME__OMIT_DATE = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__OMIT_DATE + LIMITED_SELECT__DATETIME__REVERSED_ALL = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_ALL + LIMITED_SELECT__DATETIME__REVERSED_OMIT_ID = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_ID + LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATETIME = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATETIME + LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATE = EXPECTED__RECORD__LIMITED_SELECT__DATETIME__REVERSED_OMIT_DATE + tables = Tables() records = Records() diff --git a/tests/connectors/postgresql/test_display.py b/tests/connectors/postgresql/test_display.py index 550fc97..32d87c3 100644 --- a/tests/connectors/postgresql/test_display.py +++ b/tests/connectors/postgresql/test_display.py @@ -10,6 +10,7 @@ from .constants import ( SHOW_TABLES_QUERY, COLUMNS_CLAUSE__BASIC, COLUMNS_CLAUSE__MINIMAL, + COLUMNS_CLAUSE__DATETIME, ) from .expected_display_output import ExpectedOutput from .test_core import TestPostgresqlDatabaseParent @@ -117,3 +118,4 @@ class TestPostgreSQLDisplayRecords(TestPostgresqlDatabaseParent, CoreDisplayReco cls._show_tables_query = SHOW_TABLES_QUERY cls._columns_clause__minimal = COLUMNS_CLAUSE__MINIMAL cls._columns_clause__basic = COLUMNS_CLAUSE__BASIC + cls._columns_clause__datetime = COLUMNS_CLAUSE__DATETIME -- GitLab