Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

✨ Proposal: uniqueItems based several properties or subschema #1546

Open
Labels
proposalInitial discussion of a new idea. A project will be created once a proposal document is created.
@LasneF

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalInitial discussion of a new idea. A project will be created once a proposal document is created.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /