Skip to content

Commit

Permalink
fix: initialize arrays to string value
Browse files Browse the repository at this point in the history
Arrays are stored as strings in the database so we have to initialize
them as such as well.
  • Loading branch information
Sekhmet committed Nov 8, 2024
1 parent e394fb1 commit 8024cf5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const getTypeInfo = (
const nonNullNestedType =
type.ofType instanceof GraphQLNonNull ? type.ofType.ofType : type.ofType;

return { type: `${getTypeInfo(nonNullNestedType, decimalTypes).type}[]`, initialValue: [] };
return { type: `${getTypeInfo(nonNullNestedType, decimalTypes).type}[]`, initialValue: '[]' };
}

throw new Error('Unknown type');
Expand Down
8 changes: 4 additions & 4 deletions test/unit/__snapshots__/codegen.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class Space extends Model {
this.initialSet('voting_delay', 0);
this.initialSet('proposal_threshold', 0);
this.initialSet('quorum', 0);
this.initialSet('strategies', []);
this.initialSet('strategies_nonnull', []);
this.initialSet('strategies', "[]");
this.initialSet('strategies_nonnull', "[]");
}
static async loadEntity(id) {
Expand Down Expand Up @@ -217,8 +217,8 @@ export class Space extends Model {
this.initialSet('voting_delay', 0);
this.initialSet('proposal_threshold', 0);
this.initialSet('quorum', 0);
this.initialSet('strategies', []);
this.initialSet('strategies_nonnull', []);
this.initialSet('strategies', "[]");
this.initialSet('strategies_nonnull', "[]");
}
static async loadEntity(id: string): Promise<Space | null> {
Expand Down

0 comments on commit 8024cf5

Please sign in to comment.