amplify-android: DataStore multiple one has many relation error

With below schema, latest master branch, DataStore sync disabled:

type Blog @model
{
    id: ID!
    posts: [Post] @connection(name: "BlogPosts")
}
type Post @model
{
    id: ID!
    blog: Blog @connection(name: "BlogPosts")
    comments: [Comment!] @connection(name: "PostComments")
    text: String
}
type Comment @model
{
    id: ID!
    post: Post @connection(name: "PostComments")
}

I am seeing the exception below when I am trying to query for comments Amplify.DataStore.query(Comment::class.java)

It seems that defining relations A has many B & B has many C is what causing the issue. Keep in mind that I am able to store Comments, and query/store Posts.

AmplifyException {message=Error in querying the model., cause=AmplifyException {message=Error converting field "post" from model "com.amplifyframework.datastore.generated.model.Comment", cause=AmplifyException {message=Error converting field "blog" from model "com.amplifyframework.datastore.generated.model.Post", cause=AmplifyException {message=Error converting field "id" from model "com.amplifyframework.datastore.generated.model.Blog", cause=java.lang.IllegalArgumentException: column 'Blog_id' does not exist. Available columns: [Comment_id, Comment_commentPostId, Post_id, Post_text, Post_postBlogId], recoverySuggestion=There is a possibility that there is a bug if this error persists. Please take a look at 
https://github.com/aws-amplify/amplify-android/issues to see if there are any existing issues that 
match your scenario, and file an issue with the details of the bug if there isn't.}, recoverySuggestion=There is a possibility that there is a bug if this error persists. Please take a look at 
https://github.com/aws-amplify/amplify-android/issues to see if there are any existing issues that 
match your scenario, and file an issue with the details of the bug if there isn't.}, recoverySuggestion=There is a possibility that there is a bug if this error persists. Please take a look at 
https://github.com/aws-amplify/amplify-android/issues to see if there are any existing issues that 
match your scenario, and file an issue with the details of the bug if there isn't.}, recoverySuggestion=See attached exception for details.}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

I cannot promise a specific date, but it will be coming soon! 😃

Heya @michalisAsp,

@saltonmassally’s PR to recursively join relational models should address this issue! This change will go live in our next release.

Thanks. Any chance we can chat on Discord? We’re in the #android-help channel.

https://discord.gg/jWVbPfC