11use crate :: ops:: sdk:: * ;
22
33use crate :: fields_value;
4+ use crate :: ops:: shared:: postgres:: get_db_pool;
45use crate :: settings:: DatabaseConnectionSpec ;
56use sqlx:: { Column , PgPool , Row } ;
67
@@ -33,8 +34,6 @@ struct PostgresTableSchema {
3334struct Executor {
3435 db_pool : PgPool ,
3536 table_name : String ,
36- #[ allow( dead_code) ] // Used indirectly during schema discovery, kept for completeness
37- included_columns : Option < Vec < String > > ,
3837 ordinal_column : Option < String > ,
3938 table_schema : PostgresTableSchema ,
4039}
@@ -538,7 +537,7 @@ impl SourceFactoryBase for Factory {
538537 context : & FlowInstanceContext ,
539538 ) -> Result < EnrichedValueType > {
540539 // Fetch table schema to build dynamic output schema
541- let db_pool = create_db_pool ( spec. database . as_ref ( ) , & context. auth_registry ) . await ?;
540+ let db_pool = get_db_pool ( spec. database . as_ref ( ) , & context. auth_registry ) . await ?;
542541 let table_schema =
543542 fetch_table_schema ( & db_pool, & spec. table_name , & spec. included_columns ) . await ?;
544543
@@ -613,7 +612,7 @@ impl SourceFactoryBase for Factory {
613612 spec : Spec ,
614613 context : Arc < FlowInstanceContext > ,
615614 ) -> Result < Box < dyn SourceExecutor > > {
616- let db_pool = create_db_pool ( spec. database . as_ref ( ) , & context. auth_registry ) . await ?;
615+ let db_pool = get_db_pool ( spec. database . as_ref ( ) , & context. auth_registry ) . await ?;
617616
618617 // Fetch table schema for dynamic type handling
619618 let table_schema =
@@ -622,7 +621,6 @@ impl SourceFactoryBase for Factory {
622621 let executor = Executor {
623622 db_pool,
624623 table_name : spec. table_name . clone ( ) ,
625- included_columns : spec. included_columns . clone ( ) ,
626624 ordinal_column : spec. ordinal_column . clone ( ) ,
627625 table_schema,
628626 } ;
@@ -643,20 +641,3 @@ impl SourceFactoryBase for Factory {
643641 Ok ( Box :: new ( executor) )
644642 }
645643}
646-
647- /// Create a PostgreSQL connection pool (reused from postgres target)
648- async fn create_db_pool (
649- db_ref : Option < & spec:: AuthEntryReference < DatabaseConnectionSpec > > ,
650- auth_registry : & AuthRegistry ,
651- ) -> Result < PgPool > {
652- let lib_context = crate :: lib_context:: get_lib_context ( ) ?;
653- let db_conn_spec = db_ref
654- . as_ref ( )
655- . map ( |db_ref| auth_registry. get ( db_ref) )
656- . transpose ( ) ?;
657- let db_pool = match db_conn_spec {
658- Some ( db_conn_spec) => lib_context. db_pools . get_pool ( & db_conn_spec) . await ?,
659- None => lib_context. require_builtin_db_pool ( ) ?. clone ( ) ,
660- } ;
661- Ok ( db_pool)
662- }
0 commit comments