test: declare table fields with @Field and @Relation decorators in fixtures - #16
Merged
Merged
Conversation
Comment on lines
+60
to
62
| @Field("string") | ||
| @Relation({ to: () => Author }) | ||
| declare authorId: string | null; |
There was a problem hiding this comment.
The
@Field("string") decorator on authorId doesn't reflect the field's nullable TypeScript type (string | null). Every other @Relation field in this PR is non-nullable, so this is the only case where the decorator metadata and the TypeScript type diverge. If the decorator library has a way to express nullability (e.g. a second options argument), annotating it here would make the schema metadata accurate.
Suggested change
| @Field("string") | |
| @Relation({ to: () => Author }) | |
| declare authorId: string | null; | |
| @Field("string", { nullable: true }) | |
| @Relation({ to: () => Author }) | |
| declare authorId: string | null; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/tests/components/modifier_key.test.ts
Line: 60-62
Comment:
The `@Field("string")` decorator on `authorId` doesn't reflect the field's nullable TypeScript type (`string | null`). Every other `@Relation` field in this PR is non-nullable, so this is the only case where the decorator metadata and the TypeScript type diverge. If the decorator library has a way to express nullability (e.g. a second options argument), annotating it here would make the schema metadata accurate.
```suggestion
@Field("string", { nullable: true })
@Relation({ to: () => Author })
declare authorId: string | null;
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@Field(...)decorators to every column of the table fixtures across the 11 test files (components, routes, integration)@Relation(...)on fixture fields referencing another fixture's_id(e.g.Book.authorId,Order.customerId,OrderItem.orderId/productId,Device.group_id)@antelopejs/interface-database-decorators^0.1.3 → ^0.1.4 (first version exportingRelation)_idand@Localizedfields stay non-decorated, matching the interface-database-decorators reference testsTest plan
pnpm test→ 73 passing, 0 failing (same as baseline);pnpm run lintOKNote: requires purging
.antelope/cachelocally after the dependency bump (documented project procedure) — the cached@antelopejs/database-decoratorsmodule embedded interface 0.1.1 withoutRelation.https://claude.ai/code/session_016dBZTZJnv6S9vU2jfzeUSK
Greptile Summary
This PR annotates all fixture table classes across 11 test files with
@Field(...)and@Relation(...)decorators, and bumps@antelopejs/interface-database-decoratorsfrom^0.1.3to^0.1.4to pick up the newly exportedRelationdecorator. No test assertions are changed.@Field(type)is added to every physical column (excluding_idand@Localizedfields), using the correct type tokens —"string","number","date","boolean", and["string"]for arrays.@Relation({ to: () => TargetClass })is applied to every foreign-key field (e.g.Book.authorId,Order.customerId,OrderItem.orderId/productId,Device.group_id), consistently placed after@Fieldand after any@Index.acorn,ufo, andyamlas transitive updates.Confidence Score: 4/5
Mechanical decorator additions to test fixtures with no changes to test assertions or production code; all 73 tests reportedly pass.
The change is confined to test fixtures and a minor dependency bump. The only deviation from the pattern is that Post.authorId is typed string | null but decorated with @field("string") without a nullability marker, which may leave the schema metadata slightly inaccurate if the decorator library supports expressing nullability.
src/tests/components/modifier_key.test.ts — the only file where a nullable field (string | null) receives @field("string") without any nullable option.
Important Files Changed
Entity Relationship Diagram
%%{init: {'theme': 'neutral'}}%% erDiagram Customer { string _id PK string email string firstName string lastName date registrationDate boolean isActive number loyaltyPoints } Product { string _id PK string sku string name number price boolean isActive date createdAt } Order { string _id PK string orderNumber string customerId FK string status number finalAmount date createdAt } OrderItem { string _id PK string orderId FK string productId FK number quantity number unitPrice number discount } Author { string _id PK string name string email } Book { string _id PK string authorId FK string title } Customer ||--o{ Order : "places" Order ||--o{ OrderItem : "contains" Product ||--o{ OrderItem : "included in" Author ||--o{ Book : "writes"%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% erDiagram Customer { string _id PK string email string firstName string lastName date registrationDate boolean isActive number loyaltyPoints } Product { string _id PK string sku string name number price boolean isActive date createdAt } Order { string _id PK string orderNumber string customerId FK string status number finalAmount date createdAt } OrderItem { string _id PK string orderId FK string productId FK number quantity number unitPrice number discount } Author { string _id PK string name string email } Book { string _id PK string authorId FK string title } Customer ||--o{ Order : "places" Order ||--o{ OrderItem : "contains" Product ||--o{ OrderItem : "included in" Author ||--o{ Book : "writes"Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "test: declare table fields with @Field a..." | Re-trigger Greptile