]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Added test to make sure binary minus in client-side binding works ok
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 29 Oct 2020 14:08:37 +0000 (15:08 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 29 Oct 2020 14:08:37 +0000 (15:08 +0100)
tests/types/test_numeric.py

index 8f4d349f635b3bc382d79ad3bcd1885a95cbe8f7..5b7bf193a805265cc64ff087cb500b0ec2d67c5e 100644 (file)
@@ -368,6 +368,15 @@ def test_numeric_as_float(conn, val):
 def test_minus_minus(conn, pgtype):
     cur = conn.cursor()
     cast = f"::{pgtype}" if pgtype is not None else ""
-    cur.execute("select -%%s%s" % cast, [-1])
+    cur.execute(f"select -%s{cast}", [-1])
+    result = cur.fetchone()[0]
+    assert result == 1
+
+
+@pytest.mark.parametrize("pgtype", [None, "float8", "int8", "numeric"])
+def test_minus_minus_quote(conn, pgtype):
+    cur = conn.cursor()
+    cast = f"::{pgtype}" if pgtype is not None else ""
+    cur.execute(sql.SQL("select -{}{}").format(sql.Literal(-1), sql.SQL(cast)))
     result = cur.fetchone()[0]
     assert result == 1