mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
parent
f1d69f6dec
commit
fcbe0466a6
6
NEWS
6
NEWS
|
@ -1,3 +1,9 @@
|
||||||
|
What's new in psycopg 2.4.1
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
- Correctly detect an empty query sent to the backend (ticket #46).
|
||||||
|
|
||||||
|
|
||||||
What's new in psycopg 2.4
|
What's new in psycopg 2.4
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
|
|
@ -1359,6 +1359,13 @@ pq_fetch(cursorObject *curs)
|
||||||
/* don't clear curs->pgres, because it contains the results! */
|
/* don't clear curs->pgres, because it contains the results! */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PGRES_EMPTY_QUERY:
|
||||||
|
PyErr_SetString(ProgrammingError,
|
||||||
|
"can't execute an empty query");
|
||||||
|
IFCLEARPGRES(curs->pgres);
|
||||||
|
ex = -1;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Dprintf("pq_fetch: uh-oh, something FAILED: pgconn = %p", curs->conn);
|
Dprintf("pq_fetch: uh-oh, something FAILED: pgconn = %p", curs->conn);
|
||||||
pq_raise(curs->conn, curs, NULL);
|
pq_raise(curs->conn, curs, NULL);
|
||||||
|
|
|
@ -37,6 +37,12 @@ class CursorTests(unittest.TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
|
|
||||||
|
def test_empty_query(self):
|
||||||
|
cur = self.conn.cursor()
|
||||||
|
self.assertRaises(psycopg2.ProgrammingError, cur.execute, "")
|
||||||
|
self.assertRaises(psycopg2.ProgrammingError, cur.execute, " ")
|
||||||
|
self.assertRaises(psycopg2.ProgrammingError, cur.execute, ";")
|
||||||
|
|
||||||
def test_executemany_propagate_exceptions(self):
|
def test_executemany_propagate_exceptions(self):
|
||||||
conn = self.conn
|
conn = self.conn
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user