@@ -718,6 +718,36 @@ def test_iter_browse_call_twice(self):
718718
719719
720720class TestPG (UnitTestCase ):
721+ @parametrize (
722+ [
723+ # explicit conversions
724+ ("boolean" , "bool" ),
725+ ("smallint" , "int2" ),
726+ ("integer" , "int4" ),
727+ ("bigint" , "int8" ),
728+ ("real" , "float4" ),
729+ ("double precision" , "float8" ),
730+ ("character varying" , "varchar" ),
731+ ("timestamp with time zone" , "timestamptz" ),
732+ ("timestamp without time zone" , "timestamp" ),
733+ # noop for existing types
734+ ("bool" , "bool" ),
735+ ("int4" , "int4" ),
736+ ("varchar" , "varchar" ),
737+ # and unspecified/unknown types
738+ ("jsonb" , "jsonb" ),
739+ ("foo" , "foo" ),
740+ # keep suffix (for arrays and sized limited varchar)
741+ ("int4[]" , "int4[]" ),
742+ ("varchar(2)" , "varchar(2)" ),
743+ # but also convert types
744+ ("integer[]" , "int4[]" ),
745+ ("character varying(16)" , "varchar(16)" ),
746+ ]
747+ )
748+ def test__normalize_pg_type (self , type_ , expected ):
749+ self .assertEqual (util .pg ._normalize_pg_type (type_ ), expected )
750+
721751 @parametrize (
722752 [
723753 ("res_country" , "name" , False , "jsonb" if util .version_gte ("16.0" ) else "varchar" ), # translated field
0 commit comments