Skip to content

Respect unique constraint for relations field #3854

@raza2022

Description

@raza2022

Document Created with Wrong Relation Field ID and Duplicate ID

Let's Say You have a relational field named categoryID in users collection to link with Categories collection, and also this field has a check as unique fields option in advanced settings. So when new user created it should have a valid categoryID which already exists,

Now There are three cases and please make sure my case is 2nd and 3rd as first one already asked in previous issues.

  1. categoryID not supplied then user created successfully (not my issue as I know there is notrequired fields feature currently in strapi and it's already asked)

  2. wrong categoryID supplied and user still created (that's my case), means you can pass any valid 24 digit mongodb ID from any collection (not from categories) and it will be accepted without any error ?

  3. use the same ID again and again it will created new user despite unique fields is checked in advanced settings in relational field??

Steps to reproduce the behavior

  1. Go to 'Admin Panel Content Builder'
  2. Add new Content Type Categories
  3. Go to user collections and add relational field name categoryID to Categories
  4. Go in advanced settings tab and check the unique field
  5. Create New User from Front End using Strapi SDK or axios with any valid mongodb 24 digit ID and it will created without any error

Expected behavior
It should not create user and throw error that Category with specific ID is not exists or invalid category Id.

System

  • Node.js version: 10.16.0
  • NPM version: 6.9.0
  • Strapi version: 3.0.0-next.11
  • Database: MongoDB 3.0.14 Community
  • Operating system: Linux Ubuntu 14.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: core:databaseSource is core/database packagestatus: confirmedConfirmed by a Strapi Team member or multiple community members

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions