@@ -174,6 +174,51 @@ func runAutocompleteTests(t *testing.T, facet autocompleteFacet, setupFunc func(
174174 require .Len (t , resp .Data , 1 )
175175 require .Equal (t , "alpha_task" , * resp .Data [0 ])
176176 })
177+
178+ t .Run ("WithNonDefaultSchema" , func (t * testing.T ) {
179+ t .Parallel ()
180+
181+ var (
182+ logger = riversharedtest .Logger (t )
183+ driver = riverpgxv5 .New (riversharedtest .DBPool (ctx , t ))
184+ )
185+
186+ // DisableSchemaSharing is required because we need the schema name to configure the River client.
187+ tx , schema := riverdbtest .TestTxPgxDriver (ctx , t , driver , & riverdbtest.TestTxOpts {DisableSchemaSharing : true })
188+ exec := driver .UnwrapExecutor (tx )
189+
190+ client , err := river .NewClient (driver , & river.Config {
191+ Logger : logger ,
192+ Schema : schema ,
193+ })
194+ require .NoError (t , err )
195+
196+ endpoint := newAutocompleteListEndpoint (apibundle.APIBundle [pgx.Tx ]{
197+ Archetype : riversharedtest .BaseServiceArchetype (t ),
198+ Client : client ,
199+ DB : exec ,
200+ Driver : driver ,
201+ Extensions : func (_ context.Context ) (map [string ]bool , error ) { return map [string ]bool {}, nil },
202+ Logger : logger ,
203+ })
204+
205+ setupFunc (t , & setupEndpointTestBundle {client : client , exec : exec , logger : logger , tx : tx })
206+
207+ // Reset search_path to simulate production conditions where the connection
208+ // doesn't include the River schema; unqualified table names would then fail.
209+ _ , err = tx .Exec (ctx , "SET search_path TO 'public'" )
210+ require .NoError (t , err )
211+
212+ resp , err := apitest .InvokeHandler (ctx , endpoint .Execute , testMountOpts (t ), & autocompleteListRequest {
213+ Facet : facet ,
214+ })
215+ require .NoError (t , err )
216+ require .Len (t , resp .Data , 4 )
217+ require .Equal (t , "alpha_" + facet .baseString (), * resp .Data [0 ])
218+ require .Equal (t , "alpha_task" , * resp .Data [1 ])
219+ require .Equal (t , "beta_" + facet .baseString (), * resp .Data [2 ])
220+ require .Equal (t , "gamma_" + facet .baseString (), * resp .Data [3 ])
221+ })
177222}
178223
179224func (f autocompleteFacet ) baseString () string {
0 commit comments