You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this PR #538 we're populating the associatedFields of a has-many connection. There is one case that doesn't seem to be working as expected. For this schema:
// Uni-directional has-many with CPK on parent, with customized FK
type Post8 @model {
postId: ID! @primaryKey(sortKeyFields:["title"])
title: String!
comments: [Comment8] @hasMany(indexName:"byPost", fields:["postId", "title"])
}
type Comment8 @model {
commentId: ID! @primaryKey(sortKeyFields:["content"])
content: String!
postId: ID @index(name: "byPost", sortKeyFields:["postTitle"]) # customized foreign key for parent primary key
postTitle: String # customized foreign key for parent sort key
}
The output of Post's schema file contains .hasMany(comments)
.hasMany(post.comments, is: .optional, ofType: Comment.self, associatedFields: [Comment.keys.postId])
The associatedFields of the comment to the post should be the foreign key fields on the Comment "postId" and "postTitle".
The expected output, to my understanding, should be:
.hasMany(post.comments, is: .optional, ofType: Comment.self, associatedFields: [Comment.keys.postId, Comment.keys.postTitle])
Opening this issue to bring awareness to see if we can collaborate on the solution. The code is getting pretty complicated to debug. My initial hunch is that somewhere in getConnectedFieldsForHasMany is not picking up "postTitle" and returning it in the CodeGenField[].
The text was updated successfully, but these errors were encountered:
lawmicha
changed the title
Swift Model Codegen for Unidirectional Has-Many AssociatedFields Missing Index
Swift Model Codegen for Unidirectional Has-Many AssociatedFields Missing Index fields
Feb 3, 2023
In this PR #538 we're populating the
associatedFields
of a has-many connection. There is one case that doesn't seem to be working as expected. For this schema:The output of Post's schema file contains
.hasMany(comments)
This output doesn't look accurate
The associatedFields of the comment to the post should be the foreign key fields on the Comment "postId" and "postTitle".
The expected output, to my understanding, should be:
Opening this issue to bring awareness to see if we can collaborate on the solution. The code is getting pretty complicated to debug. My initial hunch is that somewhere in
getConnectedFieldsForHasMany
is not picking up "postTitle" and returning it in theCodeGenField[]
.The text was updated successfully, but these errors were encountered: