@@ -3,6 +3,7 @@ use common::{
3
3
components:: {
4
4
CanonicalizedComponentFunctionPath ,
5
5
ComponentFunctionPath ,
6
+ ComponentId ,
6
7
ComponentPath ,
7
8
} ,
8
9
errors:: JsError ,
@@ -24,6 +25,7 @@ use common::{
24
25
} ;
25
26
use database:: {
26
27
unauthorized_error,
28
+ BootstrapComponentsModel ,
27
29
Transaction ,
28
30
} ;
29
31
use errors:: ErrorMetadata ;
@@ -56,7 +58,6 @@ use value::{
56
58
ConvexArray ,
57
59
ConvexValue ,
58
60
NamespacedTableMapping ,
59
- TableNamespace ,
60
61
VirtualTableMapping ,
61
62
} ;
62
63
@@ -146,11 +147,10 @@ fn missing_or_internal_error(path: &CanonicalizedComponentFunctionPath) -> anyho
146
147
147
148
async fn udf_version < RT : Runtime > (
148
149
path : & CanonicalizedComponentFunctionPath ,
150
+ component : ComponentId ,
149
151
tx : & mut Transaction < RT > ,
150
152
) -> anyhow:: Result < Result < Version , JsError > > {
151
- let udf_config = UdfConfigModel :: new ( tx, TableNamespace :: TODO ( ) )
152
- . get ( )
153
- . await ?;
153
+ let udf_config = UdfConfigModel :: new ( tx, component. into ( ) ) . get ( ) . await ?;
154
154
155
155
let udf_version = match udf_config {
156
156
Some ( udf_config) if udf_config. server_version > DEPRECATION_THRESHOLD . npm . unsupported => {
@@ -259,6 +259,10 @@ impl ValidatedPathAndArgs {
259
259
return Ok ( result) ;
260
260
}
261
261
262
+ let ( _, component) = BootstrapComponentsModel :: new ( tx)
263
+ . component_path_to_ids ( path. component . clone ( ) )
264
+ . await ?;
265
+
262
266
let mut backend_state_model = BackendStateModel :: new ( tx) ;
263
267
let backend_state = backend_state_model. get_backend_state ( ) . await ?;
264
268
match backend_state {
@@ -273,7 +277,7 @@ impl ValidatedPathAndArgs {
273
277
} ,
274
278
}
275
279
276
- let udf_version = match udf_version ( & path, tx) . await ? {
280
+ let udf_version = match udf_version ( & path, component , tx) . await ? {
277
281
Ok ( udf_version) => udf_version,
278
282
Err ( e) => return Ok ( Err ( e) ) ,
279
283
} ;
@@ -289,6 +293,7 @@ impl ValidatedPathAndArgs {
289
293
allowed_visibility,
290
294
tx,
291
295
path,
296
+ component,
292
297
args,
293
298
expected_udf_type,
294
299
analyzed_function,
@@ -338,7 +343,11 @@ impl ValidatedPathAndArgs {
338
343
} ,
339
344
}
340
345
341
- let udf_version = match udf_version ( & path, tx) . await ? {
346
+ let ( _, component) = BootstrapComponentsModel :: new ( tx)
347
+ . component_path_to_ids ( path. component . clone ( ) )
348
+ . await ?;
349
+
350
+ let udf_version = match udf_version ( & path, component, tx) . await ? {
342
351
Ok ( udf_version) => udf_version,
343
352
Err ( e) => return Ok ( Err ( e) ) ,
344
353
} ;
@@ -362,6 +371,7 @@ impl ValidatedPathAndArgs {
362
371
allowed_visibility,
363
372
tx,
364
373
path,
374
+ component,
365
375
args,
366
376
expected_udf_type,
367
377
analyzed_function,
@@ -378,6 +388,7 @@ impl ValidatedPathAndArgs {
378
388
allowed_visibility : AllowedVisibility ,
379
389
tx : & mut Transaction < RT > ,
380
390
path : CanonicalizedComponentFunctionPath ,
391
+ component : ComponentId ,
381
392
args : ConvexArray ,
382
393
expected_udf_type : UdfType ,
383
394
analyzed_function : AnalyzedFunction ,
@@ -420,9 +431,7 @@ impl ValidatedPathAndArgs {
420
431
Err ( err) => return Ok ( Err ( err) ) ,
421
432
}
422
433
423
- let table_mapping = & tx
424
- . table_mapping ( )
425
- . namespace ( TableNamespace :: by_component_TODO ( ) ) ;
434
+ let table_mapping = & tx. table_mapping ( ) . namespace ( component. into ( ) ) ;
426
435
let virtual_table_mapping = & tx. virtual_table_mapping ( ) . clone ( ) ;
427
436
428
437
// If the UDF has an args validator, check that these args match.
@@ -565,7 +574,10 @@ impl ValidatedHttpPath {
565
574
. fail_while_paused_or_disabled ( )
566
575
. await ?;
567
576
}
568
- let udf_version = match udf_version ( & path, tx) . await ? {
577
+ let ( _, component) = BootstrapComponentsModel :: new ( tx)
578
+ . component_path_to_ids ( path. component . clone ( ) )
579
+ . await ?;
580
+ let udf_version = match udf_version ( & path, component, tx) . await ? {
569
581
Ok ( udf_version) => udf_version,
570
582
Err ( e) => return Ok ( Err ( e) ) ,
571
583
} ;
0 commit comments