@@ -769,6 +769,92 @@ def test_postgres_types_cursor(postgres_url: str) -> None:
769769 assert_frame_equal (df , expected , check_names = True )
770770
771771
772+ def test_types_simple (postgres_url : str ) -> None :
773+ query = "SELECT test_date, test_timestamp, test_timestamptz, test_int16, test_int64, test_float32, test_numeric, test_bpchar, test_char, test_varchar, test_uuid, test_time, test_bytea, test_enum, test_f4array, test_f8array, test_narray, test_i2array, test_i4array, test_i8array FROM test_types"
774+ df = read_sql (postgres_url , query , protocol = "simple" )
775+ expected = pd .DataFrame (
776+ index = range (4 ),
777+ data = {
778+ "test_date" : pd .Series (
779+ ["1970-01-01" , "2000-02-28" , "2038-01-18" , None ], dtype = "datetime64[ns]"
780+ ),
781+ "test_timestamp" : pd .Series (
782+ [
783+ "1970-01-01 00:00:01" ,
784+ "2000-02-28 12:00:10" ,
785+ "2038-01-18 23:59:59" ,
786+ None ,
787+ ],
788+ dtype = "datetime64[ns]" ,
789+ ),
790+ "test_timestamptz" : pd .Series (
791+ [
792+ "1970-01-01 00:00:01" ,
793+ "2000-02-28 16:00:10" ,
794+ "2038-01-18 15:59:59" ,
795+ None ,
796+ ],
797+ dtype = "datetime64[ns]" ,
798+ ),
799+ "test_int16" : pd .Series ([0 , 1 , 2 , 3 ], dtype = "Int64" ),
800+ "test_int64" : pd .Series (
801+ [- 9223372036854775808 , 0 , 9223372036854775807 , None ], dtype = "Int64"
802+ ),
803+ "test_float32" : pd .Series (
804+ [None , 3.1415926535 , 2.71 , - 1e-37 ], dtype = "float64"
805+ ),
806+ "test_numeric" : pd .Series ([None , 521.34 , 999.99 , 0.00 ], dtype = "float64" ),
807+ "test_bpchar" : pd .Series (["a " , "bb " , "ccc " , None ], dtype = "object" ),
808+ "test_char" : pd .Series (["a" , "b" , None , "d" ], dtype = "object" ),
809+ "test_varchar" : pd .Series ([None , "bb" , "c" , "defghijklm" ], dtype = "object" ),
810+ "test_uuid" : pd .Series (
811+ [
812+ "86b494cc-96b2-11eb-9298-3e22fbb9fe9d" ,
813+ "86b49b84-96b2-11eb-9298-3e22fbb9fe9d" ,
814+ "86b49c42-96b2-11eb-9298-3e22fbb9fe9d" ,
815+ None ,
816+ ],
817+ dtype = "object" ,
818+ ),
819+ "test_time" : pd .Series (
820+ ["08:12:40" , None , "23:00:10" , "18:30:00" ], dtype = "object"
821+ ),
822+ "test_bytea" : pd .Series (
823+ [
824+ None ,
825+ b"\xd0 \x97 \xd0 \xb4 \xd1 \x80 \xd0 \xb0 \xcc \x81 \xd0 \xb2 \xd1 \x81 \xd1 \x82 \xd0 \xb2 \xd1 \x83 \xd0 \xb9 \xd1 \x82 \xd0 \xb5 " ,
826+ b"" ,
827+ b"\xf0 \x9f \x98 \x9c " ,
828+ ],
829+ dtype = "object" ,
830+ ),
831+ "test_enum" : pd .Series (
832+ ["happy" , "very happy" , "ecstatic" , None ], dtype = "object"
833+ ),
834+ "test_f4array" : pd .Series (
835+ [[], None , [123.123 ], [- 1e-37 , 1e37 ]], dtype = "object"
836+ ),
837+ "test_f8array" : pd .Series (
838+ [[], None , [1e-307 , 1e308 ], [0.000234 , - 12.987654321 ]], dtype = "object"
839+ ),
840+ "test_narray" : pd .Series (
841+ [[], None , [521.34 ], [0.12 , 333.33 , 22.22 ]], dtype = "object"
842+ ),
843+ "test_i2array" : pd .Series (
844+ [[- 1 , 0 , 1 ], [], [- 32768 , 32767 ], None ], dtype = "object"
845+ ),
846+ "test_i4array" : pd .Series (
847+ [[- 1 , 0 , 1123 ], [], [- 2147483648 , 2147483647 ], None ], dtype = "object"
848+ ),
849+ "test_i8array" : pd .Series (
850+ [[- 9223372036854775808 , 9223372036854775807 ], [], [0 ], None ],
851+ dtype = "object" ,
852+ ),
853+ },
854+ )
855+ assert_frame_equal (df , expected , check_names = True )
856+
857+
772858def test_empty_result (postgres_url : str ) -> None :
773859 query = "SELECT * FROM test_table where test_int < -100"
774860 df = read_sql (postgres_url , query )
0 commit comments