I have tables like this:
#[spacetimedb::table(accessor = product_category, public)]
pub struct ProductCategory {
#[primary_key]
#[auto_inc]
pub id: u64,
#[index(btree)]
pub store_id: u64,
pub name: String,
}
#[spacetimedb::table(accessor = product, public)]
pub struct Product {
#[primary_key]
#[auto_inc]
pub id: u64,
#[index(btree)]
pub store_id: u64,
#[index(btree)]
pub category_id: u64,
pub name: String,
pub description: Option<String>,
pub price: u128,
}
it compile just fine when using spacetime build
but when I spacetime publish it return error:
name product_category_id_idx_btree is used for multiple entities
From what I see its because of the index is generated by {accessor}_{field}_idx_btree, so it output the same product_category_id_idx_btree for both of the table. It's nice if we can specify the name of index with something like
#[index(btree, name="prod_category_id_idx_btree2")]
or maybe even better automagically handle that colliding name in macros
oh, after reading the spactimedb code I see the index name will auto generated with this format:
{table_name}_{cols}_idx_{algo}
maybe the simple fix is to change the separator to be double __:
{table_name}__{cols}_idx_{algo}
or use another character for separator, I don't know, what do you think?
I have tables like this:
it compile just fine when using
spacetime buildbut when I
spacetime publishit return error:name
product_category_id_idx_btreeis used for multiple entitiesFrom what I see its because of the index is generated by {accessor}_{field}_idx_btree, so it output the same product_category_id_idx_btree for both of the table. It's nice if we can specify the name of index with something like
or maybe even better automagically handle that colliding name in macros
oh, after reading the spactimedb code I see the index name will auto generated with this format:
{table_name}_{cols}_idx_{algo}maybe the simple fix is to change the separator to be double __:
{table_name}__{cols}_idx_{algo}or use another character for separator, I don't know, what do you think?