File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -571,3 +571,33 @@ def point_encoder(point_bytes: bytes) -> str:
571571 )
572572
573573 assert result [0 ]["geo_point" ] == "Just An Example"
574+
575+
576+ async def test_row_factory_query_result (
577+ psql_pool : ConnectionPool ,
578+ table_name : str ,
579+ number_database_records : int ,
580+ ) -> None :
581+ select_result = await psql_pool .execute (
582+ f"SELECT * FROM { table_name } " ,
583+ )
584+
585+ def row_factory (db_result : dict [str , Any ]) -> list [str ]:
586+ return list (db_result .keys ())
587+
588+ as_pydantic = select_result .row_factory (
589+ row_factory = row_factory ,
590+ )
591+ assert len (as_pydantic ) == number_database_records
592+
593+ for single_record in as_pydantic :
594+ assert isinstance (single_record , DefaultPydanticModel )
595+
596+ as_py_class = select_result .as_class (
597+ as_class = DefaultPythonModelClass ,
598+ )
599+
600+ assert len (as_py_class ) == number_database_records
601+
602+ for single_py_record in as_py_class :
603+ assert isinstance (single_py_record , DefaultPythonModelClass )
You can’t perform that action at this time.
0 commit comments