mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 18:33:44 +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
|
||||
-------------------------
|
||||
|
||||
|
|
|
@ -1359,6 +1359,13 @@ pq_fetch(cursorObject *curs)
|
|||
/* don't clear curs->pgres, because it contains the results! */
|
||||
break;
|
||||
|
||||
case PGRES_EMPTY_QUERY:
|
||||
PyErr_SetString(ProgrammingError,
|
||||
"can't execute an empty query");
|
||||
IFCLEARPGRES(curs->pgres);
|
||||
ex = -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
Dprintf("pq_fetch: uh-oh, something FAILED: pgconn = %p", curs->conn);
|
||||
pq_raise(curs->conn, curs, NULL);
|
||||
|
|
|
@ -37,6 +37,12 @@ class CursorTests(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
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):
|
||||
conn = self.conn
|
||||
cur = conn.cursor()
|
||||
|
|
Loading…
Reference in New Issue
Block a user