diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-01-29 02:41:44 +0000 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-01-29 03:30:46 +0000 |
| commit | ddb87b7727793ef1d49f3915ad4b2399aeb6ef78 (patch) | |
| tree | 09d6d256f8f01916ff04f917e1e039b32e7992e3 /tests | |
| parent | 3354bbd1b6c9d4cdc4b34bf0a13b81b4e4cd15e7 (diff) | |
| download | psycopg2-ddb87b7727793ef1d49f3915ad4b2399aeb6ef78.tar.gz | |
Convert fields names into valid Python identifiers in NamedTupleCursor
Close #211.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/test_extras_dictcursor.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/test_extras_dictcursor.py b/tests/test_extras_dictcursor.py index 75c2277..99bdeee 100755 --- a/tests/test_extras_dictcursor.py +++ b/tests/test_extras_dictcursor.py @@ -349,6 +349,14 @@ class NamedTupleCursorTest(ConnectingTestCase): curs.execute("update nttest set s = s") self.assertRaises(psycopg2.ProgrammingError, curs.fetchall) + def test_bad_col_names(self): + curs = self.conn.cursor() + curs.execute('select 1 as "foo.bar_baz", 2 as "?column?", 3 as "3"') + rv = curs.fetchone() + self.assertEqual(rv.foo_bar_baz, 1) + self.assertEqual(rv.f_column_, 2) + self.assertEqual(rv.f3, 3) + def test_minimal_generation(self): # Instrument the class to verify it gets called the minimum number of times. from psycopg2.extras import NamedTupleCursor |
