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

✨ Proposal: uniqueItems based several properties or subschema #1546

Open
LasneF opened this issue Oct 18, 2024 · 7 comments
Open

✨ Proposal: uniqueItems based several properties or subschema #1546

LasneF opened this issue Oct 18, 2024 · 7 comments
Labels
proposal Initial discussion of a new idea. A project will be created once a proposal document is created.

Comments

@LasneF
Copy link
Contributor

LasneF commented Oct 18, 2024

Describe the inspiration for your proposal

very often data are inserted in a db with constrains like a unique key
key can be one properties or a set of properties

it occurs that we may insert , update or manipulate data in bulk , and that as a pre requisite we have not unicity of the entire object but unicity on the subset of an object

for instance

{
   "type" : "array",
   "uniqueItems" : true, 
   "items": {
     "type" : "object",
     "required" : ["id", "dummy"] 
     "properties" : {
          "id" : { "type" :  "integer" },
          "dummy" : { "type" :  "integer" }
    }
   }
} 

For instance making this failing base on the subschema : "key"
[ { "id" : 1 , "dummy" : 12 } , {"id" : 1 , "dummy" : 13 }]

Describe the proposal

allows uniqueItems to be either a boolean either a schema like

{
   "type" : "array",
   "uniqueItems" : { "type" : "object" , "properties" : {"id" : { "type" :  "integer" } } 
   "items": {
     "type" : "object",
     "required" : ["id", "dummy"] 
     "properties" : {
          "id" : { "type" :  "integer" },
          "dummy" : { "type" :  "integer" }
    }
   }
} 

Describe alternatives you've considered

an alternative would be a meta data on top of the array to indicate "uniqueKey" as a complement of uniqueItems 👎

like

{
   "type" : "array",
   "uniqueItems" : true,
  "uniqueKey" :  ["id"]  
  "items": {
     "type" : "object",
     "required" : ["id", "dummy"] 
     
     "properties" : {
          "id" : { "type" :  "integer" },
          "dummy" : { "type" :  "integer" }
    }
   }
} 

another alternative would be to leverage a meta data on top of the properties (may be better )

{
   "type" : "array",
   "uniqueItems" : true,
  "items": {
     "type" : "object",
     "required" : ["id", "dummy"] 
     
     "properties" : {
          "id" : { "type" :  "integer" , "key": true },
          "dummy" : { "type" :  "integer" }
    }
   }
} 

Additional context

my context is unicity toward not a single properties like id , but 'kind of' composite key , spread on several properties

@LasneF LasneF added the proposal Initial discussion of a new idea. A project will be created once a proposal document is created. label Oct 18, 2024
@gregsdennis
Copy link
Member

This is very similar to my uniqueKeys keyword.

https://docs.json-everything.net/schema/vocabs/array-ext/#uniquekeys

@LasneF
Copy link
Contributor Author

LasneF commented Oct 21, 2024

yes exactly , it would be great to have it integrated as "core Json schema" in an evolution of JsonSchema 2025 version for instant ce, so that it got more widely adopted by schema validator .

@gregsdennis
Copy link
Member

We have introduced a process for new features going forward. Please have a look at that to set expectations.

Also, know that we're just looking to publish existing features (in a stable spec) with this next release. No new features for now. In fact some are being removed because they're not fully baked.

@LasneF
Copy link
Contributor Author

LasneF commented Oct 21, 2024

i cannot find the process description 😥, neither the feature roadmap could you give me a pointer , so that i can contribute support , upvote some intiatives

@gregsdennis
Copy link
Member

The process is defined in the PROCESS.md file in the root of this repository.

@benjagm can you provide a link to the roadmap in its current form, please? (We also have some work being done to publish it on the site.) The majority of my work, and as related to this repository, can be found on this project board.

@benjagm
Copy link
Collaborator

benjagm commented Oct 21, 2024

can you provide a link to the roadmap in its current form, please?

Hi Greg and Francois. Please, find here the current roadmap for the whole JSON Schema Initiative:

https://github.com/orgs/json-schema-org/discussions/427

@JaneX8
Copy link

JaneX8 commented Oct 31, 2024

This is exactly what I'm looking for. I really miss a feature to define that a value in an itemlist should be unique.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Initial discussion of a new idea. A project will be created once a proposal document is created.
Projects
None yet
Development

No branches or pull requests

4 participants