File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -669,10 +669,23 @@ def get_table_model(
669669 f'Could not connect to { repr (engine .url )} (password hidden).'
670670 )
671671 except InvalidRequestError :
672- raise ProviderQueryError (
672+ msg = (
673673 f"Table '{ table_name } ' not found in schema '{ schema } ' "
674674 f'on { repr (engine .url )} .'
675675 )
676+ LOGGER .error (msg )
677+
678+ if len (db_search_path ) > 1 :
679+ # If the table is not found in the first schema, try the next one
680+ return get_table_model (
681+ table_name ,
682+ id_field ,
683+ db_search_path [1 :],
684+ engine
685+ )
686+ else :
687+ # If the table is not found in any schema, raise an error
688+ raise ProviderQueryError (msg )
676689
677690 # Create SQLAlchemy model from reflected table
678691 # It is necessary to add the primary key constraint because SQLAlchemy
Original file line number Diff line number Diff line change @@ -151,6 +151,15 @@ def test_valid_connection_options(config):
151151 'keepalives_interval' ]
152152
153153
154+ def test_schema_path_search (config ):
155+ config ['data' ]['search_path' ] = ['public' , 'osm' ]
156+ PostgreSQLProvider (config )
157+
158+ config ['data' ]['search_path' ] = ['public' , 'notosm' ]
159+ with pytest .raises (ProviderQueryError ):
160+ PostgreSQLProvider (config )
161+
162+
154163def test_query (config ):
155164 """Testing query for a valid JSON object with geometry"""
156165 p = PostgreSQLProvider (config )
You can’t perform that action at this time.
0 commit comments