Skip to content

Commit

Permalink
Don't raise an exception on an empty query
Browse files Browse the repository at this point in the history
  • Loading branch information
tlocke committed May 21, 2022
1 parent 4d8f27f commit 857252c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pg8000/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def handle_ERROR_RESPONSE(self, data, context):
context.error = DatabaseError(msg)

def handle_EMPTY_QUERY_RESPONSE(self, data, context):
context.error = DatabaseError("query was empty")
pass

def handle_CLOSE_COMPLETE(self, data, context):
pass
Expand Down
5 changes: 2 additions & 3 deletions test/dbapi/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,9 @@ def test_tpc_prepare(con):
con.tpc_rollback(xid)


# An empty query should raise a ProgrammingError
def test_empty_query(cursor):
with pytest.raises(pg8000.dbapi.DatabaseError):
cursor.execute("")
"""No exception thrown"""
cursor.execute("")


# rolling back when not in a transaction doesn't generate a warning
Expand Down
5 changes: 2 additions & 3 deletions test/legacy/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,9 @@ def test_tpc_prepare(con):
con.tpc_rollback(xid)


# An empty query should raise a ProgrammingError
def test_empty_query(cursor):
with pytest.raises(pg8000.ProgrammingError):
cursor.execute("")
"""No exception raised"""
cursor.execute("")


# rolling back when not in a transaction doesn't generate a warning
Expand Down
5 changes: 2 additions & 3 deletions test/native/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,9 @@ def test_in(con):
assert ret[0][0] == "bool"


# An empty query should raise a ProgrammingError
def test_empty_query(con):
with pytest.raises(DatabaseError):
con.run("")
"""No exception thrown"""
con.run("")


def test_rollback_no_transaction(con):
Expand Down

0 comments on commit 857252c

Please sign in to comment.