From: Sergey Matveev Date: Wed, 18 Jun 2025 15:06:51 +0000 (+0300) Subject: Remove redundant "TAKE ." X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f74a8b8b18da56b370085d0d003b54f3e5836384f61d65afc151725ddd23e451;p=keks.git Remove redundant "TAKE ." --- diff --git a/c/lib/schema.c b/c/lib/schema.c index c253b2a..bfe5734 100644 --- a/c/lib/schema.c +++ b/c/lib/schema.c @@ -641,7 +641,7 @@ KEKSSchemaValidate( // NOLINT(misc-no-recursion) } idxSchema = schema->list[idxSchema].atom.v.list.head; err.offSchema = schema->offsets[idxSchema]; - size_t taken = SIZE_MAX; + size_t taken = idxData; bool eachInList = false; bool eachInMap = false; struct KEKSSchemaErr errCmd; diff --git a/go/schema/check.go b/go/schema/check.go index 7edeed9..7daf7fd 100644 --- a/go/schema/check.go +++ b/go/schema/check.go @@ -86,7 +86,7 @@ func Check(schemaName string, schemas map[string][][]any, data any) error { }} } var taken string - var vs []any + vs := []any{data} for cmdIdx, cmd := range cmds { if len(cmd) == 0 { return &SchemaErr{BaseErr: BaseErr{ diff --git a/spec/schema/cmds b/spec/schema/cmds index 9bf4ea5..eecc30c 100644 --- a/spec/schema/cmds +++ b/spec/schema/cmds @@ -13,6 +13,8 @@ TAKE | [".", k] If "k" equals to ".", then choose the element you are currently in. Command never fails, but key can be non-existent. All following commands will be applied to the taken value. + By default analogue of [".", "."] command is executed when schema + check is called. EXISTS | ["E"] Assure that chosen element exists. @@ -100,7 +102,6 @@ Here is an example with multiple schemas: { "where": [ - [".", "."], ["T", "LIST"], [">", 1], ["<", 3], @@ -116,7 +117,6 @@ Here is an example with multiple schemas: ["<", 181], ], "wheres": [ - [".", "."], ["T", "LIST"], [">", 0], ["*"], diff --git a/tcl/schema.t/generic.t b/tcl/schema.t/generic.t index e384b3b..257fff5 100755 --- a/tcl/schema.t/generic.t +++ b/tcl/schema.t/generic.t @@ -616,7 +616,6 @@ test_expect_success "tai64 prec=fs" "$SCHEMA_VALIDATE schema.keks e schema.keks.hex <