Amplify-android: DataStore multiple one has many relation error

Created on 19 May 2020  路  16Comments  路  Source: aws-amplify/amplify-android

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.

console 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.}

Bug DataStore

All 16 comments

This looks like the "atom" of the issue:

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]

Hi, any help on this issue? I'm having the same problem and it is critical for my project.

Thanks @tomasfelder! We're actively working on this one in preparation for our next release. Stay tuned.

@tomasfelder Can you verify this is happening with the latest CLI and Amplify Android 1.1.1?

Hi, this is hapening for me with latest CLI and Amplify Android 1.1.1, but maybe I'm making something wrong. Maybe I'm defining wrong the relations if this problem doesn't appears to you. My schema is similar to the one that it is defined on the issue but maybe I need to make changes and I don't understand the platform well. I would be great if you can help me to get this thing work!

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

https://discord.gg/jWVbPfC

I have the same issue with 1.1.2 and cli 4.27.0, in my Schema I have the attribute adress at the BranchOffice entity, that has relationship One to Many with DeliveryMan

these are some entities that are related in my schema.graphql

type Route @model{
    id: ID!
    name: String!
    creationDate: String!
    deliveryMan: DeliveryMan! @connection(name: "DeliveryManRoutes")
    industrial: Industrial! @connection(name: "IndustrialRoutes")
    deliveries: [Delivery] @connection(name: "RouteDeliveries")
    detail: [RouteDetail] @connection(name: "RouteDetail")
    active: Boolean!
}

type DeliveryMan @model{
    id: ID!
    username: String!
    firstName: String!
    lastName: String!
    phoneNumber: String!
    branchOffice: BranchOffice! @connection(name: "OfficeDeliverers")
    routes: [Route] @connection(name: "DeliveryManRoutes")
}

type Industrial @model{
    id: ID!
    username: String!
    firstName: String!
    lastName: String!
    email: String!
    phoneNumber: String!
    branchOffice: BranchOffice! @connection(name: "OfficeIndustrials")
    routes: [Route] @connection(name: "IndustrialRoutes")
}

type BranchOffice @model{
    id: ID!
    name: String!
    address: String!
    products: [Product] @connection(name: "OfficeProducts")
    industrials: [Industrial] @connection(name: "OfficeIndustrials")
    customers: [Customer] @connection(name: "OfficeCustomers")
    deliverers: [DeliveryMan] @connection(name: "OfficeDeliverers")
}

type Customer @model{
    id: ID!
    firstName: String!
    lastName: String!
    code: String!
    phoneNumber: String!
    balance: Float!
    location: String!
    deliveries: [Delivery] @connection(name: "CustomerDeliveries")
    branchOffice: BranchOffice! @connection(name: "OfficeCustomers")
}

And this is the message that I got

2020-08-10 00:35:52.595 18090-18181/com.bluepeople.grumarutas E/Amplify: Description: AmplifyException {message=Error in querying the model., cause=AmplifyException {message=Error converting field "deliveryMan" from model "com.amplifyframework.datastore.generated.model.Route", cause=AmplifyException {message=Error converting field "branchOffice" from model "com.amplifyframework.datastore.generated.model.DeliveryMan", cause=AmplifyException {message=Error converting field "address" from model "com.amplifyframework.datastore.generated.model.BranchOffice", cause=java.lang.IllegalArgumentException: column 'BranchOffice_address' does not exist. Available columns: [Route_id, Route_active, Route_creationDate, Route_name, Route_routeDeliveryManId, Route_routeIndustrialId, DeliveryMan_id, DeliveryMan_firstName, DeliveryMan_lastName, DeliveryMan_phoneNumber, DeliveryMan_username, DeliveryMan_deliveryManBranchOfficeId, Industrial_id, Industrial_email, Industrial_firstName, Industrial_lastName, Industrial_phoneNumber, Industrial_username, Industrial_industrialBranchOfficeId], 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.}

Hi @rjuliano , how are you? I wanted to know if there has been any update to this issue with the latest releases of Datastore. Thank you and waiting for your news :)

Hey @tomasfelder that one is still in our backlog, but we haven't had a chance to get someone working on that. I'll be sure to link any upcoming related PRs to this issue so you can track progress.

Any updates on this?

Thanks @micstepper! We're putting this bug on the top of our list for our next sprint on Monday given its age and the feedback. Will provide updates here.

Thx @jpignata - does any workaround exist?

Heya @michalisAsp,

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

@raphkim when is your next release scheduled?

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

This has been addressed in 1.6.0 - please ping me if you have any trouble!

Was this page helpful?
0 / 5 - 0 ratings