(self, conn, name)
| 403 | @pytest.mark.crdb_skip("composite") # create type, actually |
| 404 | @pytest.mark.parametrize("name", ["a-b", f"{eur}", "order", "foo bar", "FooBar"]) |
| 405 | def test_invalid_name(self, conn, name): |
| 406 | if conn.info.parameter_status("is_superuser") != "on": |
| 407 | pytest.skip("not a superuser") |
| 408 | conn.execute(f""" |
| 409 | set client_encoding to utf8; |
| 410 | create type "{name}"; |
| 411 | create function invin(cstring) returns "{name}" |
| 412 | language internal immutable strict as 'textin'; |
| 413 | create function invout("{name}") returns cstring |
| 414 | language internal immutable strict as 'textout'; |
| 415 | create type "{name}" (input=invin, output=invout, like=text); |
| 416 | """) |
| 417 | info = TypeInfo.fetch(conn, f'"{name}"') |
| 418 | |
| 419 | class InvDumper(StrDumper): |
| 420 | oid = info.oid |
| 421 | |
| 422 | def dump(self, obj): |
| 423 | rv = super().dump(obj) |
| 424 | return b"%s-inv" % rv |
| 425 | |
| 426 | info.register(conn) |
| 427 | conn.adapters.register_dumper(str, InvDumper) |
| 428 | |
| 429 | assert sql.Literal("hello").as_string(conn) == f"'hello-inv'::\"{name}\"" |
| 430 | cur = conn.execute(sql.SQL("select {}").format("hello")) |
| 431 | assert cur.fetchone()[0] == "hello-inv" |
| 432 | |
| 433 | assert ( |
| 434 | sql.Literal(["hello"]).as_string(conn) == f"'{{hello-inv}}'::\"{name}\"[]" |
| 435 | ) |
| 436 | cur = conn.execute(sql.SQL("select {}").format(["hello"])) |
| 437 | assert cur.fetchone()[0] == ["hello-inv"] |
| 438 | |
| 439 | |
| 440 | class TestSQL: |
nothing calls this directly
no test coverage detected