Skip to content

Commit c899270

Browse files
committed
fix index arg
1 parent ed568f9 commit c899270

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

crates/lib/src/db/raw_def/v10.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,14 @@ pub struct RawIndexDefV10 {
350350
/// Even though there is ABSOLUTELY NO REASON TO.
351351
pub source_name: Option<RawIdentifier>,
352352

353-
/// Accessor name for the index used in client codegen.
353+
/// name for the index used internally and in client codegen
354354
///
355355
/// This is set the user and should not be assumed to follow
356356
/// any particular format.
357357
///
358358
/// May be set to `None` if this is an auto-generated index for which the user
359-
/// has not supplied a name. In this case, no client code generation for this index
360-
/// will be performed.
361-
///
362-
/// This name is not visible in the system tables, it is only used for client codegen.
363-
pub accessor_name: Option<RawIdentifier>,
359+
/// has not supplied a name.
360+
pub name: Option<RawIdentifier>,
364361

365362
/// The algorithm parameters for the index.
366363
pub algorithm: RawIndexAlgorithm,
@@ -1140,8 +1137,8 @@ impl RawTableDefBuilderV10<'_> {
11401137
let accessor_name = accessor_name.into();
11411138

11421139
self.table.indexes.push(RawIndexDefV10 {
1143-
source_name: index_name.map(Into::into),
1144-
accessor_name: Some(accessor_name),
1140+
name: index_name.map(Into::into),
1141+
source_name: Some(accessor_name),
11451142
algorithm,
11461143
});
11471144
self
@@ -1151,7 +1148,7 @@ impl RawTableDefBuilderV10<'_> {
11511148
pub fn with_index_no_accessor_name(mut self, algorithm: RawIndexAlgorithm) -> Self {
11521149
self.table.indexes.push(RawIndexDefV10 {
11531150
source_name: None,
1154-
accessor_name: None,
1151+
name: None,
11551152
algorithm,
11561153
});
11571154
self

crates/lib/src/db/raw_def/v9.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,8 @@ impl From<RawScopedTypeNameV10> for RawScopedTypeNameV9 {
10741074
impl From<RawIndexDefV10> for RawIndexDefV9 {
10751075
fn from(raw: RawIndexDefV10) -> Self {
10761076
RawIndexDefV9 {
1077-
name: raw.source_name,
1078-
accessor_name: raw.accessor_name,
1077+
accessor_name: raw.source_name,
1078+
name: raw.name,
10791079
algorithm: raw.algorithm,
10801080
}
10811081
}

crates/schema/src/def/validate/v10.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -867,17 +867,17 @@ mod tests {
867867
[
868868
&IndexDef {
869869
name: "Apples_count_idx_direct".into(),
870-
codegen_name: Some(expect_identifier("Apples_count_direct")),
870+
codegen_name: Some(expect_identifier("Apples_count_idx_direct")),
871871
algorithm: DirectAlgorithm { column: 2.into() }.into(),
872872
},
873873
&IndexDef {
874874
name: "Apples_name_count_idx_btree".into(),
875-
codegen_name: Some(expect_identifier("apples_id")),
875+
codegen_name: Some(expect_identifier("Apples_name_count_idx_btree")),
876876
algorithm: BTreeAlgorithm { columns: [1, 2].into() }.into(),
877877
},
878878
&IndexDef {
879879
name: "Apples_type_idx_btree".into(),
880-
codegen_name: Some(expect_identifier("Apples_type_btree")),
880+
codegen_name: Some(expect_identifier("Apples_type_idx_btree")),
881881
algorithm: BTreeAlgorithm { columns: 3.into() }.into(),
882882
}
883883
]
@@ -1463,7 +1463,7 @@ mod tests {
14631463
let mut raw_def = builder.finish();
14641464
let tables = raw_def.tables_mut_for_tests();
14651465
tables[0].constraints[0].source_name = Some("wacky.constraint()".into());
1466-
tables[0].indexes[0].source_name = Some("wacky.index()".into());
1466+
tables[0].indexes[0].name = Some("wacky.index()".into());
14671467
tables[0].sequences[0].source_name = Some("wacky.sequence()".into());
14681468

14691469
let def: ModuleDef = raw_def.try_into().unwrap();

0 commit comments

Comments
 (0)