Skip to content

Commit 9f09e8a

Browse files
authored
Use camel case for typescript unique indexes (#2628)
1 parent 2d0b412 commit 9f09e8a

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

crates/cli/src/subcommands/generate/typescript.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export class {table_handle} {{
157157
for (unique_field_ident, unique_field_type_use) in
158158
iter_unique_cols(module.typespace_for_generate(), &schema, product_def)
159159
{
160-
let unique_field_name = unique_field_ident.deref().to_case(Case::Snake);
160+
let unique_field_name = unique_field_ident.deref().to_case(Case::Camel);
161161
let unique_field_name_pascalcase = unique_field_name.to_case(Case::Pascal);
162162

163163
let unique_constraint = table_name_pascalcase.clone() + &unique_field_name_pascalcase + "Unique";

crates/cli/tests/snapshots/codegen__codegen_typescript.snap

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,22 +1547,22 @@ export class LoggedOutPlayerTableHandle {
15471547
},
15481548
};
15491549
/**
1550-
* Access to the `player_id` unique index on the table `logged_out_player`,
1550+
* Access to the `playerId` unique index on the table `logged_out_player`,
15511551
* which allows point queries on the field of the same name
15521552
* via the [`LoggedOutPlayerPlayerIdUnique.find`] method.
15531553
*
15541554
* Users are encouraged not to explicitly reference this type,
15551555
* but to directly chain method calls,
1556-
* like `ctx.db.loggedOutPlayer.player_id().find(...)`.
1556+
* like `ctx.db.loggedOutPlayer.playerId().find(...)`.
15571557
*
1558-
* Get a handle on the `player_id` unique index on the table `logged_out_player`.
1558+
* Get a handle on the `playerId` unique index on the table `logged_out_player`.
15591559
*/
1560-
player_id = {
1561-
// Find the subscribed row whose `player_id` column value is equal to `col_val`,
1560+
playerId = {
1561+
// Find the subscribed row whose `playerId` column value is equal to `col_val`,
15621562
// if such a row is present in the client cache.
15631563
find: (col_val: bigint): Player | undefined => {
15641564
for (let row of this.tableCache.iter()) {
1565-
if (deepEqual(row.player_id, col_val)) {
1565+
if (deepEqual(row.playerId, col_val)) {
15661566
return row;
15671567
}
15681568
}
@@ -2218,22 +2218,22 @@ export class PlayerTableHandle {
22182218
},
22192219
};
22202220
/**
2221-
* Access to the `player_id` unique index on the table `player`,
2221+
* Access to the `playerId` unique index on the table `player`,
22222222
* which allows point queries on the field of the same name
22232223
* via the [`PlayerPlayerIdUnique.find`] method.
22242224
*
22252225
* Users are encouraged not to explicitly reference this type,
22262226
* but to directly chain method calls,
2227-
* like `ctx.db.player.player_id().find(...)`.
2227+
* like `ctx.db.player.playerId().find(...)`.
22282228
*
2229-
* Get a handle on the `player_id` unique index on the table `player`.
2229+
* Get a handle on the `playerId` unique index on the table `player`.
22302230
*/
2231-
player_id = {
2232-
// Find the subscribed row whose `player_id` column value is equal to `col_val`,
2231+
playerId = {
2232+
// Find the subscribed row whose `playerId` column value is equal to `col_val`,
22332233
// if such a row is present in the client cache.
22342234
find: (col_val: bigint): Player | undefined => {
22352235
for (let row of this.tableCache.iter()) {
2236-
if (deepEqual(row.player_id, col_val)) {
2236+
if (deepEqual(row.playerId, col_val)) {
22372237
return row;
22382238
}
22392239
}
@@ -2759,22 +2759,22 @@ export class RepeatingTestArgTableHandle {
27592759
return this.tableCache.iter();
27602760
}
27612761
/**
2762-
* Access to the `scheduled_id` unique index on the table `repeating_test_arg`,
2762+
* Access to the `scheduledId` unique index on the table `repeating_test_arg`,
27632763
* which allows point queries on the field of the same name
27642764
* via the [`RepeatingTestArgScheduledIdUnique.find`] method.
27652765
*
27662766
* Users are encouraged not to explicitly reference this type,
27672767
* but to directly chain method calls,
2768-
* like `ctx.db.repeatingTestArg.scheduled_id().find(...)`.
2768+
* like `ctx.db.repeatingTestArg.scheduledId().find(...)`.
27692769
*
2770-
* Get a handle on the `scheduled_id` unique index on the table `repeating_test_arg`.
2770+
* Get a handle on the `scheduledId` unique index on the table `repeating_test_arg`.
27712771
*/
2772-
scheduled_id = {
2773-
// Find the subscribed row whose `scheduled_id` column value is equal to `col_val`,
2772+
scheduledId = {
2773+
// Find the subscribed row whose `scheduledId` column value is equal to `col_val`,
27742774
// if such a row is present in the client cache.
27752775
find: (col_val: bigint): RepeatingTestArg | undefined => {
27762776
for (let row of this.tableCache.iter()) {
2777-
if (deepEqual(row.scheduled_id, col_val)) {
2777+
if (deepEqual(row.scheduledId, col_val)) {
27782778
return row;
27792779
}
27802780
}

0 commit comments

Comments
 (0)