Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: Failed one to many relationship #8058

Open
2 tasks done
stnguyen90 opened this issue May 1, 2024 · 1 comment
Open
2 tasks done

🐛 Bug Report: Failed one to many relationship #8058

stnguyen90 opened this issue May 1, 2024 · 1 comment
Labels
bug Something isn't working feature / relationships Fixes and upgrades for database relationships product / databases Fixes and upgrades for the Appwrite Database.

Comments

@stnguyen90
Copy link
Contributor

👟 Reproduction steps

Create 2 one way one to many relationships to the same collection from separate collections:

For example, using the CLI:

$ appwrite databases createRelationshipAttribute --databaseId relationships --collectionId first --relatedCollectionId third --type oneToMany --key oneToManyThird --twoWay false --twoWayKey related2
key : oneToManyThird
type : relationship
status : processing
error : 
required : false
array : false
relatedCollection : third
relationType : oneToMany
twoWay : false
twoWayKey : related2
onDelete : restrict
side : parent
✓ Success 

# steven @ Stevens-MacBook-Pro-2 in ~/Projects/appwrite-projects/localhost-test [9:25:40] 
$ appwrite databases createRelationshipAttribute --databaseId relationships --collectionId second --relatedCollectionId third --type oneToMany --key oneToManyThird --twoWay false --twoWayKey related2
key : oneToManyThird
type : relationship
status : processing
error : 
required : false
array : false
relatedCollection : third
relationType : oneToMany
twoWay : false
twoWayKey : related2
onDelete : restrict
side : parent
✓ Success

👍 Expected behavior

Maybe an error should be thrown for the 2nd create relationship attribute API call.

👎 Actual Behavior

API calls are successful, but the attribute ends up as failed, but without any error:

{
  "key": "oneToManyThird",
  "type": "relationship",
  "status": "failed",
  "error": "",
  "required": false,
  "array": false,
  "relatedCollection": "third",
  "relationType": "oneToMany",
  "twoWay": false,
  "twoWayKey": "related2",
  "onDelete": "restrict",
  "side": "parent"
}

Database worker logs show:

appwrite-worker-databases  | [Job] Received Job (66326d5ab7a040.66031591).
appwrite-worker-databases  | SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'related2'
appwrite-worker-databases  | [Job] (66326d5ab7a040.66031591) successfully run.

🎲 Appwrite version

Version 1.5.x

💻 Operating system

Linux

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@stnguyen90 stnguyen90 added bug Something isn't working product / databases Fixes and upgrades for the Appwrite Database. feature / relationships Fixes and upgrades for database relationships labels May 1, 2024
@stnguyen90
Copy link
Contributor Author

Related to #8059 because of the behavior with two way keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature / relationships Fixes and upgrades for database relationships product / databases Fixes and upgrades for the Appwrite Database.
Projects
None yet
Development

No branches or pull requests

1 participant