Skip to content

Commit e0fb227

Browse files
committed
lints
1 parent 15ede7f commit e0fb227

11 files changed

Lines changed: 78 additions & 97 deletions

File tree

crates/bench/src/spacetime_raw.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ impl BenchDatabase for SpacetimeRaw {
5656
index_algorithm: IndexAlgorithm::BTree(BTreeAlgorithm {
5757
columns: ColId(0).into(),
5858
}),
59+
alias: None,
5960
},
6061
true,
6162
)?;
@@ -72,6 +73,7 @@ impl BenchDatabase for SpacetimeRaw {
7273
index_algorithm: IndexAlgorithm::BTree(BTreeAlgorithm {
7374
columns: ColId(i as _).into(),
7475
}),
76+
alias: None,
7577
},
7678
false,
7779
)?;

crates/bindings-macro/src/table.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::sats;
22
use crate::sym;
3-
use crate::util::{check_duplicate, check_duplicate_msg, ident_to_litstr, match_meta};
3+
use crate::util::{check_duplicate, check_duplicate_msg, match_meta};
44
use core::slice;
55
use heck::ToSnakeCase;
66
use proc_macro2::{Span, TokenStream};
@@ -55,7 +55,7 @@ struct IndexArg {
5555
}
5656

5757
impl IndexArg {
58-
fn inline(accessor: Ident, kind: IndexType) -> Self {
58+
fn new(accessor: Ident, kind: IndexType) -> Self {
5959
// We don't know if its unique yet.
6060
// We'll discover this once we have collected constraints.
6161
let is_unique = false;
@@ -66,14 +66,6 @@ impl IndexArg {
6666
// name,
6767
}
6868
}
69-
fn explicit(accessor: Ident, kind: IndexType) -> Self {
70-
Self {
71-
accessor,
72-
is_unique: false,
73-
kind,
74-
// name: None,
75-
}
76-
}
7769
}
7870

7971
enum IndexType {
@@ -214,7 +206,7 @@ impl IndexArg {
214206
)
215207
})?;
216208

217-
Ok(IndexArg::explicit(accessor, kind))
209+
Ok(IndexArg::new(accessor, kind))
218210
}
219211

220212
fn parse_columns(meta: &ParseNestedMeta) -> syn::Result<Option<Vec<Ident>>> {
@@ -305,7 +297,7 @@ impl IndexArg {
305297

306298
// Default accessor = field name if not provided
307299
let accessor = field.clone();
308-
Ok(IndexArg::inline(accessor, kind))
300+
Ok(IndexArg::new(accessor, kind))
309301
}
310302

311303
fn validate<'a>(&'a self, table_name: &str, cols: &'a [Column<'a>]) -> syn::Result<ValidatedIndex<'a>> {

crates/bindings-typescript/src/lib/table.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -458,17 +458,17 @@ export function table<Row extends RowObj, const Opts extends TableOpts<Row>>(
458458
row.typeName = toPascalCase(tableName);
459459
}
460460

461-
// Build index source names using accName
462-
for (const index of indexes) {
463-
const cols =
464-
index.algorithm.tag === 'Direct'
465-
? [index.algorithm.value]
466-
: index.algorithm.value;
467-
468-
const colS = cols.map(i => colNameList[i]).join('_');
469-
index.sourceName = `${accName}_${colS}_idx_${index.algorithm.tag.toLowerCase()}`;
470-
}
471-
461+
// Build index source names using accName
462+
for (const index of indexes) {
463+
const cols =
464+
index.algorithm.tag === 'Direct'
465+
? [index.algorithm.value]
466+
: index.algorithm.value;
467+
468+
const colS = cols.map(i => colNameList[i]).join('_');
469+
index.sourceName = `${accName}_${colS}_idx_${index.algorithm.tag.toLowerCase()}`;
470+
}
471+
472472
return {
473473
sourceName: accName,
474474
productTypeRef: ctx.registerTypesRecursively(row).ref,

crates/bindings-typescript/src/server/schema.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,14 +541,14 @@ export function schema<const H extends Record<string, UntypedTableSchema>>(
541541
});
542542
}
543543
if (table.tableName) {
544-
ctx.moduleDef.explicitNames.entries.push ({
545-
tag: "Table",
546-
value: {
547-
sourceName: accName,
548-
canonicalName: table.tableName,
549-
}
550-
})
551-
}
544+
ctx.moduleDef.explicitNames.entries.push({
545+
tag: 'Table',
546+
value: {
547+
sourceName: accName,
548+
canonicalName: table.tableName,
549+
},
550+
});
551+
}
552552
}
553553
return { tables: tableSchemas } as TablesToSchema<H>;
554554
});

