Skip to content

Commit a15ee42

Browse files
emmaling27Convex, Inc.
authored and
Convex, Inc.
committed
Clean up some ComponentId::TODOs and TableNameSpace::TODOs (#28790)
Cleans up some `ComponentId::TODO`s and `TableNamespace::TODO`s. These should just be root because they are not in APIs used for components. GitOrigin-RevId: f98036bba895f0f1582bab090c8290cf5e1d474f
1 parent d1a3d54 commit a15ee42

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

crates/application/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ impl<RT: Runtime> Application<RT> {
17891789
parse_schema_id(
17901790
&schema_id,
17911791
tx.table_mapping(),
1792-
TableNamespace::by_component_TODO(),
1792+
TableNamespace::root_component(),
17931793
)
17941794
.context(invalid_schema_id(&schema_id))
17951795
})
@@ -1806,7 +1806,7 @@ impl<RT: Runtime> Application<RT> {
18061806

18071807
let config_metadata = ConfigMetadata::from_file(config_file, auth_providers);
18081808

1809-
let (config_diff, schema) = ConfigModel::new(tx, ComponentId::TODO())
1809+
let (config_diff, schema) = ConfigModel::new(tx, ComponentId::Root)
18101810
.apply(
18111811
config_metadata.clone(),
18121812
modules,

crates/isolate/src/tests/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async fn test_analyze_module(rt: TestRuntime) -> anyhow::Result<()> {
5757
let has_http = {
5858
let mut tx = t.database.begin(Identity::system()).await?;
5959
ModuleModel::new(&mut tx)
60-
.has_http(ComponentId::TODO())
60+
.has_http(ComponentId::test_user())
6161
.await?
6262
};
6363
assert!(has_http);

crates/local_backend/src/deploy_config.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ pub async fn get_config(
225225
.await?;
226226

227227
let mut tx = st.application.begin(identity).await?;
228-
let (config, modules, udf_config) = ConfigModel::new(&mut tx, ComponentId::TODO())
228+
let component = ComponentId::Root; // This endpoint is only used pre-components.
229+
let (config, modules, udf_config) = ConfigModel::new(&mut tx, component)
229230
.get_with_module_source(st.application.modules_cache())
230231
.await?;
231232
let config = ConvexObject::try_from(config)?;
@@ -255,7 +256,8 @@ pub async fn get_config_hashes(
255256
.await?;
256257

257258
let mut tx = st.application.begin(identity).await?;
258-
let (config, modules, udf_config) = ConfigModel::new(&mut tx, ComponentId::TODO())
259+
let component = ComponentId::Root; // This endpoint is not used in components push.
260+
let (config, modules, udf_config) = ConfigModel::new(&mut tx, component)
259261
.get_with_module_metadata()
260262
.await?;
261263
let module_hashes: Vec<_> = modules

crates/local_backend/src/schema.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ pub async fn prepare_schema(
247247
Json(req): Json<PrepareSchemaArgs>,
248248
) -> Result<Json<PrepareSchemaResponse>, HttpResponseError> {
249249
let (response, _) = prepare_schema_handler(st, req).await?;
250-
251250
Ok(response)
252251
}
253252

@@ -271,21 +270,24 @@ pub async fn prepare_schema_handler(
271270

272271
let dry_run = req.dry_run.unwrap_or(true);
273272

273+
// Table namespace is root because this endpoint is only used in non-components
274+
// push.
275+
let table_namespace = TableNamespace::root_component();
274276
// In dry_run we only commit the schema, to enable CLI to check if the schema is
275277
// valid.
276278
let index_diff: LegacyIndexDiff = if dry_run {
277279
let mut tx = st.application.begin(identity.clone()).await?;
278280
IndexModel::new(&mut tx)
279-
.prepare_new_and_mutated_indexes(TableNamespace::by_component_TODO(), &schema)
281+
.prepare_new_and_mutated_indexes(table_namespace, &schema)
280282
.await?
281283
} else {
282284
IndexModel::new(&mut tx)
283-
.prepare_new_and_mutated_indexes(TableNamespace::by_component_TODO(), &schema)
285+
.prepare_new_and_mutated_indexes(table_namespace, &schema)
284286
.await?
285287
}
286288
.into();
287289

288-
let (schema_id, schema_state) = SchemaModel::new(&mut tx, TableNamespace::by_component_TODO())
290+
let (schema_id, schema_state) = SchemaModel::new(&mut tx, table_namespace)
289291
.submit_pending(schema)
290292
.await?;
291293
let should_save_new_schema = match schema_state {
@@ -359,10 +361,12 @@ pub async fn schema_state(
359361
) -> Result<impl IntoResponse, HttpResponseError> {
360362
must_be_admin(&identity)?;
361363
let mut tx = st.application.begin(identity.clone()).await?;
364+
// This endpoint is only used in non-components push.
365+
let table_namespace = TableNamespace::root_component();
362366
let indexes = IndexModel::new(&mut tx)
363-
.get_application_indexes(TableNamespace::TODO())
367+
.get_application_indexes(table_namespace)
364368
.await?;
365-
let schema_id = parse_schema_id(&schema_id, tx.table_mapping(), TableNamespace::TODO())
369+
let schema_id = parse_schema_id(&schema_id, tx.table_mapping(), table_namespace)
366370
.context(invalid_schema_id(&schema_id))?;
367371

368372
let doc = tx.get(schema_id).await?.ok_or_else(|| {

0 commit comments

Comments
 (0)