From: Daniele Varrazzo Date: Thu, 29 Oct 2020 14:08:37 +0000 (+0100) Subject: Added test to make sure binary minus in client-side binding works ok X-Git-Tag: 3.0.dev0~413 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bab84302c1fccdab5ae112d46317d75b861e0cbe;p=thirdparty%2Fpsycopg.git Added test to make sure binary minus in client-side binding works ok --- diff --git a/tests/types/test_numeric.py b/tests/types/test_numeric.py index 8f4d349f6..5b7bf193a 100644 --- a/tests/types/test_numeric.py +++ b/tests/types/test_numeric.py @@ -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