diff --git a/Doc/includes/sqlite3/pysqlite_datetime.py b/Doc/includes/sqlite3/pysqlite_datetime.py index 5d843f906b3062d..f8481b7b956b8f1 100644 --- a/Doc/includes/sqlite3/pysqlite_datetime.py +++ b/Doc/includes/sqlite3/pysqlite_datetime.py @@ -18,5 +18,6 @@ row = cur.fetchone() print("current_date", row[0], type(row[0])) print("current_timestamp", row[1], type(row[1])) +print(cur.description) con.close() diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py index c714116ac49208b..cbd46d4978afb96 100644 --- a/Lib/sqlite3/test/regression.py +++ b/Lib/sqlite3/test/regression.py @@ -68,7 +68,7 @@ def CheckStatementReset(self): def CheckColumnNameWithSpaces(self): cur = self.con.cursor() cur.execute('select 1 as "foo bar [datetime]"') - self.assertEqual(cur.description[0][0], "foo bar") + self.assertEqual(cur.description[0][0], "foo bar [datetime]") cur.execute('select 1 as "foo baz"') self.assertEqual(cur.description[0][0], "foo baz") diff --git a/Lib/sqlite3/test/types.py b/Lib/sqlite3/test/types.py index 19ecd07500fec50..0fdc67a6cdce39a 100644 --- a/Lib/sqlite3/test/types.py +++ b/Lib/sqlite3/test/types.py @@ -281,7 +281,7 @@ def CheckColName(self): # Check if the stripping of colnames works. Everything after the first # whitespace should be stripped. - self.assertEqual(self.cur.description[0][0], "x") + self.assertEqual(self.cur.description[0][0], "x [bar]") def CheckCaseInConverterName(self): self.cur.execute("select 'other' as \"x [b1b1]\"") diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index ab276db782607c9..80b01ebbecc0bc1 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -202,10 +202,7 @@ _pysqlite_build_column_name(const char* colname) } for (pos = colname;; pos++) { - if (*pos == 0 || *pos == '[') { - if ((*pos == '[') && (pos > colname) && (*(pos-1) == ' ')) { - pos--; - } + if (*pos == '\0') { return PyUnicode_FromStringAndSize(colname, pos - colname); } }