From d7db38303c06afa4526e595ff5d79ff149388abd Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Sat, 21 Jan 2017 10:26:08 +0000 Subject: [PATCH 1/5] added test_enum_2 --- tests/test_codecs.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_codecs.py b/tests/test_codecs.py index ec8356e5..70b8c083 100644 --- a/tests/test_codecs.py +++ b/tests/test_codecs.py @@ -1053,3 +1053,26 @@ async def test_enum(self): DROP TABLE tab; DROP TYPE enum_t; ''') + + async def test_enum_2(self): + await self.con.execute(''' + CREATE TYPE enum_t AS ENUM ('abc', 'def', 'ghi'); + CREATE TABLE tab ( + a text, + b enum_t + ); + ''') + + try: + await self.con.execute(''' + INSERT INTO tab (a) VALUES ('foo',); + ''') + await self.con.execute(''' + INSERT INTO tab (a, b) VALUES ('foo', 'abc'); + ''') + + finally: + await self.con.execute(''' + DROP TABLE tab; + DROP TYPE enum_t; + ''') From c7e27a96fad1b40269d268e6b7cfdcadc7f22ed8 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Sat, 21 Jan 2017 10:29:04 +0000 Subject: [PATCH 2/5] Changed the test to use arguments in execute --- tests/test_codecs.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/test_codecs.py b/tests/test_codecs.py index 70b8c083..82287399 100644 --- a/tests/test_codecs.py +++ b/tests/test_codecs.py @@ -1064,12 +1064,8 @@ async def test_enum_2(self): ''') try: - await self.con.execute(''' - INSERT INTO tab (a) VALUES ('foo',); - ''') - await self.con.execute(''' - INSERT INTO tab (a, b) VALUES ('foo', 'abc'); - ''') + await self.con.execute('INSERT INTO tab (a) VALUES ($1);', ["foo"]) + await self.con.execute('INSERT INTO tab (a, b) VALUES ($1, $2);', ["foo", "abc"]) finally: await self.con.execute(''' From b63ab8d98a177f984f1a342e5685a3af8aa4ad9c Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Sat, 21 Jan 2017 10:35:41 +0000 Subject: [PATCH 3/5] Fixed the test_enum_2 test --- tests/test_codecs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_codecs.py b/tests/test_codecs.py index 82287399..140f053a 100644 --- a/tests/test_codecs.py +++ b/tests/test_codecs.py @@ -1064,8 +1064,8 @@ async def test_enum_2(self): ''') try: - await self.con.execute('INSERT INTO tab (a) VALUES ($1);', ["foo"]) - await self.con.execute('INSERT INTO tab (a, b) VALUES ($1, $2);', ["foo", "abc"]) + await self.con.execute('INSERT INTO tab (a) VALUES ($1);', "foo") + await self.con.execute('INSERT INTO tab (a, b) VALUES ($1, $2);', "foo", "abc") finally: await self.con.execute(''' From bd00c410f2cdc1168627f763e4f8eb901357a6e3 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Mon, 23 Jan 2017 11:55:29 +0000 Subject: [PATCH 4/5] Added SELECT queries --- tests/test_codecs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_codecs.py b/tests/test_codecs.py index 140f053a..d6da07e6 100644 --- a/tests/test_codecs.py +++ b/tests/test_codecs.py @@ -1066,6 +1066,8 @@ async def test_enum_2(self): try: await self.con.execute('INSERT INTO tab (a) VALUES ($1);', "foo") await self.con.execute('INSERT INTO tab (a, b) VALUES ($1, $2);', "foo", "abc") + await self.con.execute('SELECT a FROM tab;") + await self.con.execute('SELECT a, b FROM tab;") finally: await self.con.execute(''' From 49716480808c2138a990810993a776821b3fced1 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Mon, 23 Jan 2017 12:00:56 +0000 Subject: [PATCH 5/5] Typo in test_enum_2 --- tests/test_codecs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_codecs.py b/tests/test_codecs.py index d6da07e6..dd80ea3c 100644 --- a/tests/test_codecs.py +++ b/tests/test_codecs.py @@ -1066,8 +1066,8 @@ async def test_enum_2(self): try: await self.con.execute('INSERT INTO tab (a) VALUES ($1);', "foo") await self.con.execute('INSERT INTO tab (a, b) VALUES ($1, $2);', "foo", "abc") - await self.con.execute('SELECT a FROM tab;") - await self.con.execute('SELECT a, b FROM tab;") + await self.con.execute("SELECT a FROM tab;") + await self.con.execute("SELECT a, b FROM tab;") finally: await self.con.execute('''