crates/bindings-typescript/src/server/views.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,15 @@ export function registerView<
163163
returnType,
164164
});
165165

166-
if (opts.name != null) {
167-
ctx.moduleDef.explicitNames.entries.push({
168-
tag: "Function",
169-
value: {
170-
sourceName: exportName,
171-
canonicalName: opts.name
172-
}
173-
})
174-
}
166+
if (opts.name != null) {
167+
ctx.moduleDef.explicitNames.entries.push({
168+
tag: 'Function',
169+
value: {
170+
sourceName: exportName,
171+
canonicalName: opts.name,
172+
},
173+
});
174+
}
175175

176176
// If it is an option, we wrap the function to make the return look like an array.
177177
if (returnType.tag == 'Sum') {

crates/core/src/db/relational_db.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,8 +1257,6 @@ impl RelationalDB {
12571257
.map(|s| s.as_str())
12581258
.unwrap_or(table_name);
12591259

1260-
println!("replaced table name {table_name} with {new_table}");
1261-
12621260
Ok(self.inner.table_id_from_name_mut_tx(tx, new_table)?)
12631261
}
12641262

@@ -1270,8 +1268,6 @@ impl RelationalDB {
12701268
.map(|s| s.as_str())
12711269
.unwrap_or(table_name);
12721270

1273-
println!("replaced table name {table_name} with {new_table}");
1274-
12751271
Ok(self.inner.table_id_from_name_tx(tx, new_table)?)
12761272
}
12771273

@@ -1303,8 +1299,6 @@ impl RelationalDB {
13031299
.map(|s| s.as_str())
13041300
.unwrap_or(index_name);
13051301

1306-
println!("replaced index name {index_name} with {new_index_name}");
1307-
13081302
Ok(self.inner.index_id_from_name_mut_tx(tx, new_index_name)?)
13091303
}
13101304

crates/datastore/src/locking_tx_datastore/datastore.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,7 @@ mod tests {
14851485
col_pos: value.pos.into(),
14861486
col_name: Identifier::for_test(value.name),
14871487
col_type: value.ty,
1488+
alias: None,
14881489
}
14891490
}
14901491
}
@@ -2108,6 +2109,7 @@ mod tests {
21082109
table_id,
21092110
index_name: "Foo_id_idx_btree".into(),
21102111
index_algorithm: BTreeAlgorithm::from(0).into(),
2112+
alias: None,
21112113
},
21122114
true,
21132115
)?;
@@ -2349,6 +2351,7 @@ mod tests {
23492351
table_id,
23502352
index_name: "Foo_age_idx_btree".into(),
23512353
index_algorithm: BTreeAlgorithm::from(2).into(),
2354+
alias: None,
23522355
};
23532356
// TODO: it's slightly incorrect to create an index with `is_unique: true` without creating a corresponding constraint.
23542357
// But the `Table` crate allows it for now.

