return err;
}
err.offSchema = schema->offsets[idxSchema];
- if (schema->list[idxSchema].atom.typ != KEKSItemStr) {
+ if (schema->list[idxSchema].atom.typ != KEKSItemBin) {
err.code = KEKSSchemaErrInvalidSchema;
- err.msg = "non-str EQ";
+ err.msg = "non-bin EQ";
return err;
}
err.code = ((schema->list[idxSchema].atom.v.str.len ==
package schema
import (
+ "bytes"
"errors"
"fmt"
"slices"
if len(act) != 2 {
return fmt.Errorf("%s: %d: %s: wrong number of args", schemaName, i, cmd)
}
- expect, ok := act[1].(string)
+ expect, ok := act[1].([]byte)
if !ok {
- return fmt.Errorf("%s: %d: %s: bad str: %+v", schemaName, i, cmd, act[1])
+ return fmt.Errorf("%s: %d: %s: bad bin: %+v", schemaName, i, cmd, act[1])
}
for _, v := range vs {
- got, ok := v.(string)
- if !ok {
- return fmt.Errorf("%s: %d: %s: not str: %T", schemaName, i, cmd, v)
+ var eq bool
+ switch got := v.(type) {
+ case string:
+ eq = got == string(expect)
+ case []byte:
+ eq = bytes.Equal(got, expect)
+ case keks.Hexlet:
+ eq = bytes.Equal(got[:], expect)
+ case *tai64n.TAI64:
+ eq = bytes.Equal(got[:], expect)
+ case *tai64n.TAI64N:
+ eq = bytes.Equal(got[:], expect)
+ case *tai64n.TAI64NA:
+ eq = bytes.Equal(got[:], expect)
+ case keks.Magic:
+ eq = string(got) == string(expect)
+ case keks.Raw:
+ eq = bytes.Equal(got, expect)
+ default:
+ if !ok {
+ return fmt.Errorf("%s: %d: %s: non-comparable: %T", schemaName, i, cmd, v)
+ }
}
- if got != expect {
+ if !eq {
return fmt.Errorf("%s: %d: %s: !=", schemaName, i, cmd)
}
}
proc EXISTS {} {return {{LIST {{STR E}}}}}
proc !EXISTS {} {return {{LIST {{STR !E}}}}}
proc EACH {} {return {{LIST {{STR *}}}}}
-proc EQ {v} {subst {{LIST {{STR =} {STR $v}}}}}
+proc EQ {v} {subst {{LIST {{STR =} {BIN $v}}}}}
proc TYPE {vs} {
set l {{STR T}}
foreach v $vs {