aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

aws-amplify datastore sqlite-adapter issue with connections [NOT NULL constraint] #9128

Closed cybexai closed 2 years ago

cybexai commented 2 years ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

DataStore

Amplify Categories

api

Environment information

``` # Put output below this line "dependencies": { "@aws-amplify/datastore-storage-adapter": "^1.1.10", "@azure/core-asynciterator-polyfill": "^1.0.0", "@react-native-async-storage/async-storage": "^1.15.9", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^6.0.2", "amazon-cognito-identity-js": "^5.2.0", "aws-amplify": "^4.3.2", "aws-amplify-react-native": "^5.0.4", ... }, ```

Describe the bug

We're receiving NOT NULL constraint when retrieving data from datastore. These NOT NULL constraints affects entities with "connections".

Expected behavior

We want the data of all entities to be retrieved from datastore

Reproduction steps

type Enterprise @model @auth( rules: [ { allow: owner ownerField: "belongTo" } ] ) { id: ID! name: String! image: String contact: String Departments: [Department!] @connection(keyName: "byEnterprise", fields: ["id"]) belongTo: String! }

...

type Department @model @key(name: "byEnterprise", fields: ["enterpriseID"]) @auth( rules: [ { allow: owner ownerField: "belongTo" } ] ) { id: ID! name: String! options: AWSJSON }

...

await DataStore.query( Enterprise, (enterprise) => enterprise.isDeleted("eq", false), { sort: (s) => s.name(SortDirection.DESCENDING), } )

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line Possible Unhandled Promise Rejection (id: 3): Object { "code": 6, "message": "NOT NULL constraint failed: Enterprise.Departments", } ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

iPhone 6, iPhone Xr, LG G6, Xiaomi Redmi

Mobile Operating System

iOS 14.5, iOS 12.5, Android 9,10

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

iartemiev commented 2 years ago

Thank you for opening the issue. We've opened a PR with the fix: https://github.com/aws-amplify/amplify-js/pull/9166

cybexai commented 2 years ago

thanks

iartemiev commented 2 years ago

Closing, as this is fixed as of @aws-amplify/datastore-storage-adapter@1.1.11

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.