crates/physical-plan/src/plan.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,7 @@ mod tests {
14791479
col_name: Identifier::for_test(*name),
14801480
col_pos: i.into(),
14811481
col_type: ty.clone(),
1482+
alias: None,
14821483
})
14831484
.collect(),
14841485
indexes
@@ -1491,6 +1492,7 @@ mod tests {
14911492
index_algorithm: IndexAlgorithm::BTree(BTreeAlgorithm {
14921493
columns: ColList::from_iter(cols.iter().copied()),
14931494
}),
1495+
alias: None,
14941496
})
14951497
.collect(),
14961498
unique
@@ -1511,6 +1513,7 @@ mod tests {
15111513
None,
15121514
primary_key.map(ColId::from),
15131515
false,
1516+
None,
15141517
)))
15151518
}
15161519

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ impl<'a> ModuleValidatorV10<'a> {
345345
.into_iter()
346346
.map(|index| {
347347
table_validator
348-
.validate_index_def_v10(index.into())
348+
.validate_index_def_v10(index)
349349
.map(|index| (index.name.clone(), index))
350350
})
351351
.collect_all_errors::<StrMap<_>>();
@@ -403,7 +403,11 @@ impl<'a> ModuleValidatorV10<'a> {
403403
if table_type != TableType::System && name.starts_with("st_") {
404404
Err(ValidationError::TableNameReserved { table: name }.into())
405405
} else {
406-
let name = table_validator.add_to_global_namespace(name.as_raw().clone())?;
406+
let mut name = name.as_raw().clone();
407+
if name != raw_table_name {
408+
name = table_validator.add_to_global_namespace(name)?;
409+
}
410+
407411
Ok(name)
408412
}
409413
};
@@ -524,7 +528,7 @@ impl<'a> ModuleValidatorV10<'a> {
524528
tables: &HashMap<Identifier, TableDef>,
525529
) -> Result<(ScheduleDef, Identifier)> {
526530
let RawScheduleDefV10 {
527-
source_name,
531+
source_name: _,
528532
table_name,
529533
schedule_at_col,
530534
function_name,
@@ -671,7 +675,7 @@ impl<'a> ModuleValidatorV10<'a> {
671675
&return_type,
672676
);
673677

674-
let name_result = self.core.resolve_function_ident(accessor_name.clone());
678+
let name = self.core.resolve_function_ident(accessor_name.clone())?;
675679

676680
let mut view_validator = ViewValidator::new(
677681
accessor_name.clone(),
@@ -682,7 +686,7 @@ impl<'a> ModuleValidatorV10<'a> {
682686
&mut self.core,
683687
)?;
684688

685-
let name_result = view_validator.add_to_global_namespace(name_result?.as_raw().clone());
689+
let _ = view_validator.add_to_global_namespace(name.as_raw().clone())?;
686690

687691
let n = product_type.elements.len();
688692
let return_columns = (0..n)
@@ -694,11 +698,11 @@ impl<'a> ModuleValidatorV10<'a> {
694698
.map(|id| view_validator.validate_param_column_def(id.into()))
695699
.collect_all_errors();
696700

697-
let (name_result, return_type_for_generate, return_columns, param_columns) =
698-
(name_result, return_type_for_generate, return_columns, param_columns).combine_errors()?;
701+
let (return_type_for_generate, return_columns, param_columns) =
702+
(return_type_for_generate, return_columns, param_columns).combine_errors()?;
699703

700704
Ok(ViewDef {
701-
name: self.core.resolve_function_ident(name_result.clone())?,
705+
name,
702706
accessor_name: identifier(accessor_name)?,
703707
is_anonymous,
704708
is_public,
@@ -935,16 +939,19 @@ mod tests {
935939
name: "Apples_count_idx_direct".into(),
936940
codegen_name: Some(expect_identifier("Apples_count_idx_direct")),
937941
algorithm: DirectAlgorithm { column: 2.into() }.into(),
942+
accessor_name: "Apples_count_idx_direct".into(),
938943
},
939944
&IndexDef {
940945
name: "Apples_name_count_idx_btree".into(),
941946
codegen_name: Some(expect_identifier("Apples_name_count_idx_btree")),
942947
algorithm: BTreeAlgorithm { columns: [1, 2].into() }.into(),
948+
accessor_name: "Apples_name_count_idx_btree".into(),
943949
},
944950
&IndexDef {
945951
name: "Apples_type_idx_btree".into(),
946952
codegen_name: Some(expect_identifier("Apples_type_idx_btree")),
947953
algorithm: BTreeAlgorithm { columns: 3.into() }.into(),
954+
accessor_name: "Apples_type_idx_btree".into(),
948955
}
949956
]
950957
);

0 commit comments

Comments
 (0)