diff --git a/sql/ast.gen.go b/sql/ast.gen.go new file mode 100644 index 00000000..4e22ebd4 --- /dev/null +++ b/sql/ast.gen.go @@ -0,0 +1,20013 @@ +// Code generated by codecgen - DO NOT EDIT. + +package sql + +import ( + "errors" + "fmt" + codec1978 "github.com/ugorji/go/codec" + pkg1_language "golang.org/x/text/language" + "reflect" + "runtime" + time "time" +) + +const ( + // ----- content types ---- + codecSelferCcUTF84085 = 1 + codecSelferCcRAW4085 = 0 + // ----- value types used ---- + codecSelferValueTypeArray4085 = 10 + codecSelferValueTypeMap4085 = 9 + // ----- containerStateValues ---- + codecSelferKcontainerMapKey4085 = 2 + codecSelferKcontainerMapValue4085 = 3 + codecSelferKcontainerMapEnd4085 = 4 + codecSelferKcontainerArrayElem4085 = 6 + codecSelferKcontainerArrayEnd4085 = 7 +) + +var ( + codecSelferBitsize4085 = uint8(reflect.TypeOf(uint(0)).Bits()) + errCodecSelferOnlyMapOrArrayEncodeToStruct4085 = errors.New(`only encoded map or array can be decoded into a struct`) +) + +type codecSelfer4085 struct{} + +func init() { + if codec1978.GenVersion != 8 { + _, file, _, _ := runtime.Caller(0) + err := fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v", + 8, codec1978.GenVersion, file) + panic(err) + } + if false { // reference the types, but skip this branch at build/run time + var v0 pkg1_language.Tag + var v1 time.Duration + _, _ = v0, v1 + } +} + +func (x *Query) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Statements == nil { + r.EncodeNil() + } else { + x.Statements.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Statements`) + r.WriteMapElemValue() + if x.Statements == nil { + r.EncodeNil() + } else { + x.Statements.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Query) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Query) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Statements": + if r.TryDecodeAsNil() { + x.Statements = nil + } else { + yyv4 := &x.Statements + yyv4.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Query) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj5 int + var yyb5 bool + var yyhl5 bool = l >= 0 + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Statements = nil + } else { + yyv6 := &x.Statements + yyv6.CodecDecodeSelf(d) + } + for { + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj5-1, "") + } + r.ReadArrayEnd() +} + +func (x Statements) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encStatements((Statements)(x), e) + } + } +} + +func (x *Statements) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decStatements((*Statements)(x), d) + } +} + +func (x *BeginStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *BeginStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *BeginStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *BeginStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *CancelStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *CancelStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *CancelStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *CancelStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *CommitStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *CommitStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *CommitStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *CommitStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *UseStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *UseStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *UseStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *UseStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *InfoStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *InfoStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *InfoStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *InfoStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *IfStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(3) + } else { + r.WriteMapStart(3) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Cond == nil { + r.EncodeNil() + } else { + x.Cond.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `cond`) + r.WriteMapElemValue() + if x.Cond == nil { + r.EncodeNil() + } else { + x.Cond.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Then == nil { + r.EncodeNil() + } else { + x.Then.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `then`) + r.WriteMapElemValue() + if x.Then == nil { + r.EncodeNil() + } else { + x.Then.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Else == nil { + r.EncodeNil() + } else { + yym10 := z.EncBinary() + _ = yym10 + if false { + } else if z.HasExtensions() && z.EncExt(x.Else) { + } else { + z.EncFallback(x.Else) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `else`) + r.WriteMapElemValue() + if x.Else == nil { + r.EncodeNil() + } else { + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(x.Else) { + } else { + z.EncFallback(x.Else) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *IfStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *IfStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "cond": + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv4 := &x.Cond + yyv4.CodecDecodeSelf(d) + } + case "then": + if r.TryDecodeAsNil() { + x.Then = nil + } else { + yyv5 := &x.Then + yyv5.CodecDecodeSelf(d) + } + case "else": + if r.TryDecodeAsNil() { + x.Else = nil + } else { + yyv6 := &x.Else + yym7 := z.DecBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.DecExt(yyv6) { + } else { + z.DecFallback(yyv6, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *IfStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv9 := &x.Cond + yyv9.CodecDecodeSelf(d) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Then = nil + } else { + yyv10 := &x.Then + yyv10.CodecDecodeSelf(d) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Else = nil + } else { + yyv11 := &x.Else + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + for { + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj8-1, "") + } + r.ReadArrayEnd() +} + +func (x *LetStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *LetStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *LetStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *LetStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *ReturnStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *ReturnStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *ReturnStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *ReturnStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *LiveStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(9) + } else { + r.WriteMapStart(9) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.ID)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `ID`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.ID)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.FB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `FB`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.FB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `KV`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym13 := z.EncBinary() + _ = yym13 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `NS`) + r.WriteMapElemValue() + yym14 := z.EncBinary() + _ = yym14 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym16 := z.EncBinary() + _ = yym16 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `DB`) + r.WriteMapElemValue() + yym17 := z.EncBinary() + _ = yym17 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym19 := z.EncBinary() + _ = yym19 + if false { + } else { + r.EncodeBool(bool(x.Diff)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `diff`) + r.WriteMapElemValue() + yym20 := z.EncBinary() + _ = yym20 + if false { + } else { + r.EncodeBool(bool(x.Diff)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Expr == nil { + r.EncodeNil() + } else { + x.Expr.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `expr`) + r.WriteMapElemValue() + if x.Expr == nil { + r.EncodeNil() + } else { + x.Expr.CodecEncodeSelf(e) + } + } + var yyn24 bool + if x.What == nil { + yyn24 = true + goto LABEL24 + } + LABEL24: + if yyr2 || yy2arr2 { + if yyn24 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `what`) + r.WriteMapElemValue() + if yyn24 { + r.EncodeNil() + } else { + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Cond == nil { + r.EncodeNil() + } else { + yym28 := z.EncBinary() + _ = yym28 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `cond`) + r.WriteMapElemValue() + if x.Cond == nil { + r.EncodeNil() + } else { + yym29 := z.EncBinary() + _ = yym29 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *LiveStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *LiveStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "ID": + if r.TryDecodeAsNil() { + x.ID = "" + } else { + yyv4 := &x.ID + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "FB": + if r.TryDecodeAsNil() { + x.FB = "" + } else { + yyv6 := &x.FB + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*string)(yyv6)) = r.DecodeString() + } + } + case "KV": + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv8 := &x.KV + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + case "NS": + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv10 := &x.NS + yym11 := z.DecBinary() + _ = yym11 + if false { + } else { + *((*string)(yyv10)) = r.DecodeString() + } + } + case "DB": + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv12 := &x.DB + yym13 := z.DecBinary() + _ = yym13 + if false { + } else { + *((*string)(yyv12)) = r.DecodeString() + } + } + case "diff": + if r.TryDecodeAsNil() { + x.Diff = false + } else { + yyv14 := &x.Diff + yym15 := z.DecBinary() + _ = yym15 + if false { + } else { + *((*bool)(yyv14)) = r.DecodeBool() + } + } + case "expr": + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv16 := &x.Expr + yyv16.CodecDecodeSelf(d) + } + case "what": + if x.What == nil { + x.What = new(Table) + } + if r.TryDecodeAsNil() { + if x.What != nil { + x.What = nil + } + } else { + if x.What == nil { + x.What = new(Table) + } + x.What.CodecDecodeSelf(d) + } + case "cond": + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv18 := &x.Cond + yym19 := z.DecBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.DecExt(yyv18) { + } else { + z.DecFallback(yyv18, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *LiveStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj20 int + var yyb20 bool + var yyhl20 bool = l >= 0 + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l + } else { + yyb20 = r.CheckBreak() + } + if yyb20 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.ID = "" + } else { + yyv21 := &x.ID + yym22 := z.DecBinary() + _ = yym22 + if false { + } else { + *((*string)(yyv21)) = r.DecodeString() + } + } + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l + } else { + yyb20 = r.CheckBreak() + } + if yyb20 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.FB = "" + } else { + yyv23 := &x.FB + yym24 := z.DecBinary() + _ = yym24 + if false { + } else { + *((*string)(yyv23)) = r.DecodeString() + } + } + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l + } else { + yyb20 = r.CheckBreak() + } + if yyb20 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv25 := &x.KV + yym26 := z.DecBinary() + _ = yym26 + if false { + } else { + *((*string)(yyv25)) = r.DecodeString() + } + } + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l + } else { + yyb20 = r.CheckBreak() + } + if yyb20 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv27 := &x.NS + yym28 := z.DecBinary() + _ = yym28 + if false { + } else { + *((*string)(yyv27)) = r.DecodeString() + } + } + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l + } else { + yyb20 = r.CheckBreak() + } + if yyb20 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv29 := &x.DB + yym30 := z.DecBinary() + _ = yym30 + if false { + } else { + *((*string)(yyv29)) = r.DecodeString() + } + } + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l + } else { + yyb20 = r.CheckBreak() + } + if yyb20 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Diff = false + } else { + yyv31 := &x.Diff + yym32 := z.DecBinary() + _ = yym32 + if false { + } else { + *((*bool)(yyv31)) = r.DecodeBool() + } + } + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l + } else { + yyb20 = r.CheckBreak() + } + if yyb20 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv33 := &x.Expr + yyv33.CodecDecodeSelf(d) + } + if x.What == nil { + x.What = new(Table) + } + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l + } else { + yyb20 = r.CheckBreak() + } + if yyb20 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.What != nil { + x.What = nil + } + } else { + if x.What == nil { + x.What = new(Table) + } + x.What.CodecDecodeSelf(d) + } + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l + } else { + yyb20 = r.CheckBreak() + } + if yyb20 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv35 := &x.Cond + yym36 := z.DecBinary() + _ = yym36 + if false { + } else if z.HasExtensions() && z.DecExt(yyv35) { + } else { + z.DecFallback(yyv35, true) + } + } + for { + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l + } else { + yyb20 = r.CheckBreak() + } + if yyb20 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj20-1, "") + } + r.ReadArrayEnd() +} + +func (x *KillStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(5) + } else { + r.WriteMapStart(5) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.FB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `FB`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.FB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `KV`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `NS`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym13 := z.EncBinary() + _ = yym13 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `DB`) + r.WriteMapElemValue() + yym14 := z.EncBinary() + _ = yym14 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } + var yyn15 bool + if x.Name == nil { + yyn15 = true + goto LABEL15 + } + LABEL15: + if yyr2 || yy2arr2 { + if yyn15 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn15 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *KillStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *KillStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "FB": + if r.TryDecodeAsNil() { + x.FB = "" + } else { + yyv4 := &x.FB + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "KV": + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv6 := &x.KV + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*string)(yyv6)) = r.DecodeString() + } + } + case "NS": + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv8 := &x.NS + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + case "DB": + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv10 := &x.DB + yym11 := z.DecBinary() + _ = yym11 + if false { + } else { + *((*string)(yyv10)) = r.DecodeString() + } + } + case "name": + if x.Name == nil { + x.Name = new(Value) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Value) + } + x.Name.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *KillStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj13 int + var yyb13 bool + var yyhl13 bool = l >= 0 + yyj13++ + if yyhl13 { + yyb13 = yyj13 > l + } else { + yyb13 = r.CheckBreak() + } + if yyb13 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.FB = "" + } else { + yyv14 := &x.FB + yym15 := z.DecBinary() + _ = yym15 + if false { + } else { + *((*string)(yyv14)) = r.DecodeString() + } + } + yyj13++ + if yyhl13 { + yyb13 = yyj13 > l + } else { + yyb13 = r.CheckBreak() + } + if yyb13 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv16 := &x.KV + yym17 := z.DecBinary() + _ = yym17 + if false { + } else { + *((*string)(yyv16)) = r.DecodeString() + } + } + yyj13++ + if yyhl13 { + yyb13 = yyj13 > l + } else { + yyb13 = r.CheckBreak() + } + if yyb13 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv18 := &x.NS + yym19 := z.DecBinary() + _ = yym19 + if false { + } else { + *((*string)(yyv18)) = r.DecodeString() + } + } + yyj13++ + if yyhl13 { + yyb13 = yyj13 > l + } else { + yyb13 = r.CheckBreak() + } + if yyb13 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv20 := &x.DB + yym21 := z.DecBinary() + _ = yym21 + if false { + } else { + *((*string)(yyv20)) = r.DecodeString() + } + } + if x.Name == nil { + x.Name = new(Value) + } + yyj13++ + if yyhl13 { + yyb13 = yyj13 > l + } else { + yyb13 = r.CheckBreak() + } + if yyb13 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Value) + } + x.Name.CodecDecodeSelf(d) + } + for { + yyj13++ + if yyhl13 { + yyb13 = yyj13 > l + } else { + yyb13 = r.CheckBreak() + } + if yyb13 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj13-1, "") + } + r.ReadArrayEnd() +} + +func (x *SelectStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(13) + } else { + r.WriteMapStart(13) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `KV`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `NS`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `DB`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Expr == nil { + r.EncodeNil() + } else { + x.Expr.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `expr`) + r.WriteMapElemValue() + if x.Expr == nil { + r.EncodeNil() + } else { + x.Expr.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `what`) + r.WriteMapElemValue() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Cond == nil { + r.EncodeNil() + } else { + yym19 := z.EncBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `cond`) + r.WriteMapElemValue() + if x.Cond == nil { + r.EncodeNil() + } else { + yym20 := z.EncBinary() + _ = yym20 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Group == nil { + r.EncodeNil() + } else { + x.Group.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `group`) + r.WriteMapElemValue() + if x.Group == nil { + r.EncodeNil() + } else { + x.Group.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Order == nil { + r.EncodeNil() + } else { + x.Order.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `order`) + r.WriteMapElemValue() + if x.Order == nil { + r.EncodeNil() + } else { + x.Order.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Limit == nil { + r.EncodeNil() + } else { + yym28 := z.EncBinary() + _ = yym28 + if false { + } else if z.HasExtensions() && z.EncExt(x.Limit) { + } else { + z.EncFallback(x.Limit) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `limit`) + r.WriteMapElemValue() + if x.Limit == nil { + r.EncodeNil() + } else { + yym29 := z.EncBinary() + _ = yym29 + if false { + } else if z.HasExtensions() && z.EncExt(x.Limit) { + } else { + z.EncFallback(x.Limit) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Start == nil { + r.EncodeNil() + } else { + yym31 := z.EncBinary() + _ = yym31 + if false { + } else if z.HasExtensions() && z.EncExt(x.Start) { + } else { + z.EncFallback(x.Start) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `start`) + r.WriteMapElemValue() + if x.Start == nil { + r.EncodeNil() + } else { + yym32 := z.EncBinary() + _ = yym32 + if false { + } else if z.HasExtensions() && z.EncExt(x.Start) { + } else { + z.EncFallback(x.Start) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Version == nil { + r.EncodeNil() + } else { + yym34 := z.EncBinary() + _ = yym34 + if false { + } else if z.HasExtensions() && z.EncExt(x.Version) { + } else { + z.EncFallback(x.Version) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `version`) + r.WriteMapElemValue() + if x.Version == nil { + r.EncodeNil() + } else { + yym35 := z.EncBinary() + _ = yym35 + if false { + } else if z.HasExtensions() && z.EncExt(x.Version) { + } else { + z.EncFallback(x.Version) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym37 := z.EncBinary() + _ = yym37 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `timeout`) + r.WriteMapElemValue() + yym38 := z.EncBinary() + _ = yym38 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym40 := z.EncBinary() + _ = yym40 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `parallel`) + r.WriteMapElemValue() + yym41 := z.EncBinary() + _ = yym41 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *SelectStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *SelectStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "KV": + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv4 := &x.KV + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "NS": + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv6 := &x.NS + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*string)(yyv6)) = r.DecodeString() + } + } + case "DB": + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv8 := &x.DB + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + case "expr": + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv10 := &x.Expr + yyv10.CodecDecodeSelf(d) + } + case "what": + if r.TryDecodeAsNil() { + x.What = nil + } else { + yyv11 := &x.What + yyv11.CodecDecodeSelf(d) + } + case "cond": + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv12 := &x.Cond + yym13 := z.DecBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.DecExt(yyv12) { + } else { + z.DecFallback(yyv12, true) + } + } + case "group": + if r.TryDecodeAsNil() { + x.Group = nil + } else { + yyv14 := &x.Group + yyv14.CodecDecodeSelf(d) + } + case "order": + if r.TryDecodeAsNil() { + x.Order = nil + } else { + yyv15 := &x.Order + yyv15.CodecDecodeSelf(d) + } + case "limit": + if r.TryDecodeAsNil() { + x.Limit = nil + } else { + yyv16 := &x.Limit + yym17 := z.DecBinary() + _ = yym17 + if false { + } else if z.HasExtensions() && z.DecExt(yyv16) { + } else { + z.DecFallback(yyv16, true) + } + } + case "start": + if r.TryDecodeAsNil() { + x.Start = nil + } else { + yyv18 := &x.Start + yym19 := z.DecBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.DecExt(yyv18) { + } else { + z.DecFallback(yyv18, true) + } + } + case "version": + if r.TryDecodeAsNil() { + x.Version = nil + } else { + yyv20 := &x.Version + yym21 := z.DecBinary() + _ = yym21 + if false { + } else if z.HasExtensions() && z.DecExt(yyv20) { + } else { + z.DecFallback(yyv20, true) + } + } + case "timeout": + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv22 := &x.Timeout + yym23 := z.DecBinary() + _ = yym23 + if false { + } else if z.HasExtensions() && z.DecExt(yyv22) { + } else { + *((*int64)(yyv22)) = int64(r.DecodeInt(64)) + } + } + case "parallel": + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv24 := &x.Parallel + yym25 := z.DecBinary() + _ = yym25 + if false { + } else { + *((*int)(yyv24)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *SelectStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj26 int + var yyb26 bool + var yyhl26 bool = l >= 0 + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv27 := &x.KV + yym28 := z.DecBinary() + _ = yym28 + if false { + } else { + *((*string)(yyv27)) = r.DecodeString() + } + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv29 := &x.NS + yym30 := z.DecBinary() + _ = yym30 + if false { + } else { + *((*string)(yyv29)) = r.DecodeString() + } + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv31 := &x.DB + yym32 := z.DecBinary() + _ = yym32 + if false { + } else { + *((*string)(yyv31)) = r.DecodeString() + } + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv33 := &x.Expr + yyv33.CodecDecodeSelf(d) + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.What = nil + } else { + yyv34 := &x.What + yyv34.CodecDecodeSelf(d) + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv35 := &x.Cond + yym36 := z.DecBinary() + _ = yym36 + if false { + } else if z.HasExtensions() && z.DecExt(yyv35) { + } else { + z.DecFallback(yyv35, true) + } + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Group = nil + } else { + yyv37 := &x.Group + yyv37.CodecDecodeSelf(d) + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Order = nil + } else { + yyv38 := &x.Order + yyv38.CodecDecodeSelf(d) + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Limit = nil + } else { + yyv39 := &x.Limit + yym40 := z.DecBinary() + _ = yym40 + if false { + } else if z.HasExtensions() && z.DecExt(yyv39) { + } else { + z.DecFallback(yyv39, true) + } + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Start = nil + } else { + yyv41 := &x.Start + yym42 := z.DecBinary() + _ = yym42 + if false { + } else if z.HasExtensions() && z.DecExt(yyv41) { + } else { + z.DecFallback(yyv41, true) + } + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Version = nil + } else { + yyv43 := &x.Version + yym44 := z.DecBinary() + _ = yym44 + if false { + } else if z.HasExtensions() && z.DecExt(yyv43) { + } else { + z.DecFallback(yyv43, true) + } + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv45 := &x.Timeout + yym46 := z.DecBinary() + _ = yym46 + if false { + } else if z.HasExtensions() && z.DecExt(yyv45) { + } else { + *((*int64)(yyv45)) = int64(r.DecodeInt(64)) + } + } + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv47 := &x.Parallel + yym48 := z.DecBinary() + _ = yym48 + if false { + } else { + *((*int)(yyv47)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + for { + yyj26++ + if yyhl26 { + yyb26 = yyj26 > l + } else { + yyb26 = r.CheckBreak() + } + if yyb26 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj26-1, "") + } + r.ReadArrayEnd() +} + +func (x *CreateStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(8) + } else { + r.WriteMapStart(8) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `KV`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `NS`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `DB`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `what`) + r.WriteMapElemValue() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Data == nil { + r.EncodeNil() + } else { + yym16 := z.EncBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `data`) + r.WriteMapElemValue() + if x.Data == nil { + r.EncodeNil() + } else { + yym17 := z.EncBinary() + _ = yym17 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym19 := z.EncBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym19 { + z.EncBinaryMarshal(x.Echo) + } else if !yym19 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `echo`) + r.WriteMapElemValue() + yym20 := z.EncBinary() + _ = yym20 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym20 { + z.EncBinaryMarshal(x.Echo) + } else if !yym20 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym22 := z.EncBinary() + _ = yym22 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `timeout`) + r.WriteMapElemValue() + yym23 := z.EncBinary() + _ = yym23 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym25 := z.EncBinary() + _ = yym25 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `parallel`) + r.WriteMapElemValue() + yym26 := z.EncBinary() + _ = yym26 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *CreateStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *CreateStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "KV": + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv4 := &x.KV + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "NS": + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv6 := &x.NS + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*string)(yyv6)) = r.DecodeString() + } + } + case "DB": + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv8 := &x.DB + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + case "what": + if r.TryDecodeAsNil() { + x.What = nil + } else { + yyv10 := &x.What + yyv10.CodecDecodeSelf(d) + } + case "data": + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv11 := &x.Data + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + case "echo": + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv13 := &x.Echo + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else if yym14 { + z.DecBinaryUnmarshal(yyv13) + } else { + *((*int16)(yyv13)) = int16(r.DecodeInt(16)) + } + } + case "timeout": + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv15 := &x.Timeout + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else { + *((*int64)(yyv15)) = int64(r.DecodeInt(64)) + } + } + case "parallel": + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv17 := &x.Parallel + yym18 := z.DecBinary() + _ = yym18 + if false { + } else { + *((*int)(yyv17)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *CreateStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj19 int + var yyb19 bool + var yyhl19 bool = l >= 0 + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv20 := &x.KV + yym21 := z.DecBinary() + _ = yym21 + if false { + } else { + *((*string)(yyv20)) = r.DecodeString() + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv22 := &x.NS + yym23 := z.DecBinary() + _ = yym23 + if false { + } else { + *((*string)(yyv22)) = r.DecodeString() + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv24 := &x.DB + yym25 := z.DecBinary() + _ = yym25 + if false { + } else { + *((*string)(yyv24)) = r.DecodeString() + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.What = nil + } else { + yyv26 := &x.What + yyv26.CodecDecodeSelf(d) + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv27 := &x.Data + yym28 := z.DecBinary() + _ = yym28 + if false { + } else if z.HasExtensions() && z.DecExt(yyv27) { + } else { + z.DecFallback(yyv27, true) + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv29 := &x.Echo + yym30 := z.DecBinary() + _ = yym30 + if false { + } else if z.HasExtensions() && z.DecExt(yyv29) { + } else if yym30 { + z.DecBinaryUnmarshal(yyv29) + } else { + *((*int16)(yyv29)) = int16(r.DecodeInt(16)) + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv31 := &x.Timeout + yym32 := z.DecBinary() + _ = yym32 + if false { + } else if z.HasExtensions() && z.DecExt(yyv31) { + } else { + *((*int64)(yyv31)) = int64(r.DecodeInt(64)) + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv33 := &x.Parallel + yym34 := z.DecBinary() + _ = yym34 + if false { + } else { + *((*int)(yyv33)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + for { + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj19-1, "") + } + r.ReadArrayEnd() +} + +func (x *UpdateStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(9) + } else { + r.WriteMapStart(9) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `KV`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `NS`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `DB`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `what`) + r.WriteMapElemValue() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Data == nil { + r.EncodeNil() + } else { + yym16 := z.EncBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `data`) + r.WriteMapElemValue() + if x.Data == nil { + r.EncodeNil() + } else { + yym17 := z.EncBinary() + _ = yym17 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Cond == nil { + r.EncodeNil() + } else { + yym19 := z.EncBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `cond`) + r.WriteMapElemValue() + if x.Cond == nil { + r.EncodeNil() + } else { + yym20 := z.EncBinary() + _ = yym20 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym22 := z.EncBinary() + _ = yym22 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym22 { + z.EncBinaryMarshal(x.Echo) + } else if !yym22 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `echo`) + r.WriteMapElemValue() + yym23 := z.EncBinary() + _ = yym23 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym23 { + z.EncBinaryMarshal(x.Echo) + } else if !yym23 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym25 := z.EncBinary() + _ = yym25 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `timeout`) + r.WriteMapElemValue() + yym26 := z.EncBinary() + _ = yym26 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym28 := z.EncBinary() + _ = yym28 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `parallel`) + r.WriteMapElemValue() + yym29 := z.EncBinary() + _ = yym29 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *UpdateStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *UpdateStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "KV": + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv4 := &x.KV + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "NS": + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv6 := &x.NS + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*string)(yyv6)) = r.DecodeString() + } + } + case "DB": + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv8 := &x.DB + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + case "what": + if r.TryDecodeAsNil() { + x.What = nil + } else { + yyv10 := &x.What + yyv10.CodecDecodeSelf(d) + } + case "data": + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv11 := &x.Data + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + case "cond": + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv13 := &x.Cond + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else { + z.DecFallback(yyv13, true) + } + } + case "echo": + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv15 := &x.Echo + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else if yym16 { + z.DecBinaryUnmarshal(yyv15) + } else { + *((*int16)(yyv15)) = int16(r.DecodeInt(16)) + } + } + case "timeout": + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv17 := &x.Timeout + yym18 := z.DecBinary() + _ = yym18 + if false { + } else if z.HasExtensions() && z.DecExt(yyv17) { + } else { + *((*int64)(yyv17)) = int64(r.DecodeInt(64)) + } + } + case "parallel": + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv19 := &x.Parallel + yym20 := z.DecBinary() + _ = yym20 + if false { + } else { + *((*int)(yyv19)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *UpdateStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj21 int + var yyb21 bool + var yyhl21 bool = l >= 0 + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv22 := &x.KV + yym23 := z.DecBinary() + _ = yym23 + if false { + } else { + *((*string)(yyv22)) = r.DecodeString() + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv24 := &x.NS + yym25 := z.DecBinary() + _ = yym25 + if false { + } else { + *((*string)(yyv24)) = r.DecodeString() + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv26 := &x.DB + yym27 := z.DecBinary() + _ = yym27 + if false { + } else { + *((*string)(yyv26)) = r.DecodeString() + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.What = nil + } else { + yyv28 := &x.What + yyv28.CodecDecodeSelf(d) + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv29 := &x.Data + yym30 := z.DecBinary() + _ = yym30 + if false { + } else if z.HasExtensions() && z.DecExt(yyv29) { + } else { + z.DecFallback(yyv29, true) + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv31 := &x.Cond + yym32 := z.DecBinary() + _ = yym32 + if false { + } else if z.HasExtensions() && z.DecExt(yyv31) { + } else { + z.DecFallback(yyv31, true) + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv33 := &x.Echo + yym34 := z.DecBinary() + _ = yym34 + if false { + } else if z.HasExtensions() && z.DecExt(yyv33) { + } else if yym34 { + z.DecBinaryUnmarshal(yyv33) + } else { + *((*int16)(yyv33)) = int16(r.DecodeInt(16)) + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv35 := &x.Timeout + yym36 := z.DecBinary() + _ = yym36 + if false { + } else if z.HasExtensions() && z.DecExt(yyv35) { + } else { + *((*int64)(yyv35)) = int64(r.DecodeInt(64)) + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv37 := &x.Parallel + yym38 := z.DecBinary() + _ = yym38 + if false { + } else { + *((*int)(yyv37)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + for { + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj21-1, "") + } + r.ReadArrayEnd() +} + +func (x *DeleteStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(9) + } else { + r.WriteMapStart(9) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `KV`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `NS`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `DB`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym13 := z.EncBinary() + _ = yym13 + if false { + } else { + r.EncodeBool(bool(x.Hard)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `hard`) + r.WriteMapElemValue() + yym14 := z.EncBinary() + _ = yym14 + if false { + } else { + r.EncodeBool(bool(x.Hard)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `what`) + r.WriteMapElemValue() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Cond == nil { + r.EncodeNil() + } else { + yym19 := z.EncBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `cond`) + r.WriteMapElemValue() + if x.Cond == nil { + r.EncodeNil() + } else { + yym20 := z.EncBinary() + _ = yym20 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym22 := z.EncBinary() + _ = yym22 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym22 { + z.EncBinaryMarshal(x.Echo) + } else if !yym22 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `echo`) + r.WriteMapElemValue() + yym23 := z.EncBinary() + _ = yym23 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym23 { + z.EncBinaryMarshal(x.Echo) + } else if !yym23 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym25 := z.EncBinary() + _ = yym25 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `timeout`) + r.WriteMapElemValue() + yym26 := z.EncBinary() + _ = yym26 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym28 := z.EncBinary() + _ = yym28 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `parallel`) + r.WriteMapElemValue() + yym29 := z.EncBinary() + _ = yym29 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DeleteStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DeleteStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "KV": + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv4 := &x.KV + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "NS": + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv6 := &x.NS + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*string)(yyv6)) = r.DecodeString() + } + } + case "DB": + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv8 := &x.DB + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + case "hard": + if r.TryDecodeAsNil() { + x.Hard = false + } else { + yyv10 := &x.Hard + yym11 := z.DecBinary() + _ = yym11 + if false { + } else { + *((*bool)(yyv10)) = r.DecodeBool() + } + } + case "what": + if r.TryDecodeAsNil() { + x.What = nil + } else { + yyv12 := &x.What + yyv12.CodecDecodeSelf(d) + } + case "cond": + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv13 := &x.Cond + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else { + z.DecFallback(yyv13, true) + } + } + case "echo": + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv15 := &x.Echo + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else if yym16 { + z.DecBinaryUnmarshal(yyv15) + } else { + *((*int16)(yyv15)) = int16(r.DecodeInt(16)) + } + } + case "timeout": + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv17 := &x.Timeout + yym18 := z.DecBinary() + _ = yym18 + if false { + } else if z.HasExtensions() && z.DecExt(yyv17) { + } else { + *((*int64)(yyv17)) = int64(r.DecodeInt(64)) + } + } + case "parallel": + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv19 := &x.Parallel + yym20 := z.DecBinary() + _ = yym20 + if false { + } else { + *((*int)(yyv19)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DeleteStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj21 int + var yyb21 bool + var yyhl21 bool = l >= 0 + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv22 := &x.KV + yym23 := z.DecBinary() + _ = yym23 + if false { + } else { + *((*string)(yyv22)) = r.DecodeString() + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv24 := &x.NS + yym25 := z.DecBinary() + _ = yym25 + if false { + } else { + *((*string)(yyv24)) = r.DecodeString() + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv26 := &x.DB + yym27 := z.DecBinary() + _ = yym27 + if false { + } else { + *((*string)(yyv26)) = r.DecodeString() + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Hard = false + } else { + yyv28 := &x.Hard + yym29 := z.DecBinary() + _ = yym29 + if false { + } else { + *((*bool)(yyv28)) = r.DecodeBool() + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.What = nil + } else { + yyv30 := &x.What + yyv30.CodecDecodeSelf(d) + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv31 := &x.Cond + yym32 := z.DecBinary() + _ = yym32 + if false { + } else if z.HasExtensions() && z.DecExt(yyv31) { + } else { + z.DecFallback(yyv31, true) + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv33 := &x.Echo + yym34 := z.DecBinary() + _ = yym34 + if false { + } else if z.HasExtensions() && z.DecExt(yyv33) { + } else if yym34 { + z.DecBinaryUnmarshal(yyv33) + } else { + *((*int16)(yyv33)) = int16(r.DecodeInt(16)) + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv35 := &x.Timeout + yym36 := z.DecBinary() + _ = yym36 + if false { + } else if z.HasExtensions() && z.DecExt(yyv35) { + } else { + *((*int64)(yyv35)) = int64(r.DecodeInt(64)) + } + } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv37 := &x.Parallel + yym38 := z.DecBinary() + _ = yym38 + if false { + } else { + *((*int)(yyv37)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + for { + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = r.CheckBreak() + } + if yyb21 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj21-1, "") + } + r.ReadArrayEnd() +} + +func (x *RelateStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(11) + } else { + r.WriteMapStart(11) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `KV`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `NS`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `DB`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Type == nil { + r.EncodeNil() + } else { + yym13 := z.EncBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.EncExt(x.Type) { + } else { + z.EncFallback(x.Type) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `type`) + r.WriteMapElemValue() + if x.Type == nil { + r.EncodeNil() + } else { + yym14 := z.EncBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.EncExt(x.Type) { + } else { + z.EncFallback(x.Type) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.From == nil { + r.EncodeNil() + } else { + x.From.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `from`) + r.WriteMapElemValue() + if x.From == nil { + r.EncodeNil() + } else { + x.From.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.With == nil { + r.EncodeNil() + } else { + x.With.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `with`) + r.WriteMapElemValue() + if x.With == nil { + r.EncodeNil() + } else { + x.With.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Data == nil { + r.EncodeNil() + } else { + yym22 := z.EncBinary() + _ = yym22 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `data`) + r.WriteMapElemValue() + if x.Data == nil { + r.EncodeNil() + } else { + yym23 := z.EncBinary() + _ = yym23 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym25 := z.EncBinary() + _ = yym25 + if false { + } else { + r.EncodeBool(bool(x.Uniq)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `uniq`) + r.WriteMapElemValue() + yym26 := z.EncBinary() + _ = yym26 + if false { + } else { + r.EncodeBool(bool(x.Uniq)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym28 := z.EncBinary() + _ = yym28 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym28 { + z.EncBinaryMarshal(x.Echo) + } else if !yym28 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `echo`) + r.WriteMapElemValue() + yym29 := z.EncBinary() + _ = yym29 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym29 { + z.EncBinaryMarshal(x.Echo) + } else if !yym29 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym31 := z.EncBinary() + _ = yym31 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `timeout`) + r.WriteMapElemValue() + yym32 := z.EncBinary() + _ = yym32 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym34 := z.EncBinary() + _ = yym34 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `parallel`) + r.WriteMapElemValue() + yym35 := z.EncBinary() + _ = yym35 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *RelateStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *RelateStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "KV": + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv4 := &x.KV + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "NS": + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv6 := &x.NS + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*string)(yyv6)) = r.DecodeString() + } + } + case "DB": + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv8 := &x.DB + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + case "type": + if r.TryDecodeAsNil() { + x.Type = nil + } else { + yyv10 := &x.Type + yym11 := z.DecBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.DecExt(yyv10) { + } else { + z.DecFallback(yyv10, true) + } + } + case "from": + if r.TryDecodeAsNil() { + x.From = nil + } else { + yyv12 := &x.From + yyv12.CodecDecodeSelf(d) + } + case "with": + if r.TryDecodeAsNil() { + x.With = nil + } else { + yyv13 := &x.With + yyv13.CodecDecodeSelf(d) + } + case "data": + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv14 := &x.Data + yym15 := z.DecBinary() + _ = yym15 + if false { + } else if z.HasExtensions() && z.DecExt(yyv14) { + } else { + z.DecFallback(yyv14, true) + } + } + case "uniq": + if r.TryDecodeAsNil() { + x.Uniq = false + } else { + yyv16 := &x.Uniq + yym17 := z.DecBinary() + _ = yym17 + if false { + } else { + *((*bool)(yyv16)) = r.DecodeBool() + } + } + case "echo": + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv18 := &x.Echo + yym19 := z.DecBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.DecExt(yyv18) { + } else if yym19 { + z.DecBinaryUnmarshal(yyv18) + } else { + *((*int16)(yyv18)) = int16(r.DecodeInt(16)) + } + } + case "timeout": + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv20 := &x.Timeout + yym21 := z.DecBinary() + _ = yym21 + if false { + } else if z.HasExtensions() && z.DecExt(yyv20) { + } else { + *((*int64)(yyv20)) = int64(r.DecodeInt(64)) + } + } + case "parallel": + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv22 := &x.Parallel + yym23 := z.DecBinary() + _ = yym23 + if false { + } else { + *((*int)(yyv22)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *RelateStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj24 int + var yyb24 bool + var yyhl24 bool = l >= 0 + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv25 := &x.KV + yym26 := z.DecBinary() + _ = yym26 + if false { + } else { + *((*string)(yyv25)) = r.DecodeString() + } + } + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv27 := &x.NS + yym28 := z.DecBinary() + _ = yym28 + if false { + } else { + *((*string)(yyv27)) = r.DecodeString() + } + } + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv29 := &x.DB + yym30 := z.DecBinary() + _ = yym30 + if false { + } else { + *((*string)(yyv29)) = r.DecodeString() + } + } + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Type = nil + } else { + yyv31 := &x.Type + yym32 := z.DecBinary() + _ = yym32 + if false { + } else if z.HasExtensions() && z.DecExt(yyv31) { + } else { + z.DecFallback(yyv31, true) + } + } + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.From = nil + } else { + yyv33 := &x.From + yyv33.CodecDecodeSelf(d) + } + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.With = nil + } else { + yyv34 := &x.With + yyv34.CodecDecodeSelf(d) + } + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv35 := &x.Data + yym36 := z.DecBinary() + _ = yym36 + if false { + } else if z.HasExtensions() && z.DecExt(yyv35) { + } else { + z.DecFallback(yyv35, true) + } + } + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Uniq = false + } else { + yyv37 := &x.Uniq + yym38 := z.DecBinary() + _ = yym38 + if false { + } else { + *((*bool)(yyv37)) = r.DecodeBool() + } + } + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv39 := &x.Echo + yym40 := z.DecBinary() + _ = yym40 + if false { + } else if z.HasExtensions() && z.DecExt(yyv39) { + } else if yym40 { + z.DecBinaryUnmarshal(yyv39) + } else { + *((*int16)(yyv39)) = int16(r.DecodeInt(16)) + } + } + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv41 := &x.Timeout + yym42 := z.DecBinary() + _ = yym42 + if false { + } else if z.HasExtensions() && z.DecExt(yyv41) { + } else { + *((*int64)(yyv41)) = int64(r.DecodeInt(64)) + } + } + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv43 := &x.Parallel + yym44 := z.DecBinary() + _ = yym44 + if false { + } else { + *((*int)(yyv43)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + for { + yyj24++ + if yyhl24 { + yyb24 = yyj24 > l + } else { + yyb24 = r.CheckBreak() + } + if yyb24 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj24-1, "") + } + r.ReadArrayEnd() +} + +func (x *InsertStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(8) + } else { + r.WriteMapStart(8) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `KV`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `NS`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `DB`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Data == nil { + r.EncodeNil() + } else { + yym13 := z.EncBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `data`) + r.WriteMapElemValue() + if x.Data == nil { + r.EncodeNil() + } else { + yym14 := z.EncBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } + var yyn15 bool + if x.Into == nil { + yyn15 = true + goto LABEL15 + } + LABEL15: + if yyr2 || yy2arr2 { + if yyn15 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Into == nil { + r.EncodeNil() + } else { + x.Into.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `into`) + r.WriteMapElemValue() + if yyn15 { + r.EncodeNil() + } else { + if x.Into == nil { + r.EncodeNil() + } else { + x.Into.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym19 := z.EncBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym19 { + z.EncBinaryMarshal(x.Echo) + } else if !yym19 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `echo`) + r.WriteMapElemValue() + yym20 := z.EncBinary() + _ = yym20 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym20 { + z.EncBinaryMarshal(x.Echo) + } else if !yym20 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym22 := z.EncBinary() + _ = yym22 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `timeout`) + r.WriteMapElemValue() + yym23 := z.EncBinary() + _ = yym23 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym25 := z.EncBinary() + _ = yym25 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `parallel`) + r.WriteMapElemValue() + yym26 := z.EncBinary() + _ = yym26 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *InsertStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *InsertStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "KV": + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv4 := &x.KV + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "NS": + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv6 := &x.NS + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*string)(yyv6)) = r.DecodeString() + } + } + case "DB": + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv8 := &x.DB + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + case "data": + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv10 := &x.Data + yym11 := z.DecBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.DecExt(yyv10) { + } else { + z.DecFallback(yyv10, true) + } + } + case "into": + if x.Into == nil { + x.Into = new(Table) + } + if r.TryDecodeAsNil() { + if x.Into != nil { + x.Into = nil + } + } else { + if x.Into == nil { + x.Into = new(Table) + } + x.Into.CodecDecodeSelf(d) + } + case "echo": + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv13 := &x.Echo + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else if yym14 { + z.DecBinaryUnmarshal(yyv13) + } else { + *((*int16)(yyv13)) = int16(r.DecodeInt(16)) + } + } + case "timeout": + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv15 := &x.Timeout + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else { + *((*int64)(yyv15)) = int64(r.DecodeInt(64)) + } + } + case "parallel": + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv17 := &x.Parallel + yym18 := z.DecBinary() + _ = yym18 + if false { + } else { + *((*int)(yyv17)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *InsertStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj19 int + var yyb19 bool + var yyhl19 bool = l >= 0 + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv20 := &x.KV + yym21 := z.DecBinary() + _ = yym21 + if false { + } else { + *((*string)(yyv20)) = r.DecodeString() + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv22 := &x.NS + yym23 := z.DecBinary() + _ = yym23 + if false { + } else { + *((*string)(yyv22)) = r.DecodeString() + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv24 := &x.DB + yym25 := z.DecBinary() + _ = yym25 + if false { + } else { + *((*string)(yyv24)) = r.DecodeString() + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv26 := &x.Data + yym27 := z.DecBinary() + _ = yym27 + if false { + } else if z.HasExtensions() && z.DecExt(yyv26) { + } else { + z.DecFallback(yyv26, true) + } + } + if x.Into == nil { + x.Into = new(Table) + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Into != nil { + x.Into = nil + } + } else { + if x.Into == nil { + x.Into = new(Table) + } + x.Into.CodecDecodeSelf(d) + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv29 := &x.Echo + yym30 := z.DecBinary() + _ = yym30 + if false { + } else if z.HasExtensions() && z.DecExt(yyv29) { + } else if yym30 { + z.DecBinaryUnmarshal(yyv29) + } else { + *((*int16)(yyv29)) = int16(r.DecodeInt(16)) + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv31 := &x.Timeout + yym32 := z.DecBinary() + _ = yym32 + if false { + } else if z.HasExtensions() && z.DecExt(yyv31) { + } else { + *((*int64)(yyv31)) = int64(r.DecodeInt(64)) + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv33 := &x.Parallel + yym34 := z.DecBinary() + _ = yym34 + if false { + } else { + *((*int)(yyv33)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + for { + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj19-1, "") + } + r.ReadArrayEnd() +} + +func (x *UpsertStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(8) + } else { + r.WriteMapStart(8) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `KV`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.KV)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `NS`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.NS)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `DB`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.DB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Data == nil { + r.EncodeNil() + } else { + yym13 := z.EncBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `data`) + r.WriteMapElemValue() + if x.Data == nil { + r.EncodeNil() + } else { + yym14 := z.EncBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } + var yyn15 bool + if x.Into == nil { + yyn15 = true + goto LABEL15 + } + LABEL15: + if yyr2 || yy2arr2 { + if yyn15 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Into == nil { + r.EncodeNil() + } else { + x.Into.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `into`) + r.WriteMapElemValue() + if yyn15 { + r.EncodeNil() + } else { + if x.Into == nil { + r.EncodeNil() + } else { + x.Into.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym19 := z.EncBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym19 { + z.EncBinaryMarshal(x.Echo) + } else if !yym19 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `echo`) + r.WriteMapElemValue() + yym20 := z.EncBinary() + _ = yym20 + if false { + } else if z.HasExtensions() && z.EncExt(x.Echo) { + } else if yym20 { + z.EncBinaryMarshal(x.Echo) + } else if !yym20 { + z.EncTextMarshal(x.Echo) + } else { + r.EncodeInt(int64(x.Echo)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym22 := z.EncBinary() + _ = yym22 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `timeout`) + r.WriteMapElemValue() + yym23 := z.EncBinary() + _ = yym23 + if false { + } else if z.HasExtensions() && z.EncExt(x.Timeout) { + } else { + r.EncodeInt(int64(x.Timeout)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym25 := z.EncBinary() + _ = yym25 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `parallel`) + r.WriteMapElemValue() + yym26 := z.EncBinary() + _ = yym26 + if false { + } else { + r.EncodeInt(int64(x.Parallel)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *UpsertStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *UpsertStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "KV": + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv4 := &x.KV + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "NS": + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv6 := &x.NS + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*string)(yyv6)) = r.DecodeString() + } + } + case "DB": + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv8 := &x.DB + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + case "data": + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv10 := &x.Data + yym11 := z.DecBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.DecExt(yyv10) { + } else { + z.DecFallback(yyv10, true) + } + } + case "into": + if x.Into == nil { + x.Into = new(Table) + } + if r.TryDecodeAsNil() { + if x.Into != nil { + x.Into = nil + } + } else { + if x.Into == nil { + x.Into = new(Table) + } + x.Into.CodecDecodeSelf(d) + } + case "echo": + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv13 := &x.Echo + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else if yym14 { + z.DecBinaryUnmarshal(yyv13) + } else { + *((*int16)(yyv13)) = int16(r.DecodeInt(16)) + } + } + case "timeout": + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv15 := &x.Timeout + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else { + *((*int64)(yyv15)) = int64(r.DecodeInt(64)) + } + } + case "parallel": + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv17 := &x.Parallel + yym18 := z.DecBinary() + _ = yym18 + if false { + } else { + *((*int)(yyv17)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *UpsertStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj19 int + var yyb19 bool + var yyhl19 bool = l >= 0 + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.KV = "" + } else { + yyv20 := &x.KV + yym21 := z.DecBinary() + _ = yym21 + if false { + } else { + *((*string)(yyv20)) = r.DecodeString() + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.NS = "" + } else { + yyv22 := &x.NS + yym23 := z.DecBinary() + _ = yym23 + if false { + } else { + *((*string)(yyv22)) = r.DecodeString() + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.DB = "" + } else { + yyv24 := &x.DB + yym25 := z.DecBinary() + _ = yym25 + if false { + } else { + *((*string)(yyv24)) = r.DecodeString() + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv26 := &x.Data + yym27 := z.DecBinary() + _ = yym27 + if false { + } else if z.HasExtensions() && z.DecExt(yyv26) { + } else { + z.DecFallback(yyv26, true) + } + } + if x.Into == nil { + x.Into = new(Table) + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Into != nil { + x.Into = nil + } + } else { + if x.Into == nil { + x.Into = new(Table) + } + x.Into.CodecDecodeSelf(d) + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Echo = 0 + } else { + yyv29 := &x.Echo + yym30 := z.DecBinary() + _ = yym30 + if false { + } else if z.HasExtensions() && z.DecExt(yyv29) { + } else if yym30 { + z.DecBinaryUnmarshal(yyv29) + } else { + *((*int16)(yyv29)) = int16(r.DecodeInt(16)) + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Timeout = 0 + } else { + yyv31 := &x.Timeout + yym32 := z.DecBinary() + _ = yym32 + if false { + } else if z.HasExtensions() && z.DecExt(yyv31) { + } else { + *((*int64)(yyv31)) = int64(r.DecodeInt(64)) + } + } + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Parallel = 0 + } else { + yyv33 := &x.Parallel + yym34 := z.DecBinary() + _ = yym34 + if false { + } else { + *((*int)(yyv33)) = int(r.DecodeInt(codecSelferBitsize4085)) + } + } + for { + yyj19++ + if yyhl19 { + yyb19 = yyj19 > l + } else { + yyb19 = r.CheckBreak() + } + if yyb19 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj19-1, "") + } + r.ReadArrayEnd() +} + +func (x *DefineNamespaceStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + var yyn3 bool + if x.Name == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DefineNamespaceStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DefineNamespaceStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DefineNamespaceStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj5 int + var yyb5 bool + var yyhl5 bool = l >= 0 + if x.Name == nil { + x.Name = new(Ident) + } + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + for { + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj5-1, "") + } + r.ReadArrayEnd() +} + +func (x *RemoveNamespaceStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + var yyn3 bool + if x.Name == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *RemoveNamespaceStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *RemoveNamespaceStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *RemoveNamespaceStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj5 int + var yyb5 bool + var yyhl5 bool = l >= 0 + if x.Name == nil { + x.Name = new(Ident) + } + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + for { + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj5-1, "") + } + r.ReadArrayEnd() +} + +func (x *DefineDatabaseStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + var yyn3 bool + if x.Name == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DefineDatabaseStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DefineDatabaseStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DefineDatabaseStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj5 int + var yyb5 bool + var yyhl5 bool = l >= 0 + if x.Name == nil { + x.Name = new(Ident) + } + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + for { + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj5-1, "") + } + r.ReadArrayEnd() +} + +func (x *RemoveDatabaseStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + var yyn3 bool + if x.Name == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *RemoveDatabaseStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *RemoveDatabaseStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *RemoveDatabaseStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj5 int + var yyb5 bool + var yyhl5 bool = l >= 0 + if x.Name == nil { + x.Name = new(Ident) + } + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + for { + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj5-1, "") + } + r.ReadArrayEnd() +} + +func (x *DefineLoginStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(4) + } else { + r.WriteMapStart(4) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Kind) { + } else if yym4 { + z.EncBinaryMarshal(x.Kind) + } else if !yym4 { + z.EncTextMarshal(x.Kind) + } else { + r.EncodeInt(int64(x.Kind)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `kind`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Kind) { + } else if yym5 { + z.EncBinaryMarshal(x.Kind) + } else if !yym5 { + z.EncTextMarshal(x.Kind) + } else { + r.EncodeInt(int64(x.Kind)) + } + } + var yyn6 bool + if x.User == nil { + yyn6 = true + goto LABEL6 + } + LABEL6: + if yyr2 || yy2arr2 { + if yyn6 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.User == nil { + r.EncodeNil() + } else { + x.User.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `user`) + r.WriteMapElemValue() + if yyn6 { + r.EncodeNil() + } else { + if x.User == nil { + r.EncodeNil() + } else { + x.User.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Pass == nil { + r.EncodeNil() + } else { + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeStringBytes(codecSelferCcRAW4085, []byte(x.Pass)) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `pass`) + r.WriteMapElemValue() + if x.Pass == nil { + r.EncodeNil() + } else { + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeStringBytes(codecSelferCcRAW4085, []byte(x.Pass)) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Code == nil { + r.EncodeNil() + } else { + yym13 := z.EncBinary() + _ = yym13 + if false { + } else { + r.EncodeStringBytes(codecSelferCcRAW4085, []byte(x.Code)) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `code`) + r.WriteMapElemValue() + if x.Code == nil { + r.EncodeNil() + } else { + yym14 := z.EncBinary() + _ = yym14 + if false { + } else { + r.EncodeStringBytes(codecSelferCcRAW4085, []byte(x.Code)) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DefineLoginStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DefineLoginStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "kind": + if r.TryDecodeAsNil() { + x.Kind = 0 + } else { + yyv4 := &x.Kind + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else if yym5 { + z.DecBinaryUnmarshal(yyv4) + } else { + *((*int16)(yyv4)) = int16(r.DecodeInt(16)) + } + } + case "user": + if x.User == nil { + x.User = new(Ident) + } + if r.TryDecodeAsNil() { + if x.User != nil { + x.User = nil + } + } else { + if x.User == nil { + x.User = new(Ident) + } + x.User.CodecDecodeSelf(d) + } + case "pass": + if r.TryDecodeAsNil() { + x.Pass = nil + } else { + yyv7 := &x.Pass + yym8 := z.DecBinary() + _ = yym8 + if false { + } else { + *yyv7 = r.DecodeBytes(*(*[]byte)(yyv7), false) + } + } + case "code": + if r.TryDecodeAsNil() { + x.Code = nil + } else { + yyv9 := &x.Code + yym10 := z.DecBinary() + _ = yym10 + if false { + } else { + *yyv9 = r.DecodeBytes(*(*[]byte)(yyv9), false) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DefineLoginStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj11 int + var yyb11 bool + var yyhl11 bool = l >= 0 + yyj11++ + if yyhl11 { + yyb11 = yyj11 > l + } else { + yyb11 = r.CheckBreak() + } + if yyb11 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Kind = 0 + } else { + yyv12 := &x.Kind + yym13 := z.DecBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.DecExt(yyv12) { + } else if yym13 { + z.DecBinaryUnmarshal(yyv12) + } else { + *((*int16)(yyv12)) = int16(r.DecodeInt(16)) + } + } + if x.User == nil { + x.User = new(Ident) + } + yyj11++ + if yyhl11 { + yyb11 = yyj11 > l + } else { + yyb11 = r.CheckBreak() + } + if yyb11 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.User != nil { + x.User = nil + } + } else { + if x.User == nil { + x.User = new(Ident) + } + x.User.CodecDecodeSelf(d) + } + yyj11++ + if yyhl11 { + yyb11 = yyj11 > l + } else { + yyb11 = r.CheckBreak() + } + if yyb11 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Pass = nil + } else { + yyv15 := &x.Pass + yym16 := z.DecBinary() + _ = yym16 + if false { + } else { + *yyv15 = r.DecodeBytes(*(*[]byte)(yyv15), false) + } + } + yyj11++ + if yyhl11 { + yyb11 = yyj11 > l + } else { + yyb11 = r.CheckBreak() + } + if yyb11 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Code = nil + } else { + yyv17 := &x.Code + yym18 := z.DecBinary() + _ = yym18 + if false { + } else { + *yyv17 = r.DecodeBytes(*(*[]byte)(yyv17), false) + } + } + for { + yyj11++ + if yyhl11 { + yyb11 = yyj11 > l + } else { + yyb11 = r.CheckBreak() + } + if yyb11 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj11-1, "") + } + r.ReadArrayEnd() +} + +func (x *RemoveLoginStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(2) + } else { + r.WriteMapStart(2) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Kind) { + } else if yym4 { + z.EncBinaryMarshal(x.Kind) + } else if !yym4 { + z.EncTextMarshal(x.Kind) + } else { + r.EncodeInt(int64(x.Kind)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `kind`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Kind) { + } else if yym5 { + z.EncBinaryMarshal(x.Kind) + } else if !yym5 { + z.EncTextMarshal(x.Kind) + } else { + r.EncodeInt(int64(x.Kind)) + } + } + var yyn6 bool + if x.User == nil { + yyn6 = true + goto LABEL6 + } + LABEL6: + if yyr2 || yy2arr2 { + if yyn6 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.User == nil { + r.EncodeNil() + } else { + x.User.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `user`) + r.WriteMapElemValue() + if yyn6 { + r.EncodeNil() + } else { + if x.User == nil { + r.EncodeNil() + } else { + x.User.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *RemoveLoginStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *RemoveLoginStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "kind": + if r.TryDecodeAsNil() { + x.Kind = 0 + } else { + yyv4 := &x.Kind + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else if yym5 { + z.DecBinaryUnmarshal(yyv4) + } else { + *((*int16)(yyv4)) = int16(r.DecodeInt(16)) + } + } + case "user": + if x.User == nil { + x.User = new(Ident) + } + if r.TryDecodeAsNil() { + if x.User != nil { + x.User = nil + } + } else { + if x.User == nil { + x.User = new(Ident) + } + x.User.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *RemoveLoginStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj7 int + var yyb7 bool + var yyhl7 bool = l >= 0 + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Kind = 0 + } else { + yyv8 := &x.Kind + yym9 := z.DecBinary() + _ = yym9 + if false { + } else if z.HasExtensions() && z.DecExt(yyv8) { + } else if yym9 { + z.DecBinaryUnmarshal(yyv8) + } else { + *((*int16)(yyv8)) = int16(r.DecodeInt(16)) + } + } + if x.User == nil { + x.User = new(Ident) + } + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.User != nil { + x.User = nil + } + } else { + if x.User == nil { + x.User = new(Ident) + } + x.User.CodecDecodeSelf(d) + } + for { + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj7-1, "") + } + r.ReadArrayEnd() +} + +func (x *DefineTokenStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(4) + } else { + r.WriteMapStart(4) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Kind) { + } else if yym4 { + z.EncBinaryMarshal(x.Kind) + } else if !yym4 { + z.EncTextMarshal(x.Kind) + } else { + r.EncodeInt(int64(x.Kind)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `kind`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Kind) { + } else if yym5 { + z.EncBinaryMarshal(x.Kind) + } else if !yym5 { + z.EncTextMarshal(x.Kind) + } else { + r.EncodeInt(int64(x.Kind)) + } + } + var yyn6 bool + if x.Name == nil { + yyn6 = true + goto LABEL6 + } + LABEL6: + if yyr2 || yy2arr2 { + if yyn6 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn6 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Type)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `type`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Type)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Code == nil { + r.EncodeNil() + } else { + yym13 := z.EncBinary() + _ = yym13 + if false { + } else { + r.EncodeStringBytes(codecSelferCcRAW4085, []byte(x.Code)) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `code`) + r.WriteMapElemValue() + if x.Code == nil { + r.EncodeNil() + } else { + yym14 := z.EncBinary() + _ = yym14 + if false { + } else { + r.EncodeStringBytes(codecSelferCcRAW4085, []byte(x.Code)) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DefineTokenStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DefineTokenStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "kind": + if r.TryDecodeAsNil() { + x.Kind = 0 + } else { + yyv4 := &x.Kind + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else if yym5 { + z.DecBinaryUnmarshal(yyv4) + } else { + *((*int16)(yyv4)) = int16(r.DecodeInt(16)) + } + } + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + case "type": + if r.TryDecodeAsNil() { + x.Type = "" + } else { + yyv7 := &x.Type + yym8 := z.DecBinary() + _ = yym8 + if false { + } else { + *((*string)(yyv7)) = r.DecodeString() + } + } + case "code": + if r.TryDecodeAsNil() { + x.Code = nil + } else { + yyv9 := &x.Code + yym10 := z.DecBinary() + _ = yym10 + if false { + } else { + *yyv9 = r.DecodeBytes(*(*[]byte)(yyv9), false) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DefineTokenStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj11 int + var yyb11 bool + var yyhl11 bool = l >= 0 + yyj11++ + if yyhl11 { + yyb11 = yyj11 > l + } else { + yyb11 = r.CheckBreak() + } + if yyb11 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Kind = 0 + } else { + yyv12 := &x.Kind + yym13 := z.DecBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.DecExt(yyv12) { + } else if yym13 { + z.DecBinaryUnmarshal(yyv12) + } else { + *((*int16)(yyv12)) = int16(r.DecodeInt(16)) + } + } + if x.Name == nil { + x.Name = new(Ident) + } + yyj11++ + if yyhl11 { + yyb11 = yyj11 > l + } else { + yyb11 = r.CheckBreak() + } + if yyb11 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + yyj11++ + if yyhl11 { + yyb11 = yyj11 > l + } else { + yyb11 = r.CheckBreak() + } + if yyb11 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Type = "" + } else { + yyv15 := &x.Type + yym16 := z.DecBinary() + _ = yym16 + if false { + } else { + *((*string)(yyv15)) = r.DecodeString() + } + } + yyj11++ + if yyhl11 { + yyb11 = yyj11 > l + } else { + yyb11 = r.CheckBreak() + } + if yyb11 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Code = nil + } else { + yyv17 := &x.Code + yym18 := z.DecBinary() + _ = yym18 + if false { + } else { + *yyv17 = r.DecodeBytes(*(*[]byte)(yyv17), false) + } + } + for { + yyj11++ + if yyhl11 { + yyb11 = yyj11 > l + } else { + yyb11 = r.CheckBreak() + } + if yyb11 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj11-1, "") + } + r.ReadArrayEnd() +} + +func (x *RemoveTokenStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(2) + } else { + r.WriteMapStart(2) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Kind) { + } else if yym4 { + z.EncBinaryMarshal(x.Kind) + } else if !yym4 { + z.EncTextMarshal(x.Kind) + } else { + r.EncodeInt(int64(x.Kind)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `kind`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Kind) { + } else if yym5 { + z.EncBinaryMarshal(x.Kind) + } else if !yym5 { + z.EncTextMarshal(x.Kind) + } else { + r.EncodeInt(int64(x.Kind)) + } + } + var yyn6 bool + if x.Name == nil { + yyn6 = true + goto LABEL6 + } + LABEL6: + if yyr2 || yy2arr2 { + if yyn6 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn6 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *RemoveTokenStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *RemoveTokenStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "kind": + if r.TryDecodeAsNil() { + x.Kind = 0 + } else { + yyv4 := &x.Kind + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else if yym5 { + z.DecBinaryUnmarshal(yyv4) + } else { + *((*int16)(yyv4)) = int16(r.DecodeInt(16)) + } + } + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *RemoveTokenStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj7 int + var yyb7 bool + var yyhl7 bool = l >= 0 + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Kind = 0 + } else { + yyv8 := &x.Kind + yym9 := z.DecBinary() + _ = yym9 + if false { + } else if z.HasExtensions() && z.DecExt(yyv8) { + } else if yym9 { + z.DecBinaryUnmarshal(yyv8) + } else { + *((*int16)(yyv8)) = int16(r.DecodeInt(16)) + } + } + if x.Name == nil { + x.Name = new(Ident) + } + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + for { + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj7-1, "") + } + r.ReadArrayEnd() +} + +func (x *DefineScopeStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(6) + } else { + r.WriteMapStart(6) + } + var yyn3 bool + if x.Name == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.EncExt(x.Time) { + } else { + r.EncodeInt(int64(x.Time)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `time`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.EncExt(x.Time) { + } else { + r.EncodeInt(int64(x.Time)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Code == nil { + r.EncodeNil() + } else { + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeStringBytes(codecSelferCcRAW4085, []byte(x.Code)) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `code`) + r.WriteMapElemValue() + if x.Code == nil { + r.EncodeNil() + } else { + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeStringBytes(codecSelferCcRAW4085, []byte(x.Code)) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Signup == nil { + r.EncodeNil() + } else { + yym13 := z.EncBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.EncExt(x.Signup) { + } else { + z.EncFallback(x.Signup) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `signup`) + r.WriteMapElemValue() + if x.Signup == nil { + r.EncodeNil() + } else { + yym14 := z.EncBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.EncExt(x.Signup) { + } else { + z.EncFallback(x.Signup) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Signin == nil { + r.EncodeNil() + } else { + yym16 := z.EncBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.EncExt(x.Signin) { + } else { + z.EncFallback(x.Signin) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `signin`) + r.WriteMapElemValue() + if x.Signin == nil { + r.EncodeNil() + } else { + yym17 := z.EncBinary() + _ = yym17 + if false { + } else if z.HasExtensions() && z.EncExt(x.Signin) { + } else { + z.EncFallback(x.Signin) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Connect == nil { + r.EncodeNil() + } else { + yym19 := z.EncBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.EncExt(x.Connect) { + } else { + z.EncFallback(x.Connect) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `connect`) + r.WriteMapElemValue() + if x.Connect == nil { + r.EncodeNil() + } else { + yym20 := z.EncBinary() + _ = yym20 + if false { + } else if z.HasExtensions() && z.EncExt(x.Connect) { + } else { + z.EncFallback(x.Connect) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DefineScopeStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DefineScopeStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + case "time": + if r.TryDecodeAsNil() { + x.Time = 0 + } else { + yyv5 := &x.Time + yym6 := z.DecBinary() + _ = yym6 + if false { + } else if z.HasExtensions() && z.DecExt(yyv5) { + } else { + *((*int64)(yyv5)) = int64(r.DecodeInt(64)) + } + } + case "code": + if r.TryDecodeAsNil() { + x.Code = nil + } else { + yyv7 := &x.Code + yym8 := z.DecBinary() + _ = yym8 + if false { + } else { + *yyv7 = r.DecodeBytes(*(*[]byte)(yyv7), false) + } + } + case "signup": + if r.TryDecodeAsNil() { + x.Signup = nil + } else { + yyv9 := &x.Signup + yym10 := z.DecBinary() + _ = yym10 + if false { + } else if z.HasExtensions() && z.DecExt(yyv9) { + } else { + z.DecFallback(yyv9, true) + } + } + case "signin": + if r.TryDecodeAsNil() { + x.Signin = nil + } else { + yyv11 := &x.Signin + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + case "connect": + if r.TryDecodeAsNil() { + x.Connect = nil + } else { + yyv13 := &x.Connect + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else { + z.DecFallback(yyv13, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DefineScopeStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj15 int + var yyb15 bool + var yyhl15 bool = l >= 0 + if x.Name == nil { + x.Name = new(Ident) + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Time = 0 + } else { + yyv17 := &x.Time + yym18 := z.DecBinary() + _ = yym18 + if false { + } else if z.HasExtensions() && z.DecExt(yyv17) { + } else { + *((*int64)(yyv17)) = int64(r.DecodeInt(64)) + } + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Code = nil + } else { + yyv19 := &x.Code + yym20 := z.DecBinary() + _ = yym20 + if false { + } else { + *yyv19 = r.DecodeBytes(*(*[]byte)(yyv19), false) + } + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Signup = nil + } else { + yyv21 := &x.Signup + yym22 := z.DecBinary() + _ = yym22 + if false { + } else if z.HasExtensions() && z.DecExt(yyv21) { + } else { + z.DecFallback(yyv21, true) + } + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Signin = nil + } else { + yyv23 := &x.Signin + yym24 := z.DecBinary() + _ = yym24 + if false { + } else if z.HasExtensions() && z.DecExt(yyv23) { + } else { + z.DecFallback(yyv23, true) + } + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Connect = nil + } else { + yyv25 := &x.Connect + yym26 := z.DecBinary() + _ = yym26 + if false { + } else if z.HasExtensions() && z.DecExt(yyv25) { + } else { + z.DecFallback(yyv25, true) + } + } + for { + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj15-1, "") + } + r.ReadArrayEnd() +} + +func (x *RemoveScopeStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + var yyn3 bool + if x.Name == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *RemoveScopeStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *RemoveScopeStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *RemoveScopeStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj5 int + var yyb5 bool + var yyhl5 bool = l >= 0 + if x.Name == nil { + x.Name = new(Ident) + } + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + for { + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj5-1, "") + } + r.ReadArrayEnd() +} + +func (x *DefineTableStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(9) + } else { + r.WriteMapStart(9) + } + var yyn3 bool + if x.Name == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeBool(bool(x.Full)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `full`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeBool(bool(x.Full)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeBool(bool(x.Drop)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `drop`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeBool(bool(x.Drop)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym13 := z.EncBinary() + _ = yym13 + if false { + } else { + r.EncodeBool(bool(x.Lock)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `lock`) + r.WriteMapElemValue() + yym14 := z.EncBinary() + _ = yym14 + if false { + } else { + r.EncodeBool(bool(x.Lock)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Expr == nil { + r.EncodeNil() + } else { + x.Expr.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `expr`) + r.WriteMapElemValue() + if x.Expr == nil { + r.EncodeNil() + } else { + x.Expr.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.From == nil { + r.EncodeNil() + } else { + x.From.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `from`) + r.WriteMapElemValue() + if x.From == nil { + r.EncodeNil() + } else { + x.From.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Cond == nil { + r.EncodeNil() + } else { + yym22 := z.EncBinary() + _ = yym22 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `cond`) + r.WriteMapElemValue() + if x.Cond == nil { + r.EncodeNil() + } else { + yym23 := z.EncBinary() + _ = yym23 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Group == nil { + r.EncodeNil() + } else { + x.Group.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `group`) + r.WriteMapElemValue() + if x.Group == nil { + r.EncodeNil() + } else { + x.Group.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Perms == nil { + r.EncodeNil() + } else { + yym28 := z.EncBinary() + _ = yym28 + if false { + } else if z.HasExtensions() && z.EncExt(x.Perms) { + } else { + z.EncFallback(x.Perms) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `perms`) + r.WriteMapElemValue() + if x.Perms == nil { + r.EncodeNil() + } else { + yym29 := z.EncBinary() + _ = yym29 + if false { + } else if z.HasExtensions() && z.EncExt(x.Perms) { + } else { + z.EncFallback(x.Perms) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DefineTableStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DefineTableStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + case "full": + if r.TryDecodeAsNil() { + x.Full = false + } else { + yyv5 := &x.Full + yym6 := z.DecBinary() + _ = yym6 + if false { + } else { + *((*bool)(yyv5)) = r.DecodeBool() + } + } + case "drop": + if r.TryDecodeAsNil() { + x.Drop = false + } else { + yyv7 := &x.Drop + yym8 := z.DecBinary() + _ = yym8 + if false { + } else { + *((*bool)(yyv7)) = r.DecodeBool() + } + } + case "lock": + if r.TryDecodeAsNil() { + x.Lock = false + } else { + yyv9 := &x.Lock + yym10 := z.DecBinary() + _ = yym10 + if false { + } else { + *((*bool)(yyv9)) = r.DecodeBool() + } + } + case "expr": + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv11 := &x.Expr + yyv11.CodecDecodeSelf(d) + } + case "from": + if r.TryDecodeAsNil() { + x.From = nil + } else { + yyv12 := &x.From + yyv12.CodecDecodeSelf(d) + } + case "cond": + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv13 := &x.Cond + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else { + z.DecFallback(yyv13, true) + } + } + case "group": + if r.TryDecodeAsNil() { + x.Group = nil + } else { + yyv15 := &x.Group + yyv15.CodecDecodeSelf(d) + } + case "perms": + if r.TryDecodeAsNil() { + x.Perms = nil + } else { + yyv16 := &x.Perms + yym17 := z.DecBinary() + _ = yym17 + if false { + } else if z.HasExtensions() && z.DecExt(yyv16) { + } else { + z.DecFallback(yyv16, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DefineTableStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj18 int + var yyb18 bool + var yyhl18 bool = l >= 0 + if x.Name == nil { + x.Name = new(Ident) + } + yyj18++ + if yyhl18 { + yyb18 = yyj18 > l + } else { + yyb18 = r.CheckBreak() + } + if yyb18 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + yyj18++ + if yyhl18 { + yyb18 = yyj18 > l + } else { + yyb18 = r.CheckBreak() + } + if yyb18 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Full = false + } else { + yyv20 := &x.Full + yym21 := z.DecBinary() + _ = yym21 + if false { + } else { + *((*bool)(yyv20)) = r.DecodeBool() + } + } + yyj18++ + if yyhl18 { + yyb18 = yyj18 > l + } else { + yyb18 = r.CheckBreak() + } + if yyb18 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Drop = false + } else { + yyv22 := &x.Drop + yym23 := z.DecBinary() + _ = yym23 + if false { + } else { + *((*bool)(yyv22)) = r.DecodeBool() + } + } + yyj18++ + if yyhl18 { + yyb18 = yyj18 > l + } else { + yyb18 = r.CheckBreak() + } + if yyb18 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Lock = false + } else { + yyv24 := &x.Lock + yym25 := z.DecBinary() + _ = yym25 + if false { + } else { + *((*bool)(yyv24)) = r.DecodeBool() + } + } + yyj18++ + if yyhl18 { + yyb18 = yyj18 > l + } else { + yyb18 = r.CheckBreak() + } + if yyb18 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv26 := &x.Expr + yyv26.CodecDecodeSelf(d) + } + yyj18++ + if yyhl18 { + yyb18 = yyj18 > l + } else { + yyb18 = r.CheckBreak() + } + if yyb18 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.From = nil + } else { + yyv27 := &x.From + yyv27.CodecDecodeSelf(d) + } + yyj18++ + if yyhl18 { + yyb18 = yyj18 > l + } else { + yyb18 = r.CheckBreak() + } + if yyb18 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv28 := &x.Cond + yym29 := z.DecBinary() + _ = yym29 + if false { + } else if z.HasExtensions() && z.DecExt(yyv28) { + } else { + z.DecFallback(yyv28, true) + } + } + yyj18++ + if yyhl18 { + yyb18 = yyj18 > l + } else { + yyb18 = r.CheckBreak() + } + if yyb18 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Group = nil + } else { + yyv30 := &x.Group + yyv30.CodecDecodeSelf(d) + } + yyj18++ + if yyhl18 { + yyb18 = yyj18 > l + } else { + yyb18 = r.CheckBreak() + } + if yyb18 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Perms = nil + } else { + yyv31 := &x.Perms + yym32 := z.DecBinary() + _ = yym32 + if false { + } else if z.HasExtensions() && z.DecExt(yyv31) { + } else { + z.DecFallback(yyv31, true) + } + } + for { + yyj18++ + if yyhl18 { + yyb18 = yyj18 > l + } else { + yyb18 = r.CheckBreak() + } + if yyb18 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj18-1, "") + } + r.ReadArrayEnd() +} + +func (x *RemoveTableStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *RemoveTableStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *RemoveTableStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *RemoveTableStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *DefineEventStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(3) + } else { + r.WriteMapStart(3) + } + var yyn3 bool + if x.Name == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.When == nil { + r.EncodeNil() + } else { + yym7 := z.EncBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.EncExt(x.When) { + } else { + z.EncFallback(x.When) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `when`) + r.WriteMapElemValue() + if x.When == nil { + r.EncodeNil() + } else { + yym8 := z.EncBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.EncExt(x.When) { + } else { + z.EncFallback(x.When) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Then == nil { + r.EncodeNil() + } else { + yym10 := z.EncBinary() + _ = yym10 + if false { + } else if z.HasExtensions() && z.EncExt(x.Then) { + } else { + z.EncFallback(x.Then) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `then`) + r.WriteMapElemValue() + if x.Then == nil { + r.EncodeNil() + } else { + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(x.Then) { + } else { + z.EncFallback(x.Then) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DefineEventStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DefineEventStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + case "when": + if r.TryDecodeAsNil() { + x.When = nil + } else { + yyv5 := &x.When + yym6 := z.DecBinary() + _ = yym6 + if false { + } else if z.HasExtensions() && z.DecExt(yyv5) { + } else { + z.DecFallback(yyv5, true) + } + } + case "then": + if r.TryDecodeAsNil() { + x.Then = nil + } else { + yyv7 := &x.Then + yym8 := z.DecBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.DecExt(yyv7) { + } else { + z.DecFallback(yyv7, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DefineEventStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj9 int + var yyb9 bool + var yyhl9 bool = l >= 0 + if x.Name == nil { + x.Name = new(Ident) + } + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l + } else { + yyb9 = r.CheckBreak() + } + if yyb9 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l + } else { + yyb9 = r.CheckBreak() + } + if yyb9 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.When = nil + } else { + yyv11 := &x.When + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l + } else { + yyb9 = r.CheckBreak() + } + if yyb9 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Then = nil + } else { + yyv13 := &x.Then + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else { + z.DecFallback(yyv13, true) + } + } + for { + yyj9++ + if yyhl9 { + yyb9 = yyj9 > l + } else { + yyb9 = r.CheckBreak() + } + if yyb9 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj9-1, "") + } + r.ReadArrayEnd() +} + +func (x *RemoveEventStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *RemoveEventStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *RemoveEventStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *RemoveEventStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *DefineFieldStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(6) + } else { + r.WriteMapStart(6) + } + var yyn3 bool + if x.Name == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Perms == nil { + r.EncodeNil() + } else { + yym7 := z.EncBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.EncExt(x.Perms) { + } else { + z.EncFallback(x.Perms) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `perms`) + r.WriteMapElemValue() + if x.Perms == nil { + r.EncodeNil() + } else { + yym8 := z.EncBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.EncExt(x.Perms) { + } else { + z.EncFallback(x.Perms) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Type)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `type`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Type)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym13 := z.EncBinary() + _ = yym13 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Kind)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `kind`) + r.WriteMapElemValue() + yym14 := z.EncBinary() + _ = yym14 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Kind)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Value == nil { + r.EncodeNil() + } else { + yym16 := z.EncBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.EncExt(x.Value) { + } else { + z.EncFallback(x.Value) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `value`) + r.WriteMapElemValue() + if x.Value == nil { + r.EncodeNil() + } else { + yym17 := z.EncBinary() + _ = yym17 + if false { + } else if z.HasExtensions() && z.EncExt(x.Value) { + } else { + z.EncFallback(x.Value) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Assert == nil { + r.EncodeNil() + } else { + yym19 := z.EncBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.EncExt(x.Assert) { + } else { + z.EncFallback(x.Assert) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `assert`) + r.WriteMapElemValue() + if x.Assert == nil { + r.EncodeNil() + } else { + yym20 := z.EncBinary() + _ = yym20 + if false { + } else if z.HasExtensions() && z.EncExt(x.Assert) { + } else { + z.EncFallback(x.Assert) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DefineFieldStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DefineFieldStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + case "perms": + if r.TryDecodeAsNil() { + x.Perms = nil + } else { + yyv5 := &x.Perms + yym6 := z.DecBinary() + _ = yym6 + if false { + } else if z.HasExtensions() && z.DecExt(yyv5) { + } else { + z.DecFallback(yyv5, true) + } + } + case "type": + if r.TryDecodeAsNil() { + x.Type = "" + } else { + yyv7 := &x.Type + yym8 := z.DecBinary() + _ = yym8 + if false { + } else { + *((*string)(yyv7)) = r.DecodeString() + } + } + case "kind": + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + yyv9 := &x.Kind + yym10 := z.DecBinary() + _ = yym10 + if false { + } else { + *((*string)(yyv9)) = r.DecodeString() + } + } + case "value": + if r.TryDecodeAsNil() { + x.Value = nil + } else { + yyv11 := &x.Value + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + case "assert": + if r.TryDecodeAsNil() { + x.Assert = nil + } else { + yyv13 := &x.Assert + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else { + z.DecFallback(yyv13, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DefineFieldStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj15 int + var yyb15 bool + var yyhl15 bool = l >= 0 + if x.Name == nil { + x.Name = new(Ident) + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Perms = nil + } else { + yyv17 := &x.Perms + yym18 := z.DecBinary() + _ = yym18 + if false { + } else if z.HasExtensions() && z.DecExt(yyv17) { + } else { + z.DecFallback(yyv17, true) + } + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Type = "" + } else { + yyv19 := &x.Type + yym20 := z.DecBinary() + _ = yym20 + if false { + } else { + *((*string)(yyv19)) = r.DecodeString() + } + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + yyv21 := &x.Kind + yym22 := z.DecBinary() + _ = yym22 + if false { + } else { + *((*string)(yyv21)) = r.DecodeString() + } + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Value = nil + } else { + yyv23 := &x.Value + yym24 := z.DecBinary() + _ = yym24 + if false { + } else if z.HasExtensions() && z.DecExt(yyv23) { + } else { + z.DecFallback(yyv23, true) + } + } + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Assert = nil + } else { + yyv25 := &x.Assert + yym26 := z.DecBinary() + _ = yym26 + if false { + } else if z.HasExtensions() && z.DecExt(yyv25) { + } else { + z.DecFallback(yyv25, true) + } + } + for { + yyj15++ + if yyhl15 { + yyb15 = yyj15 > l + } else { + yyb15 = r.CheckBreak() + } + if yyb15 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj15-1, "") + } + r.ReadArrayEnd() +} + +func (x *RemoveFieldStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *RemoveFieldStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *RemoveFieldStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *RemoveFieldStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *DefineIndexStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(3) + } else { + r.WriteMapStart(3) + } + var yyn3 bool + if x.Name == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `name`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Cols == nil { + r.EncodeNil() + } else { + x.Cols.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `cols`) + r.WriteMapElemValue() + if x.Cols == nil { + r.EncodeNil() + } else { + x.Cols.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeBool(bool(x.Uniq)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `uniq`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeBool(bool(x.Uniq)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DefineIndexStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DefineIndexStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + case "cols": + if r.TryDecodeAsNil() { + x.Cols = nil + } else { + yyv5 := &x.Cols + yyv5.CodecDecodeSelf(d) + } + case "uniq": + if r.TryDecodeAsNil() { + x.Uniq = false + } else { + yyv6 := &x.Uniq + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*bool)(yyv6)) = r.DecodeBool() + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DefineIndexStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + if x.Name == nil { + x.Name = new(Ident) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Cols = nil + } else { + yyv10 := &x.Cols + yyv10.CodecDecodeSelf(d) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Uniq = false + } else { + yyv11 := &x.Uniq + yym12 := z.DecBinary() + _ = yym12 + if false { + } else { + *((*bool)(yyv11)) = r.DecodeBool() + } + } + for { + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj8-1, "") + } + r.ReadArrayEnd() +} + +func (x *RemoveIndexStatement) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *RemoveIndexStatement) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *RemoveIndexStatement) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *RemoveIndexStatement) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x Exprs) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encExprs((Exprs)(x), e) + } + } +} + +func (x *Exprs) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decExprs((*Exprs)(x), d) + } +} + +func (x *All) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 { + z.EncTextMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *All) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *All) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *All) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *Any) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 { + z.EncTextMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Any) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Any) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Any) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *Void) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 { + z.EncTextMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Void) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Void) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Void) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *Empty) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 { + z.EncTextMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(0) + } else { + r.WriteMapStart(0) + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Empty) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Empty) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Empty) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj4 int + var yyb4 bool + var yyhl4 bool = l >= 0 + for { + yyj4++ + if yyhl4 { + yyb4 = yyj4 > l + } else { + yyb4 = r.CheckBreak() + } + if yyb4 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj4-1, "") + } + r.ReadArrayEnd() +} + +func (x *Field) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(3) + } else { + r.WriteMapStart(3) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Expr == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Expr) { + } else { + z.EncFallback(x.Expr) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Expr`) + r.WriteMapElemValue() + if x.Expr == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Expr) { + } else { + z.EncFallback(x.Expr) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Field)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Field`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Field)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Alias)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Alias`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Alias)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Field) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Field) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Expr": + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv4 := &x.Expr + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + case "Field": + if r.TryDecodeAsNil() { + x.Field = "" + } else { + yyv6 := &x.Field + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*string)(yyv6)) = r.DecodeString() + } + } + case "Alias": + if r.TryDecodeAsNil() { + x.Alias = "" + } else { + yyv8 := &x.Alias + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Field) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj10 int + var yyb10 bool + var yyhl10 bool = l >= 0 + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv11 := &x.Expr + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Field = "" + } else { + yyv13 := &x.Field + yym14 := z.DecBinary() + _ = yym14 + if false { + } else { + *((*string)(yyv13)) = r.DecodeString() + } + } + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Alias = "" + } else { + yyv15 := &x.Alias + yym16 := z.DecBinary() + _ = yym16 + if false { + } else { + *((*string)(yyv15)) = r.DecodeString() + } + } + for { + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj10-1, "") + } + r.ReadArrayEnd() +} + +func (x Fields) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encFields((Fields)(x), e) + } + } +} + +func (x *Fields) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decFields((*Fields)(x), d) + } +} + +func (x *Group) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Expr == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Expr) { + } else { + z.EncFallback(x.Expr) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Expr`) + r.WriteMapElemValue() + if x.Expr == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Expr) { + } else { + z.EncFallback(x.Expr) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Group) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Group) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Expr": + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv4 := &x.Expr + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Group) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv7 := &x.Expr + yym8 := z.DecBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.DecExt(yyv7) { + } else { + z.DecFallback(yyv7, true) + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x Groups) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encGroups((Groups)(x), e) + } + } +} + +func (x *Groups) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decGroups((*Groups)(x), d) + } +} + +func (x *Order) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(3) + } else { + r.WriteMapStart(3) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Expr == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Expr) { + } else { + z.EncFallback(x.Expr) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Expr`) + r.WriteMapElemValue() + if x.Expr == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Expr) { + } else { + z.EncFallback(x.Expr) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeBool(bool(x.Dir)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Dir`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeBool(bool(x.Dir)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yy10 := &x.Tag + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(yy10) { + } else { + z.EncFallback(yy10) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Tag`) + r.WriteMapElemValue() + yy12 := &x.Tag + yym13 := z.EncBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.EncExt(yy12) { + } else { + z.EncFallback(yy12) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Order) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Order) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Expr": + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv4 := &x.Expr + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + case "Dir": + if r.TryDecodeAsNil() { + x.Dir = false + } else { + yyv6 := &x.Dir + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*bool)(yyv6)) = r.DecodeBool() + } + } + case "Tag": + if r.TryDecodeAsNil() { + x.Tag = pkg1_language.Tag{} + } else { + yyv8 := &x.Tag + yym9 := z.DecBinary() + _ = yym9 + if false { + } else if z.HasExtensions() && z.DecExt(yyv8) { + } else { + z.DecFallback(yyv8, false) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Order) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj10 int + var yyb10 bool + var yyhl10 bool = l >= 0 + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv11 := &x.Expr + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Dir = false + } else { + yyv13 := &x.Dir + yym14 := z.DecBinary() + _ = yym14 + if false { + } else { + *((*bool)(yyv13)) = r.DecodeBool() + } + } + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Tag = pkg1_language.Tag{} + } else { + yyv15 := &x.Tag + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else { + z.DecFallback(yyv15, false) + } + } + for { + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj10-1, "") + } + r.ReadArrayEnd() +} + +func (x Orders) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encOrders((Orders)(x), e) + } + } +} + +func (x *Orders) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decOrders((*Orders)(x), d) + } +} + +func (x *SubExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Expr == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Expr) { + } else { + z.EncFallback(x.Expr) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Expr`) + r.WriteMapElemValue() + if x.Expr == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Expr) { + } else { + z.EncFallback(x.Expr) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *SubExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *SubExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Expr": + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv4 := &x.Expr + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *SubExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv7 := &x.Expr + yym8 := z.DecBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.DecExt(yyv7) { + } else { + z.DecFallback(yyv7, true) + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x *IfelExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(3) + } else { + r.WriteMapStart(3) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Cond == nil { + r.EncodeNil() + } else { + x.Cond.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Cond`) + r.WriteMapElemValue() + if x.Cond == nil { + r.EncodeNil() + } else { + x.Cond.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Then == nil { + r.EncodeNil() + } else { + x.Then.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Then`) + r.WriteMapElemValue() + if x.Then == nil { + r.EncodeNil() + } else { + x.Then.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Else == nil { + r.EncodeNil() + } else { + yym10 := z.EncBinary() + _ = yym10 + if false { + } else if z.HasExtensions() && z.EncExt(x.Else) { + } else { + z.EncFallback(x.Else) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Else`) + r.WriteMapElemValue() + if x.Else == nil { + r.EncodeNil() + } else { + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(x.Else) { + } else { + z.EncFallback(x.Else) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *IfelExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *IfelExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Cond": + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv4 := &x.Cond + yyv4.CodecDecodeSelf(d) + } + case "Then": + if r.TryDecodeAsNil() { + x.Then = nil + } else { + yyv5 := &x.Then + yyv5.CodecDecodeSelf(d) + } + case "Else": + if r.TryDecodeAsNil() { + x.Else = nil + } else { + yyv6 := &x.Else + yym7 := z.DecBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.DecExt(yyv6) { + } else { + z.DecFallback(yyv6, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *IfelExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv9 := &x.Cond + yyv9.CodecDecodeSelf(d) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Then = nil + } else { + yyv10 := &x.Then + yyv10.CodecDecodeSelf(d) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Else = nil + } else { + yyv11 := &x.Else + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + for { + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj8-1, "") + } + r.ReadArrayEnd() +} + +func (x *FuncExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(2) + } else { + r.WriteMapStart(2) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Name)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Name`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.Name)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Args == nil { + r.EncodeNil() + } else { + x.Args.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Args`) + r.WriteMapElemValue() + if x.Args == nil { + r.EncodeNil() + } else { + x.Args.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *FuncExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *FuncExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Name": + if r.TryDecodeAsNil() { + x.Name = "" + } else { + yyv4 := &x.Name + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "Args": + if r.TryDecodeAsNil() { + x.Args = nil + } else { + yyv6 := &x.Args + yyv6.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *FuncExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj7 int + var yyb7 bool + var yyhl7 bool = l >= 0 + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Name = "" + } else { + yyv8 := &x.Name + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*string)(yyv8)) = r.DecodeString() + } + } + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Args = nil + } else { + yyv10 := &x.Args + yyv10.CodecDecodeSelf(d) + } + for { + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj7-1, "") + } + r.ReadArrayEnd() +} + +func (x *ItemExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(3) + } else { + r.WriteMapStart(3) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.LHS == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.LHS) { + } else { + z.EncFallback(x.LHS) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `LHS`) + r.WriteMapElemValue() + if x.LHS == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.LHS) { + } else { + z.EncFallback(x.LHS) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.EncExt(x.Op) { + } else if yym7 { + z.EncBinaryMarshal(x.Op) + } else if !yym7 { + z.EncTextMarshal(x.Op) + } else { + r.EncodeInt(int64(x.Op)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Op`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.EncExt(x.Op) { + } else if yym8 { + z.EncBinaryMarshal(x.Op) + } else if !yym8 { + z.EncTextMarshal(x.Op) + } else { + r.EncodeInt(int64(x.Op)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.RHS == nil { + r.EncodeNil() + } else { + yym10 := z.EncBinary() + _ = yym10 + if false { + } else if z.HasExtensions() && z.EncExt(x.RHS) { + } else { + z.EncFallback(x.RHS) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `RHS`) + r.WriteMapElemValue() + if x.RHS == nil { + r.EncodeNil() + } else { + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(x.RHS) { + } else { + z.EncFallback(x.RHS) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *ItemExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *ItemExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "LHS": + if r.TryDecodeAsNil() { + x.LHS = nil + } else { + yyv4 := &x.LHS + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + case "Op": + if r.TryDecodeAsNil() { + x.Op = 0 + } else { + yyv6 := &x.Op + yym7 := z.DecBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.DecExt(yyv6) { + } else if yym7 { + z.DecBinaryUnmarshal(yyv6) + } else { + *((*int16)(yyv6)) = int16(r.DecodeInt(16)) + } + } + case "RHS": + if r.TryDecodeAsNil() { + x.RHS = nil + } else { + yyv8 := &x.RHS + yym9 := z.DecBinary() + _ = yym9 + if false { + } else if z.HasExtensions() && z.DecExt(yyv8) { + } else { + z.DecFallback(yyv8, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *ItemExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj10 int + var yyb10 bool + var yyhl10 bool = l >= 0 + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.LHS = nil + } else { + yyv11 := &x.LHS + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Op = 0 + } else { + yyv13 := &x.Op + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else if yym14 { + z.DecBinaryUnmarshal(yyv13) + } else { + *((*int16)(yyv13)) = int16(r.DecodeInt(16)) + } + } + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.RHS = nil + } else { + yyv15 := &x.RHS + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else { + z.DecFallback(yyv15, true) + } + } + for { + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj10-1, "") + } + r.ReadArrayEnd() +} + +func (x *BinaryExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(3) + } else { + r.WriteMapStart(3) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.LHS == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.LHS) { + } else { + z.EncFallback(x.LHS) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `LHS`) + r.WriteMapElemValue() + if x.LHS == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.LHS) { + } else { + z.EncFallback(x.LHS) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.EncExt(x.Op) { + } else if yym7 { + z.EncBinaryMarshal(x.Op) + } else if !yym7 { + z.EncTextMarshal(x.Op) + } else { + r.EncodeInt(int64(x.Op)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Op`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.EncExt(x.Op) { + } else if yym8 { + z.EncBinaryMarshal(x.Op) + } else if !yym8 { + z.EncTextMarshal(x.Op) + } else { + r.EncodeInt(int64(x.Op)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.RHS == nil { + r.EncodeNil() + } else { + yym10 := z.EncBinary() + _ = yym10 + if false { + } else if z.HasExtensions() && z.EncExt(x.RHS) { + } else { + z.EncFallback(x.RHS) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `RHS`) + r.WriteMapElemValue() + if x.RHS == nil { + r.EncodeNil() + } else { + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(x.RHS) { + } else { + z.EncFallback(x.RHS) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *BinaryExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *BinaryExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "LHS": + if r.TryDecodeAsNil() { + x.LHS = nil + } else { + yyv4 := &x.LHS + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + case "Op": + if r.TryDecodeAsNil() { + x.Op = 0 + } else { + yyv6 := &x.Op + yym7 := z.DecBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.DecExt(yyv6) { + } else if yym7 { + z.DecBinaryUnmarshal(yyv6) + } else { + *((*int16)(yyv6)) = int16(r.DecodeInt(16)) + } + } + case "RHS": + if r.TryDecodeAsNil() { + x.RHS = nil + } else { + yyv8 := &x.RHS + yym9 := z.DecBinary() + _ = yym9 + if false { + } else if z.HasExtensions() && z.DecExt(yyv8) { + } else { + z.DecFallback(yyv8, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *BinaryExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj10 int + var yyb10 bool + var yyhl10 bool = l >= 0 + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.LHS = nil + } else { + yyv11 := &x.LHS + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Op = 0 + } else { + yyv13 := &x.Op + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else if yym14 { + z.DecBinaryUnmarshal(yyv13) + } else { + *((*int16)(yyv13)) = int16(r.DecodeInt(16)) + } + } + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.RHS = nil + } else { + yyv15 := &x.RHS + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else { + z.DecFallback(yyv15, true) + } + } + for { + yyj10++ + if yyhl10 { + yyb10 = yyj10 > l + } else { + yyb10 = r.CheckBreak() + } + if yyb10 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj10-1, "") + } + r.ReadArrayEnd() +} + +func (x *PathExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Expr == nil { + r.EncodeNil() + } else { + x.Expr.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Expr`) + r.WriteMapElemValue() + if x.Expr == nil { + r.EncodeNil() + } else { + x.Expr.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *PathExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *PathExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Expr": + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv4 := &x.Expr + yyv4.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *PathExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj5 int + var yyb5 bool + var yyhl5 bool = l >= 0 + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Expr = nil + } else { + yyv6 := &x.Expr + yyv6.CodecDecodeSelf(d) + } + for { + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj5-1, "") + } + r.ReadArrayEnd() +} + +func (x *PartExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Part == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Part) { + } else { + z.EncFallback(x.Part) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Part`) + r.WriteMapElemValue() + if x.Part == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Part) { + } else { + z.EncFallback(x.Part) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *PartExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *PartExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Part": + if r.TryDecodeAsNil() { + x.Part = nil + } else { + yyv4 := &x.Part + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *PartExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Part = nil + } else { + yyv7 := &x.Part + yym8 := z.DecBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.DecExt(yyv7) { + } else { + z.DecFallback(yyv7, true) + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x *JoinExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Join) { + } else if yym4 { + z.EncBinaryMarshal(x.Join) + } else if !yym4 { + z.EncTextMarshal(x.Join) + } else { + r.EncodeInt(int64(x.Join)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Join`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Join) { + } else if yym5 { + z.EncBinaryMarshal(x.Join) + } else if !yym5 { + z.EncTextMarshal(x.Join) + } else { + r.EncodeInt(int64(x.Join)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *JoinExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *JoinExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Join": + if r.TryDecodeAsNil() { + x.Join = 0 + } else { + yyv4 := &x.Join + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else if yym5 { + z.DecBinaryUnmarshal(yyv4) + } else { + *((*int16)(yyv4)) = int16(r.DecodeInt(16)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *JoinExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Join = 0 + } else { + yyv7 := &x.Join + yym8 := z.DecBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.DecExt(yyv7) { + } else if yym8 { + z.DecBinaryUnmarshal(yyv7) + } else { + *((*int16)(yyv7)) = int16(r.DecodeInt(16)) + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x *SubpExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(3) + } else { + r.WriteMapStart(3) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `What`) + r.WriteMapElemValue() + if x.What == nil { + r.EncodeNil() + } else { + x.What.CodecEncodeSelf(e) + } + } + var yyn6 bool + if x.Name == nil { + yyn6 = true + goto LABEL6 + } + LABEL6: + if yyr2 || yy2arr2 { + if yyn6 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Name`) + r.WriteMapElemValue() + if yyn6 { + r.EncodeNil() + } else { + if x.Name == nil { + r.EncodeNil() + } else { + x.Name.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Cond == nil { + r.EncodeNil() + } else { + yym10 := z.EncBinary() + _ = yym10 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Cond`) + r.WriteMapElemValue() + if x.Cond == nil { + r.EncodeNil() + } else { + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(x.Cond) { + } else { + z.EncFallback(x.Cond) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *SubpExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *SubpExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "What": + if r.TryDecodeAsNil() { + x.What = nil + } else { + yyv4 := &x.What + yyv4.CodecDecodeSelf(d) + } + case "Name": + if x.Name == nil { + x.Name = new(Ident) + } + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + case "Cond": + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv6 := &x.Cond + yym7 := z.DecBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.DecExt(yyv6) { + } else { + z.DecFallback(yyv6, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *SubpExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.What = nil + } else { + yyv9 := &x.What + yyv9.CodecDecodeSelf(d) + } + if x.Name == nil { + x.Name = new(Ident) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.Name != nil { + x.Name = nil + } + } else { + if x.Name == nil { + x.Name = new(Ident) + } + x.Name.CodecDecodeSelf(d) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Cond = nil + } else { + yyv11 := &x.Cond + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else { + z.DecFallback(yyv11, true) + } + } + for { + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj8-1, "") + } + r.ReadArrayEnd() +} + +func (x *PermExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(4) + } else { + r.WriteMapStart(4) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Select == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Select) { + } else { + z.EncFallback(x.Select) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Select`) + r.WriteMapElemValue() + if x.Select == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Select) { + } else { + z.EncFallback(x.Select) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Create == nil { + r.EncodeNil() + } else { + yym7 := z.EncBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.EncExt(x.Create) { + } else { + z.EncFallback(x.Create) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Create`) + r.WriteMapElemValue() + if x.Create == nil { + r.EncodeNil() + } else { + yym8 := z.EncBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.EncExt(x.Create) { + } else { + z.EncFallback(x.Create) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Update == nil { + r.EncodeNil() + } else { + yym10 := z.EncBinary() + _ = yym10 + if false { + } else if z.HasExtensions() && z.EncExt(x.Update) { + } else { + z.EncFallback(x.Update) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Update`) + r.WriteMapElemValue() + if x.Update == nil { + r.EncodeNil() + } else { + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(x.Update) { + } else { + z.EncFallback(x.Update) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Delete == nil { + r.EncodeNil() + } else { + yym13 := z.EncBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.EncExt(x.Delete) { + } else { + z.EncFallback(x.Delete) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Delete`) + r.WriteMapElemValue() + if x.Delete == nil { + r.EncodeNil() + } else { + yym14 := z.EncBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.EncExt(x.Delete) { + } else { + z.EncFallback(x.Delete) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *PermExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *PermExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Select": + if r.TryDecodeAsNil() { + x.Select = nil + } else { + yyv4 := &x.Select + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + case "Create": + if r.TryDecodeAsNil() { + x.Create = nil + } else { + yyv6 := &x.Create + yym7 := z.DecBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.DecExt(yyv6) { + } else { + z.DecFallback(yyv6, true) + } + } + case "Update": + if r.TryDecodeAsNil() { + x.Update = nil + } else { + yyv8 := &x.Update + yym9 := z.DecBinary() + _ = yym9 + if false { + } else if z.HasExtensions() && z.DecExt(yyv8) { + } else { + z.DecFallback(yyv8, true) + } + } + case "Delete": + if r.TryDecodeAsNil() { + x.Delete = nil + } else { + yyv10 := &x.Delete + yym11 := z.DecBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.DecExt(yyv10) { + } else { + z.DecFallback(yyv10, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *PermExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj12 int + var yyb12 bool + var yyhl12 bool = l >= 0 + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Select = nil + } else { + yyv13 := &x.Select + yym14 := z.DecBinary() + _ = yym14 + if false { + } else if z.HasExtensions() && z.DecExt(yyv13) { + } else { + z.DecFallback(yyv13, true) + } + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Create = nil + } else { + yyv15 := &x.Create + yym16 := z.DecBinary() + _ = yym16 + if false { + } else if z.HasExtensions() && z.DecExt(yyv15) { + } else { + z.DecFallback(yyv15, true) + } + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Update = nil + } else { + yyv17 := &x.Update + yym18 := z.DecBinary() + _ = yym18 + if false { + } else if z.HasExtensions() && z.DecExt(yyv17) { + } else { + z.DecFallback(yyv17, true) + } + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Delete = nil + } else { + yyv19 := &x.Delete + yym20 := z.DecBinary() + _ = yym20 + if false { + } else if z.HasExtensions() && z.DecExt(yyv19) { + } else { + z.DecFallback(yyv19, true) + } + } + for { + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj12-1, "") + } + r.ReadArrayEnd() +} + +func (x *DataExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Data == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + h.encSlicePtrtoItemExpression(([]*ItemExpression)(x.Data), e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Data`) + r.WriteMapElemValue() + if x.Data == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + h.encSlicePtrtoItemExpression(([]*ItemExpression)(x.Data), e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DataExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DataExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Data": + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv4 := &x.Data + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + h.decSlicePtrtoItemExpression((*[]*ItemExpression)(yyv4), d) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DataExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv7 := &x.Data + yym8 := z.DecBinary() + _ = yym8 + if false { + } else { + h.decSlicePtrtoItemExpression((*[]*ItemExpression)(yyv7), d) + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x *DiffExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Data == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Data`) + r.WriteMapElemValue() + if x.Data == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *DiffExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *DiffExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Data": + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv4 := &x.Data + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *DiffExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv7 := &x.Data + yym8 := z.DecBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.DecExt(yyv7) { + } else { + z.DecFallback(yyv7, true) + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x *MergeExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Data == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Data`) + r.WriteMapElemValue() + if x.Data == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *MergeExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *MergeExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Data": + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv4 := &x.Data + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *MergeExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv7 := &x.Data + yym8 := z.DecBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.DecExt(yyv7) { + } else { + z.DecFallback(yyv7, true) + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x *ContentExpression) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.Data == nil { + r.EncodeNil() + } else { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `Data`) + r.WriteMapElemValue() + if x.Data == nil { + r.EncodeNil() + } else { + yym5 := z.EncBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.EncExt(x.Data) { + } else { + z.EncFallback(x.Data) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *ContentExpression) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *ContentExpression) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "Data": + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv4 := &x.Data + yym5 := z.DecBinary() + _ = yym5 + if false { + } else if z.HasExtensions() && z.DecExt(yyv4) { + } else { + z.DecFallback(yyv4, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *ContentExpression) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.Data = nil + } else { + yyv7 := &x.Data + yym8 := z.DecBinary() + _ = yym8 + if false { + } else if z.HasExtensions() && z.DecExt(yyv7) { + } else { + z.DecFallback(yyv7, true) + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x *Model) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(4) + } else { + r.WriteMapStart(4) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.TB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `TB`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.TB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeFloat64(float64(x.MIN)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `MIN`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeFloat64(float64(x.MIN)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym10 := z.EncBinary() + _ = yym10 + if false { + } else { + r.EncodeFloat64(float64(x.INC)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `INC`) + r.WriteMapElemValue() + yym11 := z.EncBinary() + _ = yym11 + if false { + } else { + r.EncodeFloat64(float64(x.INC)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym13 := z.EncBinary() + _ = yym13 + if false { + } else { + r.EncodeFloat64(float64(x.MAX)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `MAX`) + r.WriteMapElemValue() + yym14 := z.EncBinary() + _ = yym14 + if false { + } else { + r.EncodeFloat64(float64(x.MAX)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Model) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Model) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "TB": + if r.TryDecodeAsNil() { + x.TB = "" + } else { + yyv4 := &x.TB + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "MIN": + if r.TryDecodeAsNil() { + x.MIN = 0 + } else { + yyv6 := &x.MIN + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*float64)(yyv6)) = float64(r.DecodeFloat(false)) + } + } + case "INC": + if r.TryDecodeAsNil() { + x.INC = 0 + } else { + yyv8 := &x.INC + yym9 := z.DecBinary() + _ = yym9 + if false { + } else { + *((*float64)(yyv8)) = float64(r.DecodeFloat(false)) + } + } + case "MAX": + if r.TryDecodeAsNil() { + x.MAX = 0 + } else { + yyv10 := &x.MAX + yym11 := z.DecBinary() + _ = yym11 + if false { + } else { + *((*float64)(yyv10)) = float64(r.DecodeFloat(false)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Model) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj12 int + var yyb12 bool + var yyhl12 bool = l >= 0 + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.TB = "" + } else { + yyv13 := &x.TB + yym14 := z.DecBinary() + _ = yym14 + if false { + } else { + *((*string)(yyv13)) = r.DecodeString() + } + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.MIN = 0 + } else { + yyv15 := &x.MIN + yym16 := z.DecBinary() + _ = yym16 + if false { + } else { + *((*float64)(yyv15)) = float64(r.DecodeFloat(false)) + } + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.INC = 0 + } else { + yyv17 := &x.INC + yym18 := z.DecBinary() + _ = yym18 + if false { + } else { + *((*float64)(yyv17)) = float64(r.DecodeFloat(false)) + } + } + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.MAX = 0 + } else { + yyv19 := &x.MAX + yym20 := z.DecBinary() + _ = yym20 + if false { + } else { + *((*float64)(yyv19)) = float64(r.DecodeFloat(false)) + } + } + for { + yyj12++ + if yyhl12 { + yyb12 = yyj12 > l + } else { + yyb12 = r.CheckBreak() + } + if yyb12 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj12-1, "") + } + r.ReadArrayEnd() +} + +func (x Params) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encParams((Params)(x), e) + } + } +} + +func (x *Params) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decParams((*Params)(x), d) + } +} + +func (x *Param) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 { + z.EncTextMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.ID)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `ID`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.ID)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Param) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Param) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "ID": + if r.TryDecodeAsNil() { + x.ID = "" + } else { + yyv4 := &x.ID + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Param) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.ID = "" + } else { + yyv7 := &x.ID + yym8 := z.DecBinary() + _ = yym8 + if false { + } else { + *((*string)(yyv7)) = r.DecodeString() + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x Values) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encValues((Values)(x), e) + } + } +} + +func (x *Values) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decValues((*Values)(x), d) + } +} + +func (x *Value) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 { + z.EncTextMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.ID)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `ID`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.ID)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Value) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Value) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "ID": + if r.TryDecodeAsNil() { + x.ID = "" + } else { + yyv4 := &x.ID + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Value) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.ID = "" + } else { + yyv7 := &x.ID + yym8 := z.DecBinary() + _ = yym8 + if false { + } else { + *((*string)(yyv7)) = r.DecodeString() + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x Idents) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encIdents((Idents)(x), e) + } + } +} + +func (x *Idents) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decIdents((*Idents)(x), d) + } +} + +func (x *Ident) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 { + z.EncTextMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.ID)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `ID`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.ID)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Ident) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Ident) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "ID": + if r.TryDecodeAsNil() { + x.ID = "" + } else { + yyv4 := &x.ID + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Ident) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.ID = "" + } else { + yyv7 := &x.ID + yym8 := z.DecBinary() + _ = yym8 + if false { + } else { + *((*string)(yyv7)) = r.DecodeString() + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x Tables) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encTables((Tables)(x), e) + } + } +} + +func (x *Tables) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decTables((*Tables)(x), d) + } +} + +func (x *Table) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 { + z.EncTextMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.TB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `TB`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.TB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Table) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Table) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "TB": + if r.TryDecodeAsNil() { + x.TB = "" + } else { + yyv4 := &x.TB + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Table) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj6 int + var yyb6 bool + var yyhl6 bool = l >= 0 + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.TB = "" + } else { + yyv7 := &x.TB + yym8 := z.DecBinary() + _ = yym8 + if false { + } else { + *((*string)(yyv7)) = r.DecodeString() + } + } + for { + yyj6++ + if yyhl6 { + yyb6 = yyj6 > l + } else { + yyb6 = r.CheckBreak() + } + if yyb6 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj6-1, "") + } + r.ReadArrayEnd() +} + +func (x Batchs) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encBatchs((Batchs)(x), e) + } + } +} + +func (x *Batchs) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decBatchs((*Batchs)(x), d) + } +} + +func (x *Batch) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 { + z.EncTextMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(2) + } else { + r.WriteMapStart(2) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.TB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `TB`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.TB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.BA == nil { + r.EncodeNil() + } else { + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + h.encSlicePtrtoThing(([]*Thing)(x.BA), e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `BA`) + r.WriteMapElemValue() + if x.BA == nil { + r.EncodeNil() + } else { + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + h.encSlicePtrtoThing(([]*Thing)(x.BA), e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Batch) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Batch) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "TB": + if r.TryDecodeAsNil() { + x.TB = "" + } else { + yyv4 := &x.TB + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "BA": + if r.TryDecodeAsNil() { + x.BA = nil + } else { + yyv6 := &x.BA + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + h.decSlicePtrtoThing((*[]*Thing)(yyv6), d) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Batch) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.TB = "" + } else { + yyv9 := &x.TB + yym10 := z.DecBinary() + _ = yym10 + if false { + } else { + *((*string)(yyv9)) = r.DecodeString() + } + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.BA = nil + } else { + yyv11 := &x.BA + yym12 := z.DecBinary() + _ = yym12 + if false { + } else { + h.decSlicePtrtoThing((*[]*Thing)(yyv11), d) + } + } + for { + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj8-1, "") + } + r.ReadArrayEnd() +} + +func (x Things) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encThings((Things)(x), e) + } + } +} + +func (x *Things) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decThings((*Things)(x), d) + } +} + +func (x *Thing) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 { + z.EncTextMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(2) + } else { + r.WriteMapStart(2) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.TB)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `TB`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferCcUTF84085, string(x.TB)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.ID == nil { + r.EncodeNil() + } else { + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + z.EncFallback(x.ID) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `ID`) + r.WriteMapElemValue() + if x.ID == nil { + r.EncodeNil() + } else { + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + z.EncFallback(x.ID) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Thing) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Thing) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "TB": + if r.TryDecodeAsNil() { + x.TB = "" + } else { + yyv4 := &x.TB + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*string)(yyv4)) = r.DecodeString() + } + } + case "ID": + if r.TryDecodeAsNil() { + x.ID = nil + } else { + yyv6 := &x.ID + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + z.DecFallback(yyv6, true) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Thing) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.TB = "" + } else { + yyv9 := &x.TB + yym10 := z.DecBinary() + _ = yym10 + if false { + } else { + *((*string)(yyv9)) = r.DecodeString() + } + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.ID = nil + } else { + yyv11 := &x.ID + yym12 := z.DecBinary() + _ = yym12 + if false { + } else { + z.DecFallback(yyv11, true) + } + } + for { + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj8-1, "") + } + r.ReadArrayEnd() +} + +func (x Points) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encPoints((Points)(x), e) + } + } +} + +func (x *Points) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decPoints((*Points)(x), d) + } +} + +func (x *Point) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 && z.IsJSONHandle() { + z.EncJSONMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(2) + } else { + r.WriteMapStart(2) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeFloat64(float64(x.LA)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `LA`) + r.WriteMapElemValue() + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeFloat64(float64(x.LA)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeFloat64(float64(x.LO)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `LO`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeFloat64(float64(x.LO)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Point) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Point) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "LA": + if r.TryDecodeAsNil() { + x.LA = 0 + } else { + yyv4 := &x.LA + yym5 := z.DecBinary() + _ = yym5 + if false { + } else { + *((*float64)(yyv4)) = float64(r.DecodeFloat(false)) + } + } + case "LO": + if r.TryDecodeAsNil() { + x.LO = 0 + } else { + yyv6 := &x.LO + yym7 := z.DecBinary() + _ = yym7 + if false { + } else { + *((*float64)(yyv6)) = float64(r.DecodeFloat(false)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Point) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.LA = 0 + } else { + yyv9 := &x.LA + yym10 := z.DecBinary() + _ = yym10 + if false { + } else { + *((*float64)(yyv9)) = float64(r.DecodeFloat(false)) + } + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.LO = 0 + } else { + yyv11 := &x.LO + yym12 := z.DecBinary() + _ = yym12 + if false { + } else { + *((*float64)(yyv11)) = float64(r.DecodeFloat(false)) + } + } + for { + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj8-1, "") + } + r.ReadArrayEnd() +} + +func (x Circles) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encCircles((Circles)(x), e) + } + } +} + +func (x *Circles) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decCircles((*Circles)(x), d) + } +} + +func (x *Circle) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 && z.IsJSONHandle() { + z.EncJSONMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(2) + } else { + r.WriteMapStart(2) + } + var yyn3 bool + if x.CE == nil { + yyn3 = true + goto LABEL3 + } + LABEL3: + if yyr2 || yy2arr2 { + if yyn3 { + r.WriteArrayElem() + r.EncodeNil() + } else { + r.WriteArrayElem() + if x.CE == nil { + r.EncodeNil() + } else { + x.CE.CodecEncodeSelf(e) + } + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `CE`) + r.WriteMapElemValue() + if yyn3 { + r.EncodeNil() + } else { + if x.CE == nil { + r.EncodeNil() + } else { + x.CE.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeFloat64(float64(x.RA)) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `RA`) + r.WriteMapElemValue() + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeFloat64(float64(x.RA)) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Circle) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Circle) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "CE": + if x.CE == nil { + x.CE = new(Point) + } + if r.TryDecodeAsNil() { + if x.CE != nil { + x.CE = nil + } + } else { + if x.CE == nil { + x.CE = new(Point) + } + x.CE.CodecDecodeSelf(d) + } + case "RA": + if r.TryDecodeAsNil() { + x.RA = 0 + } else { + yyv5 := &x.RA + yym6 := z.DecBinary() + _ = yym6 + if false { + } else { + *((*float64)(yyv5)) = float64(r.DecodeFloat(false)) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Circle) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj7 int + var yyb7 bool + var yyhl7 bool = l >= 0 + if x.CE == nil { + x.CE = new(Point) + } + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + if x.CE != nil { + x.CE = nil + } + } else { + if x.CE == nil { + x.CE = new(Point) + } + x.CE.CodecDecodeSelf(d) + } + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.RA = 0 + } else { + yyv9 := &x.RA + yym10 := z.DecBinary() + _ = yym10 + if false { + } else { + *((*float64)(yyv9)) = float64(r.DecodeFloat(false)) + } + } + for { + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj7-1, "") + } + r.ReadArrayEnd() +} + +func (x Polygons) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + h.encPolygons((Polygons)(x), e) + } + } +} + +func (x *Polygons) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + h.decPolygons((*Polygons)(x), d) + } +} + +func (x *Polygon) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else if !yym1 && z.IsJSONHandle() { + z.EncJSONMarshal(x) + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + _, _ = yysep2, yy2arr2 + const yyr2 bool = false + if yyr2 || yy2arr2 { + r.WriteArrayStart(1) + } else { + r.WriteMapStart(1) + } + if yyr2 || yy2arr2 { + r.WriteArrayElem() + if x.PS == nil { + r.EncodeNil() + } else { + x.PS.CodecEncodeSelf(e) + } + } else { + r.WriteMapElemKey() + r.EncodeString(codecSelferCcUTF84085, `PS`) + r.WriteMapElemValue() + if x.PS == nil { + r.EncodeNil() + } else { + x.PS.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + r.WriteArrayEnd() + } else { + r.WriteMapEnd() + } + } + } +} + +func (x *Polygon) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap4085 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + r.ReadMapEnd() + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray4085 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + r.ReadArrayEnd() + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(errCodecSelferOnlyMapOrArrayEncodeToStruct4085) + } + } +} + +func (x *Polygon) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + r.ReadMapElemKey() + yys3Slc = r.DecodeStringAsBytes() + yys3 := string(yys3Slc) + r.ReadMapElemValue() + switch yys3 { + case "PS": + if r.TryDecodeAsNil() { + x.PS = nil + } else { + yyv4 := &x.PS + yyv4.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + r.ReadMapEnd() +} + +func (x *Polygon) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj5 int + var yyb5 bool + var yyhl5 bool = l >= 0 + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + r.ReadArrayEnd() + return + } + r.ReadArrayElem() + if r.TryDecodeAsNil() { + x.PS = nil + } else { + yyv6 := &x.PS + yyv6.CodecDecodeSelf(d) + } + for { + yyj5++ + if yyhl5 { + yyb5 = yyj5 > l + } else { + yyb5 = r.CheckBreak() + } + if yyb5 { + break + } + r.ReadArrayElem() + z.DecStructFieldNotFound(yyj5-1, "") + } + r.ReadArrayEnd() +} + +func (x codecSelfer4085) encStatements(v Statements, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yym2 := z.EncBinary() + _ = yym2 + if false { + } else if z.HasExtensions() && z.EncExt(yyv1) { + } else { + z.EncFallback(yyv1) + } + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decStatements(v *Statements, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []Statement{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 16) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]Statement, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 16) + } else { + yyrl1 = 8 + } + yyv1 = make([]Statement, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + yyv1[yyj1] = nil + } else { + yyv2 := &yyv1[yyj1] + yym3 := z.DecBinary() + _ = yym3 + if false { + } else if z.HasExtensions() && z.DecExt(yyv2) { + } else { + z.DecFallback(yyv2, true) + } + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]Statement, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encExprs(v Exprs, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yym2 := z.EncBinary() + _ = yym2 + if false { + } else if z.HasExtensions() && z.EncExt(yyv1) { + } else { + z.EncFallback(yyv1) + } + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decExprs(v *Exprs, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []Expr{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 16) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]Expr, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 16) + } else { + yyrl1 = 8 + } + yyv1 = make([]Expr, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + yyv1[yyj1] = nil + } else { + yyv2 := &yyv1[yyj1] + yym3 := z.DecBinary() + _ = yym3 + if false { + } else if z.HasExtensions() && z.DecExt(yyv2) { + } else { + z.DecFallback(yyv2, true) + } + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]Expr, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encFields(v Fields, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decFields(v *Fields, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Field{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Field, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Field, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Field{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Field) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Field, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encGroups(v Groups, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decGroups(v *Groups, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Group{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Group, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Group, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Group{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Group) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Group, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encOrders(v Orders, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decOrders(v *Orders, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Order{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Order, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Order, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Order{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Order) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Order, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encSlicePtrtoItemExpression(v []*ItemExpression, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decSlicePtrtoItemExpression(v *[]*ItemExpression, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*ItemExpression{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*ItemExpression, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*ItemExpression, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = ItemExpression{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(ItemExpression) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*ItemExpression, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encParams(v Params, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decParams(v *Params, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Param{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Param, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Param, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Param{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Param) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Param, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encValues(v Values, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decValues(v *Values, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Value{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Value, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Value, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Value{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Value) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Value, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encIdents(v Idents, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decIdents(v *Idents, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Ident{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Ident, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Ident, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Ident{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Ident) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Ident, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encTables(v Tables, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decTables(v *Tables, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Table{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Table, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Table, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Table{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Table) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Table, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encBatchs(v Batchs, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decBatchs(v *Batchs, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Batch{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Batch, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Batch, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Batch{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Batch) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Batch, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encSlicePtrtoThing(v []*Thing, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decSlicePtrtoThing(v *[]*Thing, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Thing{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Thing, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Thing, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Thing{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Thing) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Thing, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encThings(v Things, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decThings(v *Things, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Thing{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Thing, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Thing, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Thing{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Thing) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Thing, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encPoints(v Points, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decPoints(v *Points, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Point{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Point, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Point, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Point{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Point) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Point, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encCircles(v Circles, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decCircles(v *Circles, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Circle{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Circle, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Circle, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Circle{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Circle) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Circle, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} + +func (x codecSelfer4085) encPolygons(v Polygons, e *codec1978.Encoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + r.WriteArrayStart(len(v)) + for _, yyv1 := range v { + r.WriteArrayElem() + if yyv1 == nil { + r.EncodeNil() + } else { + yyv1.CodecEncodeSelf(e) + } + } + r.WriteArrayEnd() +} + +func (x codecSelfer4085) decPolygons(v *Polygons, d *codec1978.Decoder) { + var h codecSelfer4085 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + + yyv1 := *v + yyh1, yyl1 := z.DecSliceHelperStart() + var yyc1 bool + _ = yyc1 + if yyl1 == 0 { + if yyv1 == nil { + yyv1 = []*Polygon{} + yyc1 = true + } else if len(yyv1) != 0 { + yyv1 = yyv1[:0] + yyc1 = true + } + } else { + yyhl1 := yyl1 > 0 + var yyrl1 int + _ = yyrl1 + if yyhl1 { + if yyl1 > cap(yyv1) { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + if yyrl1 <= cap(yyv1) { + yyv1 = yyv1[:yyrl1] + } else { + yyv1 = make([]*Polygon, yyrl1) + } + yyc1 = true + } else if yyl1 != len(yyv1) { + yyv1 = yyv1[:yyl1] + yyc1 = true + } + } + var yyj1 int + // var yydn1 bool + for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ { + if yyj1 == 0 && len(yyv1) == 0 { + if yyhl1 { + yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) + } else { + yyrl1 = 8 + } + yyv1 = make([]*Polygon, yyrl1) + yyc1 = true + } + yyh1.ElemContainerState(yyj1) + // yydn1 = r.TryDecodeAsNil() + + // if indefinite, etc, then expand the slice if necessary + var yydb1 bool + if yyj1 >= len(yyv1) { + yyv1 = append(yyv1, nil) + yyc1 = true + + } + if yydb1 { + z.DecSwallow() + } else { + if r.TryDecodeAsNil() { + if yyv1[yyj1] != nil { + *yyv1[yyj1] = Polygon{} + } + } else { + if yyv1[yyj1] == nil { + yyv1[yyj1] = new(Polygon) + } + yyw2 := yyv1[yyj1] + yyw2.CodecDecodeSelf(d) + } + + } + + } + if yyj1 < len(yyv1) { + yyv1 = yyv1[:yyj1] + yyc1 = true + } else if yyj1 == 0 && yyv1 == nil { + yyv1 = make([]*Polygon, 0) + yyc1 = true + } + } + yyh1.End() + if yyc1 { + *v = yyv1 + } + +} diff --git a/sql/ast.go b/sql/ast.go index 599c7100..7f9d4080 100644 --- a/sql/ast.go +++ b/sql/ast.go @@ -16,7 +16,10 @@ package sql import ( "strconv" + "strings" "time" + + "golang.org/x/text/language" ) // -------------------------------------------------- @@ -43,15 +46,11 @@ type AuthableStatement interface { } type KillableStatement interface { - Begin() - Cease() Duration() time.Duration - Timedout() <-chan struct{} } -type killable struct { - ticker *time.Timer - closer chan struct{} +type WriteableStatement interface { + Writeable() bool } // -------------------------------------------------- @@ -83,6 +82,7 @@ type UseStatement struct { // InfoStatement represents an SQL INFO statement. type InfoStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -90,12 +90,25 @@ type InfoStatement struct { What *Table `cork:"-" codec:"-"` } +// -------------------------------------------------- +// If +// -------------------------------------------------- + +// IfStatement represents an if else clause. +type IfStatement struct { + RW bool `cork:"-" codec:"-"` + Cond Exprs `cork:"cond" codec:"cond"` + Then Exprs `cork:"then" codec:"then"` + Else Expr `cork:"else" codec:"else"` +} + // -------------------------------------------------- // LET // -------------------------------------------------- // LetStatement represents a SQL LET statement. type LetStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -105,10 +118,11 @@ type LetStatement struct { // ReturnStatement represents a SQL RETURN statement. type ReturnStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` - What Expr `cork:"-" codec:"-"` + What Exprs `cork:"-" codec:"-"` } // -------------------------------------------------- @@ -117,84 +131,127 @@ type ReturnStatement struct { // LiveStatement represents a SQL LIVE statement. type LiveStatement struct { - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` + RW bool `cork:"-" codec:"-"` + ID string `cork:"ID" codec:"ID"` + FB string `cork:"FB" codec:"FB"` + KV string `cork:"KV" codec:"KV"` + NS string `cork:"NS" codec:"NS"` + DB string `cork:"DB" codec:"DB"` + Diff bool `cork:"diff" codec:"diff"` Expr Fields `cork:"expr" codec:"expr"` - What Exprs `cork:"what" codec:"what"` + What *Table `cork:"what" codec:"what"` Cond Expr `cork:"cond" codec:"cond"` - Echo Token `cork:"echo" codec:"echo"` +} + +// KillStatement represents a SQL KILL statement. +type KillStatement struct { + RW bool `cork:"-" codec:"-"` + FB string `cork:"FB" codec:"FB"` + KV string `cork:"KV" codec:"KV"` + NS string `cork:"NS" codec:"NS"` + DB string `cork:"DB" codec:"DB"` + Name *Value `cork:"name" codec:"name"` } // SelectStatement represents a SQL SELECT statement. type SelectStatement struct { - killable - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` - Expr Fields `cork:"expr" codec:"expr"` - What Exprs `cork:"what" codec:"what"` - Cond Expr `cork:"cond" codec:"cond"` - Group Groups `cork:"group" codec:"group"` - Order Orders `cork:"order" codec:"order"` - Limit Expr `cork:"limit" codec:"limit"` - Start Expr `cork:"start" codec:"start"` - Version Expr `cork:"version" codec:"version"` - Timeout time.Duration `cork:"timeout" codec:"timeout"` + RW bool `cork:"-" codec:"-"` + KV string `cork:"KV" codec:"KV"` + NS string `cork:"NS" codec:"NS"` + DB string `cork:"DB" codec:"DB"` + Expr Fields `cork:"expr" codec:"expr"` + What Exprs `cork:"what" codec:"what"` + Cond Expr `cork:"cond" codec:"cond"` + Group Groups `cork:"group" codec:"group"` + Order Orders `cork:"order" codec:"order"` + Limit Expr `cork:"limit" codec:"limit"` + Start Expr `cork:"start" codec:"start"` + Version Expr `cork:"version" codec:"version"` + Timeout time.Duration `cork:"timeout" codec:"timeout"` + Parallel int `cork:"parallel" codec:"parallel"` } // CreateStatement represents a SQL CREATE statement. type CreateStatement struct { - killable - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` - What Exprs `cork:"what" codec:"what"` - Data Expr `cork:"data" codec:"data"` - Echo Token `cork:"echo" codec:"echo"` - Timeout time.Duration `cork:"timeout" codec:"timeout"` + RW bool `cork:"-" codec:"-"` + KV string `cork:"KV" codec:"KV"` + NS string `cork:"NS" codec:"NS"` + DB string `cork:"DB" codec:"DB"` + What Exprs `cork:"what" codec:"what"` + Data Expr `cork:"data" codec:"data"` + Echo Token `cork:"echo" codec:"echo"` + Timeout time.Duration `cork:"timeout" codec:"timeout"` + Parallel int `cork:"parallel" codec:"parallel"` } // UpdateStatement represents a SQL UPDATE statement. type UpdateStatement struct { - killable - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` - Hard bool `cork:"hard" codec:"hard"` - What Exprs `cork:"what" codec:"what"` - Data Expr `cork:"data" codec:"data"` - Cond Expr `cork:"cond" codec:"cond"` - Echo Token `cork:"echo" codec:"echo"` - Timeout time.Duration `cork:"timeout" codec:"timeout"` + RW bool `cork:"-" codec:"-"` + KV string `cork:"KV" codec:"KV"` + NS string `cork:"NS" codec:"NS"` + DB string `cork:"DB" codec:"DB"` + What Exprs `cork:"what" codec:"what"` + Data Expr `cork:"data" codec:"data"` + Cond Expr `cork:"cond" codec:"cond"` + Echo Token `cork:"echo" codec:"echo"` + Timeout time.Duration `cork:"timeout" codec:"timeout"` + Parallel int `cork:"parallel" codec:"parallel"` } // DeleteStatement represents a SQL DELETE statement. type DeleteStatement struct { - killable - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` - Hard bool `cork:"hard" codec:"hard"` - What Exprs `cork:"what" codec:"what"` - Cond Expr `cork:"cond" codec:"cond"` - Echo Token `cork:"echo" codec:"echo"` - Timeout time.Duration `cork:"timeout" codec:"timeout"` + RW bool `cork:"-" codec:"-"` + KV string `cork:"KV" codec:"KV"` + NS string `cork:"NS" codec:"NS"` + DB string `cork:"DB" codec:"DB"` + Hard bool `cork:"hard" codec:"hard"` + What Exprs `cork:"what" codec:"what"` + Cond Expr `cork:"cond" codec:"cond"` + Echo Token `cork:"echo" codec:"echo"` + Timeout time.Duration `cork:"timeout" codec:"timeout"` + Parallel int `cork:"parallel" codec:"parallel"` } // RelateStatement represents a SQL RELATE statement. type RelateStatement struct { - killable - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` - Type Expr `cork:"type" codec:"type"` - From Exprs `cork:"from" codec:"from"` - With Exprs `cork:"with" codec:"with"` - Data Expr `cork:"data" codec:"data"` - Uniq bool `cork:"uniq" codec:"uniq"` - Echo Token `cork:"echo" codec:"echo"` - Timeout time.Duration `cork:"timeout" codec:"timeout"` + RW bool `cork:"-" codec:"-"` + KV string `cork:"KV" codec:"KV"` + NS string `cork:"NS" codec:"NS"` + DB string `cork:"DB" codec:"DB"` + Type Expr `cork:"type" codec:"type"` + From Exprs `cork:"from" codec:"from"` + With Exprs `cork:"with" codec:"with"` + Data Expr `cork:"data" codec:"data"` + Uniq bool `cork:"uniq" codec:"uniq"` + Echo Token `cork:"echo" codec:"echo"` + Timeout time.Duration `cork:"timeout" codec:"timeout"` + Parallel int `cork:"parallel" codec:"parallel"` +} + +// InsertStatement represents a SQL INSERT statement. +type InsertStatement struct { + RW bool `cork:"-" codec:"-"` + KV string `cork:"KV" codec:"KV"` + NS string `cork:"NS" codec:"NS"` + DB string `cork:"DB" codec:"DB"` + Data Expr `cork:"data" codec:"data"` + Into *Table `cork:"into" codec:"into"` + Echo Token `cork:"echo" codec:"echo"` + Timeout time.Duration `cork:"timeout" codec:"timeout"` + Parallel int `cork:"parallel" codec:"parallel"` +} + +// UpsertStatement represents a SQL UPSERT statement. +type UpsertStatement struct { + RW bool `cork:"-" codec:"-"` + KV string `cork:"KV" codec:"KV"` + NS string `cork:"NS" codec:"NS"` + DB string `cork:"DB" codec:"DB"` + Data Expr `cork:"data" codec:"data"` + Into *Table `cork:"into" codec:"into"` + Echo Token `cork:"echo" codec:"echo"` + Timeout time.Duration `cork:"timeout" codec:"timeout"` + Parallel int `cork:"parallel" codec:"parallel"` } // -------------------------------------------------- @@ -202,6 +259,7 @@ type RelateStatement struct { // -------------------------------------------------- type DefineNamespaceStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -209,6 +267,7 @@ type DefineNamespaceStatement struct { } type RemoveNamespaceStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -220,6 +279,7 @@ type RemoveNamespaceStatement struct { // -------------------------------------------------- type DefineDatabaseStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -227,6 +287,7 @@ type DefineDatabaseStatement struct { } type RemoveDatabaseStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -239,6 +300,7 @@ type RemoveDatabaseStatement struct { // DefineLoginStatement represents an SQL DEFINE LOGIN statement. type DefineLoginStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -250,6 +312,7 @@ type DefineLoginStatement struct { // RemoveLoginStatement represents an SQL REMOVE LOGIN statement. type RemoveLoginStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -263,6 +326,7 @@ type RemoveLoginStatement struct { // DefineTokenStatement represents an SQL DEFINE TOKEN statement. type DefineTokenStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -274,6 +338,7 @@ type DefineTokenStatement struct { // RemoveTokenStatement represents an SQL REMOVE TOKEN statement. type RemoveTokenStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -287,18 +352,21 @@ type RemoveTokenStatement struct { // DefineScopeStatement represents an SQL DEFINE SCOPE statement. type DefineScopeStatement struct { - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` - Name *Ident `cork:"name" codec:"name"` - Time time.Duration `cork:"time" codec:"time"` - Code []byte `cork:"code" codec:"code"` - Signup Expr `cork:"signup" codec:"signup"` - Signin Expr `cork:"signin" codec:"signin"` + RW bool `cork:"-" codec:"-"` + KV string `cork:"-" codec:"-"` + NS string `cork:"-" codec:"-"` + DB string `cork:"-" codec:"-"` + Name *Ident `cork:"name" codec:"name"` + Time time.Duration `cork:"time" codec:"time"` + Code []byte `cork:"code" codec:"code"` + Signup Expr `cork:"signup" codec:"signup"` + Signin Expr `cork:"signin" codec:"signin"` + Connect Expr `cork:"connect" codec:"connect"` } // RemoveScopeStatement represents an SQL REMOVE SCOPE statement. type RemoveScopeStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -311,49 +379,79 @@ type RemoveScopeStatement struct { // DefineTableStatement represents an SQL DEFINE TABLE statement. type DefineTableStatement struct { - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` - What Tables `cork:"-" codec:"-"` - Full bool `cork:"full" codec:"full"` - Perm *PermExpression `cork:"perm" codec:"perm"` + RW bool `cork:"-" codec:"-"` + KV string `cork:"-" codec:"-"` + NS string `cork:"-" codec:"-"` + DB string `cork:"-" codec:"-"` + Name *Ident `cork:"name" codec:"name"` + What Tables `cork:"-" codec:"-"` + Full bool `cork:"full" codec:"full"` + Drop bool `cork:"drop" codec:"drop"` + Lock bool `cork:"lock" codec:"lock"` + Expr Fields `cork:"expr" codec:"expr"` + From Tables `cork:"from" codec:"from"` + Cond Expr `cork:"cond" codec:"cond"` + Group Groups `cork:"group" codec:"group"` + Perms Expr `cork:"perms" codec:"perms"` } // RemoveTableStatement represents an SQL REMOVE TABLE statement. type RemoveTableStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` What Tables `cork:"-" codec:"-"` } +// -------------------------------------------------- +// Event +// -------------------------------------------------- + +// DefineEventStatement represents an SQL DEFINE EVENT statement. +type DefineEventStatement struct { + RW bool `cork:"-" codec:"-"` + KV string `cork:"-" codec:"-"` + NS string `cork:"-" codec:"-"` + DB string `cork:"-" codec:"-"` + Name *Ident `cork:"name" codec:"name"` + What Tables `cork:"-" codec:"-"` + When Expr `cork:"when" codec:"when"` + Then Expr `cork:"then" codec:"then"` +} + +// RemoveEventStatement represents an SQL REMOVE EVENT statement. +type RemoveEventStatement struct { + RW bool `cork:"-" codec:"-"` + KV string `cork:"-" codec:"-"` + NS string `cork:"-" codec:"-"` + DB string `cork:"-" codec:"-"` + Name *Ident `cork:"-" codec:"-"` + What Tables `cork:"-" codec:"-"` +} + // -------------------------------------------------- // Field // -------------------------------------------------- // DefineFieldStatement represents an SQL DEFINE FIELD statement. type DefineFieldStatement struct { - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` - Name *Ident `cork:"name" codec:"name"` - What Tables `cork:"-" codec:"-"` - Type string `cork:"type" codec:"type"` - Perm *PermExpression `cork:"perm" codec:"perm"` - Enum Array `cork:"enum" codec:"enum"` - Code string `cork:"code" codec:"code"` - Min float64 `cork:"min" codec:"min"` - Max float64 `cork:"max" codec:"max"` - Match string `cork:"match" codec:"match"` - Default interface{} `cork:"default" codec:"default"` - Notnull bool `cork:"notnull" codec:"notnull"` - Readonly bool `cork:"readonly" codec:"readonly"` - Mandatory bool `cork:"mandatory" codec:"mandatory"` - Validate bool `cork:"validate" codec:"validate"` + RW bool `cork:"-" codec:"-"` + KV string `cork:"-" codec:"-"` + NS string `cork:"-" codec:"-"` + DB string `cork:"-" codec:"-"` + Name *Ident `cork:"name" codec:"name"` + What Tables `cork:"-" codec:"-"` + Perms Expr `cork:"perms" codec:"perms"` + Type string `cork:"type" codec:"type"` + Kind string `cork:"kind" codec:"kind"` + Value Expr `cork:"value" codec:"value"` + Assert Expr `cork:"assert" codec:"assert"` } // RemoveFieldStatement represents an SQL REMOVE FIELD statement. type RemoveFieldStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -367,6 +465,7 @@ type RemoveFieldStatement struct { // DefineIndexStatement represents an SQL DEFINE INDEX statement. type DefineIndexStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -378,6 +477,7 @@ type DefineIndexStatement struct { // RemoveIndexStatement represents an SQL REMOVE INDEX statement. type RemoveIndexStatement struct { + RW bool `cork:"-" codec:"-"` KV string `cork:"-" codec:"-"` NS string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"` @@ -385,30 +485,6 @@ type RemoveIndexStatement struct { What Tables `cork:"-" codec:"-"` } -// -------------------------------------------------- -// View -// -------------------------------------------------- - -// DefineViewStatement represents an SQL DEFINE VIEW statement. -type DefineViewStatement struct { - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` - Name *Ident `cork:"name" codec:"name"` - Expr Fields `cork:"expr" codec:"expr"` - What Tables `cork:"what" codec:"what"` - Cond Expr `cork:"cond" codec:"cond"` - Group Groups `cork:"group" codec:"group"` -} - -// RemoveViewStatement represents an SQL REMOVE VIEW statement. -type RemoveViewStatement struct { - KV string `cork:"-" codec:"-"` - NS string `cork:"-" codec:"-"` - DB string `cork:"-" codec:"-"` - Name *Ident `cork:"-" codec:"-"` -} - // -------------------------------------------------- // Literals // -------------------------------------------------- @@ -425,31 +501,17 @@ type All struct{} // Any represents a ? expression. type Any struct{} -// Asc represents the ASC expression. -type Asc struct{} - -// Desc represents the DESC expression. -type Desc struct{} - -// Null represents a null expression. -type Null struct{} - // Void represents an expression which is not set. type Void struct{} // Empty represents an expression which is null or "". type Empty struct{} -// Array represents a parsed json array. -type Array []interface{} - -// Object represents a parsed json object. -type Object map[string]interface{} - // Field represents a SELECT AS clause. type Field struct { Expr Expr - Alias *Ident + Field string + Alias string } // Fields represents multiple SELECT AS clauses. @@ -466,7 +528,8 @@ type Groups []*Group // Order represents a ORDER BY clause. type Order struct { Expr Expr - Dir Expr + Dir bool + Tag language.Tag } // Orders represents multiple ORDER BY clauses. @@ -481,10 +544,18 @@ type SubExpression struct { Expr Expr } +// IfelExpression represents an if else clause. +type IfelExpression struct { + Cond Exprs + Then Exprs + Else Expr +} + // FuncExpression represents a function call. type FuncExpression struct { Name string Args Exprs + Aggr bool } // ItemExpression represents a part of a SET expression. @@ -529,7 +600,6 @@ type PermExpression struct { Create Expr Update Expr Delete Expr - Relate Expr } // DataExpression represents a SET expression. @@ -632,6 +702,27 @@ func NewTable(TB string) *Table { return &Table{TB} } +// -------------------------------------------------- +// Batch +// -------------------------------------------------- + +// Batchs represents multiple Batch clauses. +type Batchs []*Batch + +// Batch comment +type Batch struct { + TB string + BA []*Thing +} + +func NewBatch(TB string, BA []interface{}) *Batch { + var b = &Batch{TB: TB} + for _, ID := range BA { + b.BA = append(b.BA, NewThing(TB, ID)) + } + return b +} + // -------------------------------------------------- // Thing // -------------------------------------------------- @@ -646,23 +737,74 @@ type Thing struct { } func NewThing(TB string, ID interface{}) *Thing { - if str, ok := ID.(string); ok { - if cnv, err := strconv.ParseFloat(str, 64); err == nil { - if cnv == float64(int64(cnv)) { - return &Thing{TB: TB, ID: int64(cnv)} - } + switch val := ID.(type) { + default: + return &Thing{TB: TB, ID: ID} + case int: + return &Thing{TB: TB, ID: float64(val)} + case int64: + return &Thing{TB: TB, ID: float64(val)} + case string: + val = strings.Replace(val, TB+":", "", -1) + if cnv, err := strconv.ParseFloat(val, 64); err == nil { return &Thing{TB: TB, ID: cnv} - } else if cnv, err := strconv.ParseBool(str); err == nil { + } else if cnv, err := strconv.ParseBool(val); err == nil { return &Thing{TB: TB, ID: cnv} - } else if cnv, err := time.Parse(RFCDate, str); err == nil { + } else if cnv, err := time.Parse(RFCDate, val); err == nil { return &Thing{TB: TB, ID: cnv.UTC()} - } else if cnv, err := time.Parse(RFCTime, str); err == nil { - return &Thing{TB: TB, ID: cnv.UTC()} - } else if cnv, err := time.Parse(RFCNorm, str); err == nil { - return &Thing{TB: TB, ID: cnv.UTC()} - } else if cnv, err := time.Parse(RFCText, str); err == nil { + } else if cnv, err := time.Parse(RFCTime, val); err == nil { return &Thing{TB: TB, ID: cnv.UTC()} } + return &Thing{TB: TB, ID: val} } - return &Thing{TB: TB, ID: ID} +} + +// -------------------------------------------------- +// Point +// -------------------------------------------------- + +// Points represents multiple Point clauses. +type Points []*Point + +// Point comment +type Point struct { + LA float64 + LO float64 +} + +func NewPoint(LA, LO float64) *Point { + return &Point{LA: LA, LO: LO} +} + +// -------------------------------------------------- +// Circle +// -------------------------------------------------- + +// Circles represents multiple Circle clauses. +type Circles []*Circle + +// Circle comment +type Circle struct { + CE *Point + RA float64 +} + +func NewCircle(CE *Point, RA float64) *Circle { + return &Circle{CE: CE, RA: RA} +} + +// -------------------------------------------------- +// Polygon +// -------------------------------------------------- + +// Polygons represents multiple Polygon clauses. +type Polygons []*Polygon + +// Polygon comment +type Polygon struct { + PS Points +} + +func NewPolygon(PS ...*Point) *Polygon { + return &Polygon{PS: PS} } diff --git a/sql/auth.gen.go b/sql/auth.gen.go index a328d5ef..3775eff1 100644 --- a/sql/auth.gen.go +++ b/sql/auth.gen.go @@ -38,6 +38,10 @@ func (s *LiveStatement) Auth() (string, string) { return s.NS, s.DB } +func (s *KillStatement) Auth() (string, string) { + return s.NS, s.DB +} + func (s *SelectStatement) Auth() (string, string) { return s.NS, s.DB } @@ -58,6 +62,14 @@ func (s *RelateStatement) Auth() (string, string) { return s.NS, s.DB } +func (s *InsertStatement) Auth() (string, string) { + return s.NS, s.DB +} + +func (s *UpsertStatement) Auth() (string, string) { + return s.NS, s.DB +} + func (s *DefineNamespaceStatement) Auth() (string, string) { return s.NS, s.DB } @@ -106,6 +118,14 @@ func (s *RemoveTableStatement) Auth() (string, string) { return s.NS, s.DB } +func (s *DefineEventStatement) Auth() (string, string) { + return s.NS, s.DB +} + +func (s *RemoveEventStatement) Auth() (string, string) { + return s.NS, s.DB +} + func (s *DefineFieldStatement) Auth() (string, string) { return s.NS, s.DB } @@ -121,11 +141,3 @@ func (s *DefineIndexStatement) Auth() (string, string) { func (s *RemoveIndexStatement) Auth() (string, string) { return s.NS, s.DB } - -func (s *DefineViewStatement) Auth() (string, string) { - return s.NS, s.DB -} - -func (s *RemoveViewStatement) Auth() (string, string) { - return s.NS, s.DB -} diff --git a/sql/auth.gen.json b/sql/auth.gen.json index ad06c467..568054f9 100644 --- a/sql/auth.gen.json +++ b/sql/auth.gen.json @@ -6,11 +6,14 @@ { "name": "Return" }, { "name": "Live" }, + { "name": "Kill" }, { "name": "Select" }, { "name": "Create" }, { "name": "Update" }, { "name": "Delete" }, { "name": "Relate" }, + { "name": "Insert" }, + { "name": "Upsert" }, { "name": "DefineNamespace" }, { "name": "RemoveNamespace" }, @@ -24,10 +27,10 @@ { "name": "RemoveScope" }, { "name": "DefineTable" }, { "name": "RemoveTable" }, + { "name": "DefineEvent" }, + { "name": "RemoveEvent" }, { "name": "DefineField" }, { "name": "RemoveField" }, { "name": "DefineIndex" }, - { "name": "RemoveIndex" }, - { "name": "DefineView" }, - { "name": "RemoveView" } + { "name": "RemoveIndex" } ] diff --git a/sql/auth_test.go b/sql/auth_test.go new file mode 100644 index 00000000..fdb497d9 --- /dev/null +++ b/sql/auth_test.go @@ -0,0 +1,246 @@ +// Code generated by https://github.com/abcum/tmpl +// Source file: auth.gen.go.tmpl +// DO NOT EDIT! + +// Copyright © 2016 Abcum Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sql + +import ( + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestAuth(t *testing.T) { + + Convey("UseStatement should auth correctly", t, func() { + s := &UseStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("InfoStatement should auth correctly", t, func() { + s := &InfoStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("LetStatement should auth correctly", t, func() { + s := &LetStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("ReturnStatement should auth correctly", t, func() { + s := &ReturnStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("LiveStatement should auth correctly", t, func() { + s := &LiveStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("KillStatement should auth correctly", t, func() { + s := &KillStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("SelectStatement should auth correctly", t, func() { + s := &SelectStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("CreateStatement should auth correctly", t, func() { + s := &CreateStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("UpdateStatement should auth correctly", t, func() { + s := &UpdateStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("DeleteStatement should auth correctly", t, func() { + s := &DeleteStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("RelateStatement should auth correctly", t, func() { + s := &RelateStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("InsertStatement should auth correctly", t, func() { + s := &InsertStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("UpsertStatement should auth correctly", t, func() { + s := &UpsertStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("DefineNamespaceStatement should auth correctly", t, func() { + s := &DefineNamespaceStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("RemoveNamespaceStatement should auth correctly", t, func() { + s := &RemoveNamespaceStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("DefineDatabaseStatement should auth correctly", t, func() { + s := &DefineDatabaseStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("RemoveDatabaseStatement should auth correctly", t, func() { + s := &RemoveDatabaseStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("DefineLoginStatement should auth correctly", t, func() { + s := &DefineLoginStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("RemoveLoginStatement should auth correctly", t, func() { + s := &RemoveLoginStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("DefineTokenStatement should auth correctly", t, func() { + s := &DefineTokenStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("RemoveTokenStatement should auth correctly", t, func() { + s := &RemoveTokenStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("DefineScopeStatement should auth correctly", t, func() { + s := &DefineScopeStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("RemoveScopeStatement should auth correctly", t, func() { + s := &RemoveScopeStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("DefineTableStatement should auth correctly", t, func() { + s := &DefineTableStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("RemoveTableStatement should auth correctly", t, func() { + s := &RemoveTableStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("DefineEventStatement should auth correctly", t, func() { + s := &DefineEventStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("RemoveEventStatement should auth correctly", t, func() { + s := &RemoveEventStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("DefineFieldStatement should auth correctly", t, func() { + s := &DefineFieldStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("RemoveFieldStatement should auth correctly", t, func() { + s := &RemoveFieldStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("DefineIndexStatement should auth correctly", t, func() { + s := &DefineIndexStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + + Convey("RemoveIndexStatement should auth correctly", t, func() { + s := &RemoveIndexStatement{NS: "namespace", DB: "database"} + n, d := s.Auth() + So(n, ShouldEqual, "namespace") + So(d, ShouldEqual, "database") + }) + +} diff --git a/sql/check.go b/sql/check.go new file mode 100644 index 00000000..b7f8c542 --- /dev/null +++ b/sql/check.go @@ -0,0 +1,62 @@ +// Copyright © 2016 Abcum Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sql + +func checkExpression(allowed map[string]bool, expr Fields, grps Groups) error { + + if len(grps) > 0 { + + skip: + for _, e := range expr { + + for _, g := range grps { + + // If the expression in the SELECT + // clause is a field, then check to + // see if it exists in the GROUP BY. + + if i, ok := g.Expr.(*Ident); ok { + if e.Field == i.ID { + continue skip + } + } + + // Otherwise if the expression in + // the SELECT clause is a function + // then check to see if it is an + // aggregate function. + + if f, ok := e.Expr.(*FuncExpression); ok { + if ok = allowed[f.Name]; ok { + continue skip + } + } + + } + + // If the expression in the SELECT + // clause isn't an aggregate function + // and isn't specified in the GROUP BY + // clause, then raise an error. + + return &GroupError{found: e.Field} + + } + + } + + return nil + +} diff --git a/sql/cork.go b/sql/cork.go index da821ef2..7ab8cb45 100644 --- a/sql/cork.go +++ b/sql/cork.go @@ -15,8 +15,6 @@ package sql import ( - "bytes" - "github.com/abcum/cork" "github.com/abcum/surreal/util/pack" ) @@ -92,78 +90,6 @@ func (this Any) MarshalText() (data []byte, err error) { return []byte("?"), err } -// -------------------------------------------------- -// ASC -// -------------------------------------------------- - -func init() { - cork.Register(&Asc{}) -} - -func (this *Asc) ExtendCORK() byte { - return 0x03 -} - -func (this *Asc) MarshalCORK() (dst []byte, err error) { - return -} - -func (this *Asc) UnmarshalCORK(src []byte) (err error) { - return -} - -func (this Asc) MarshalText() (data []byte, err error) { - return []byte("~ASC~"), err -} - -// -------------------------------------------------- -// DESC -// -------------------------------------------------- - -func init() { - cork.Register(&Desc{}) -} - -func (this *Desc) ExtendCORK() byte { - return 0x04 -} - -func (this *Desc) MarshalCORK() (dst []byte, err error) { - return -} - -func (this *Desc) UnmarshalCORK(src []byte) (err error) { - return -} - -func (this Desc) MarshalText() (data []byte, err error) { - return []byte("~DESC~"), err -} - -// -------------------------------------------------- -// NULL -// -------------------------------------------------- - -func init() { - cork.Register(&Null{}) -} - -func (this *Null) ExtendCORK() byte { - return 0x05 -} - -func (this *Null) MarshalCORK() (dst []byte, err error) { - return -} - -func (this *Null) UnmarshalCORK(src []byte) (err error) { - return -} - -func (this Null) MarshalText() (data []byte, err error) { - return []byte("~NULL~"), err -} - // -------------------------------------------------- // VOID // -------------------------------------------------- @@ -173,7 +99,7 @@ func init() { } func (this *Void) ExtendCORK() byte { - return 0x06 + return 0x05 } func (this *Void) MarshalCORK() (dst []byte, err error) { @@ -197,7 +123,7 @@ func init() { } func (this *Empty) ExtendCORK() byte { - return 0x07 + return 0x06 } func (this *Empty) MarshalCORK() (dst []byte, err error) { @@ -221,22 +147,20 @@ func init() { } func (this *Field) ExtendCORK() byte { - return 0x08 + return 0x07 } -func (this *Field) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Expr) - e.Encode(this.Alias) - return b.Bytes(), nil +func (this *Field) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Expr) + w.EncodeString(this.Field) + w.EncodeString(this.Alias) + return } -func (this *Field) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Expr) - d.Decode(&this.Alias) +func (this *Field) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Expr) + r.DecodeString(&this.Field) + r.DecodeString(&this.Alias) return } @@ -249,20 +173,16 @@ func init() { } func (this *Group) ExtendCORK() byte { - return 0x09 + return 0x08 } -func (this *Group) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Expr) - return b.Bytes(), nil +func (this *Group) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Expr) + return } -func (this *Group) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Expr) +func (this *Group) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Expr) return } @@ -275,22 +195,18 @@ func init() { } func (this *Order) ExtendCORK() byte { - return 0x10 + return 0x09 } -func (this *Order) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Expr) - e.Encode(this.Dir) - return b.Bytes(), nil +func (this *Order) MarshalCORK(w *cork.Writer) (dst []byte, err error) { + w.EncodeAny(this.Expr) + w.EncodeAny(this.Dir) + return } -func (this *Order) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Expr) - d.Decode(&this.Dir) +func (this *Order) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Expr) + r.DecodeAny(&this.Dir) return } @@ -312,17 +228,39 @@ func (this *SubExpression) ExtendCORK() byte { return 0x21 } -func (this *SubExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Expr) - return b.Bytes(), nil +func (this *SubExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Expr) + return } -func (this *SubExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Expr) +func (this *SubExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Expr) + return +} + +// -------------------------------------------------- +// IfelExpression +// -------------------------------------------------- + +func init() { + cork.Register(&IfelExpression{}) +} + +func (this *IfelExpression) ExtendCORK() byte { + return 0x22 +} + +func (this *IfelExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Cond) + w.EncodeAny(this.Then) + w.EncodeAny(this.Else) + return +} + +func (this *IfelExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Cond) + r.DecodeAny(&this.Then) + r.DecodeAny(&this.Else) return } @@ -335,22 +273,20 @@ func init() { } func (this *FuncExpression) ExtendCORK() byte { - return 0x22 + return 0x23 } -func (this *FuncExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - e.Encode(this.Args) - return b.Bytes(), nil +func (this *FuncExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.Name) + w.EncodeAny(this.Args) + w.EncodeBool(this.Aggr) + return } -func (this *FuncExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) - d.Decode(&this.Args) +func (this *FuncExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.Name) + r.DecodeAny(&this.Args) + r.DecodeBool(&this.Aggr) return } @@ -363,24 +299,20 @@ func init() { } func (this *ItemExpression) ExtendCORK() byte { - return 0x23 + return 0x24 } -func (this *ItemExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.LHS) - e.Encode(this.Op) - e.Encode(this.RHS) - return b.Bytes(), nil +func (this *ItemExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.LHS) + w.EncodeAny(this.Op) + w.EncodeAny(this.RHS) + return } -func (this *ItemExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.LHS) - d.Decode(&this.Op) - d.Decode(&this.RHS) +func (this *ItemExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.LHS) + r.DecodeAny(&this.Op) + r.DecodeAny(&this.RHS) return } @@ -393,24 +325,20 @@ func init() { } func (this *BinaryExpression) ExtendCORK() byte { - return 0x24 + return 0x25 } -func (this *BinaryExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.LHS) - e.Encode(this.Op) - e.Encode(this.RHS) - return b.Bytes(), nil +func (this *BinaryExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.LHS) + w.EncodeAny(this.Op) + w.EncodeAny(this.RHS) + return } -func (this *BinaryExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.LHS) - d.Decode(&this.Op) - d.Decode(&this.RHS) +func (this *BinaryExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.LHS) + r.DecodeAny(&this.Op) + r.DecodeAny(&this.RHS) return } @@ -423,20 +351,16 @@ func init() { } func (this *PathExpression) ExtendCORK() byte { - return 0x25 + return 0x26 } -func (this *PathExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Expr) - return b.Bytes(), nil +func (this *PathExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Expr) + return } -func (this *PathExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Expr) +func (this *PathExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Expr) return } @@ -449,20 +373,16 @@ func init() { } func (this *PartExpression) ExtendCORK() byte { - return 0x26 + return 0x27 } -func (this *PartExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Part) - return b.Bytes(), nil +func (this *PartExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Part) + return } -func (this *PartExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Part) +func (this *PartExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Part) return } @@ -475,20 +395,16 @@ func init() { } func (this *JoinExpression) ExtendCORK() byte { - return 0x27 + return 0x28 } -func (this *JoinExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Join) - return b.Bytes(), nil +func (this *JoinExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Join) + return } -func (this *JoinExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Join) +func (this *JoinExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Join) return } @@ -501,24 +417,20 @@ func init() { } func (this *SubpExpression) ExtendCORK() byte { - return 0x28 + return 0x29 } -func (this *SubpExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.What) - e.Encode(this.Name) - e.Encode(this.Cond) - return b.Bytes(), nil +func (this *SubpExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.What) + w.EncodeAny(this.Name) + w.EncodeAny(this.Cond) + return } -func (this *SubpExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.What) - d.Decode(&this.Name) - d.Decode(&this.Cond) +func (this *SubpExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.What) + r.DecodeAny(&this.Name) + r.DecodeAny(&this.Cond) return } @@ -531,28 +443,22 @@ func init() { } func (this *PermExpression) ExtendCORK() byte { - return 0x29 + return 0x30 } -func (this *PermExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Select) - e.Encode(this.Create) - e.Encode(this.Update) - e.Encode(this.Delete) - e.Encode(this.Relate) - return b.Bytes(), nil +func (this *PermExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Select) + w.EncodeAny(this.Create) + w.EncodeAny(this.Update) + w.EncodeAny(this.Delete) + return } -func (this *PermExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Select) - d.Decode(&this.Create) - d.Decode(&this.Update) - d.Decode(&this.Delete) - d.Decode(&this.Relate) +func (this *PermExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Select) + r.DecodeAny(&this.Create) + r.DecodeAny(&this.Update) + r.DecodeAny(&this.Delete) return } @@ -565,20 +471,16 @@ func init() { } func (this *DataExpression) ExtendCORK() byte { - return 0x30 + return 0x31 } -func (this *DataExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Data) - return b.Bytes(), nil +func (this *DataExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Data) + return } -func (this *DataExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Data) +func (this *DataExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Data) return } @@ -591,20 +493,16 @@ func init() { } func (this *DiffExpression) ExtendCORK() byte { - return 0x31 + return 0x32 } -func (this *DiffExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Data) - return b.Bytes(), nil +func (this *DiffExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Data) + return } -func (this *DiffExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Data) +func (this *DiffExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Data) return } @@ -617,20 +515,16 @@ func init() { } func (this *MergeExpression) ExtendCORK() byte { - return 0x32 + return 0x33 } -func (this *MergeExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Data) - return b.Bytes(), nil +func (this *MergeExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Data) + return } -func (this *MergeExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Data) +func (this *MergeExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Data) return } @@ -643,20 +537,16 @@ func init() { } func (this *ContentExpression) ExtendCORK() byte { - return 0x33 + return 0x34 } -func (this *ContentExpression) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Data) - return b.Bytes(), nil +func (this *ContentExpression) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Data) + return } -func (this *ContentExpression) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Data) +func (this *ContentExpression) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Data) return } @@ -678,17 +568,13 @@ func (this *Param) ExtendCORK() byte { return 0x51 } -func (this *Param) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.ID) - return b.Bytes(), nil +func (this *Param) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.ID) + return } -func (this *Param) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.ID) +func (this *Param) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.ID) return } @@ -708,17 +594,13 @@ func (this *Value) ExtendCORK() byte { return 0x52 } -func (this *Value) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.ID) - return b.Bytes(), nil +func (this *Value) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.ID) + return } -func (this *Value) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.ID) +func (this *Value) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.ID) return } @@ -738,17 +620,13 @@ func (this *Ident) ExtendCORK() byte { return 0x53 } -func (this *Ident) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.ID) - return b.Bytes(), nil +func (this *Ident) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.ID) + return } -func (this *Ident) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.ID) +func (this *Ident) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.ID) return } @@ -768,17 +646,13 @@ func (this *Table) ExtendCORK() byte { return 0x54 } -func (this *Table) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.TB) - return b.Bytes(), nil +func (this *Table) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.TB) + return } -func (this *Table) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.TB) +func (this *Table) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.TB) return } @@ -786,6 +660,32 @@ func (this Table) MarshalText() (data []byte, err error) { return []byte("TB:" + this.TB), err } +// -------------------------------------------------- +// Batch +// -------------------------------------------------- + +func init() { + cork.Register(&Batch{}) +} + +func (this *Batch) ExtendCORK() byte { + return 0x55 +} + +func (this *Batch) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.BA) + return +} + +func (this *Batch) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.BA) + return +} + +func (this Batch) MarshalText() (data []byte, err error) { + return []byte(this.String()), err +} + // -------------------------------------------------- // Thing // -------------------------------------------------- @@ -799,22 +699,18 @@ func (this Thing) Bytes() []byte { } func (this *Thing) ExtendCORK() byte { - return 0x55 + return 0x56 } -func (this *Thing) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.TB) - e.Encode(this.ID) - return b.Bytes(), nil +func (this *Thing) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.TB) + w.EncodeAny(this.ID) + return } -func (this *Thing) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.TB) - d.Decode(&this.ID) +func (this *Thing) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.TB) + r.DecodeAny(&this.ID) return } @@ -822,6 +718,100 @@ func (this Thing) MarshalText() (data []byte, err error) { return []byte(this.String()), err } +// -------------------------------------------------- +// Point +// -------------------------------------------------- + +func init() { + cork.Register(&Point{}) +} + +func (this *Point) ExtendCORK() byte { + return 0x57 +} + +func (this *Point) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeFloat64(this.LA) + w.EncodeFloat64(this.LO) + return +} + +func (this *Point) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeFloat64(&this.LA) + r.DecodeFloat64(&this.LO) + return +} + +func (this Point) MarshalText() (data []byte, err error) { + return []byte(this.String()), err +} + +func (this Point) MarshalJSON() (data []byte, err error) { + return []byte(this.JSON()), err +} + +// -------------------------------------------------- +// Circle +// -------------------------------------------------- + +func init() { + cork.Register(&Circle{}) +} + +func (this *Circle) ExtendCORK() byte { + return 0x58 +} + +func (this *Circle) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.CE) + w.EncodeFloat64(this.RA) + return +} + +func (this *Circle) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.CE) + r.DecodeFloat64(&this.RA) + return +} + +func (this Circle) MarshalText() (data []byte, err error) { + return []byte(this.String()), err +} + +func (this Circle) MarshalJSON() (data []byte, err error) { + return []byte(this.JSON()), err +} + +// -------------------------------------------------- +// Polygon +// -------------------------------------------------- + +func init() { + cork.Register(&Polygon{}) +} + +func (this *Polygon) ExtendCORK() byte { + return 0x59 +} + +func (this *Polygon) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.PS) + return +} + +func (this *Polygon) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.PS) + return +} + +func (this Polygon) MarshalText() (data []byte, err error) { + return []byte(this.String()), err +} + +func (this Polygon) MarshalJSON() (data []byte, err error) { + return []byte(this.JSON()), err +} + // ################################################## // ################################################## // ################################################## @@ -848,23 +838,23 @@ func (this *LiveStatement) ExtendCORK() byte { return 0x71 } -func (this *LiveStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Expr) - e.Encode(this.What) - e.Encode(this.Cond) - e.Encode(this.Echo) - return b.Bytes(), nil +func (this *LiveStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.FB) + w.EncodeString(this.ID) + w.EncodeBool(this.Diff) + w.EncodeAny(this.Expr) + w.EncodeAny(this.What) + w.EncodeAny(this.Cond) + return } -func (this *LiveStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Expr) - d.Decode(&this.What) - d.Decode(&this.Cond) - d.Decode(&this.Echo) +func (this *LiveStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.FB) + r.DecodeString(&this.ID) + r.DecodeBool(&this.Diff) + r.DecodeAny(&this.Expr) + r.DecodeAny(&this.What) + r.DecodeAny(&this.Cond) return } @@ -888,31 +878,35 @@ func (this *SelectStatement) ExtendCORK() byte { return 0x72 } -func (this *SelectStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Expr) - e.Encode(this.What) - e.Encode(this.Cond) - e.Encode(this.Group) - e.Encode(this.Order) - e.Encode(this.Limit) - e.Encode(this.Start) - e.Encode(this.Version) - return b.Bytes(), nil +func (this *SelectStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.KV) + w.EncodeString(this.NS) + w.EncodeString(this.DB) + w.EncodeAny(this.Expr) + w.EncodeAny(this.What) + w.EncodeAny(this.Cond) + w.EncodeAny(this.Group) + w.EncodeAny(this.Order) + w.EncodeAny(this.Limit) + w.EncodeAny(this.Start) + w.EncodeAny(this.Version) + w.EncodeAny(this.Timeout) + return } -func (this *SelectStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Expr) - d.Decode(&this.What) - d.Decode(&this.Cond) - d.Decode(&this.Group) - d.Decode(&this.Order) - d.Decode(&this.Limit) - d.Decode(&this.Start) - d.Decode(&this.Version) +func (this *SelectStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.KV) + r.DecodeString(&this.NS) + r.DecodeString(&this.DB) + r.DecodeAny(&this.Expr) + r.DecodeAny(&this.What) + r.DecodeAny(&this.Cond) + r.DecodeAny(&this.Group) + r.DecodeAny(&this.Order) + r.DecodeAny(&this.Limit) + r.DecodeAny(&this.Start) + r.DecodeAny(&this.Version) + r.DecodeAny(&this.Timeout) return } @@ -936,21 +930,25 @@ func (this *CreateStatement) ExtendCORK() byte { return 0x73 } -func (this *CreateStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.What) - e.Encode(this.Data) - e.Encode(this.Echo) - return b.Bytes(), nil +func (this *CreateStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.KV) + w.EncodeString(this.NS) + w.EncodeString(this.DB) + w.EncodeAny(this.What) + w.EncodeAny(this.Data) + w.EncodeAny(this.Echo) + w.EncodeAny(this.Timeout) + return } -func (this *CreateStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.What) - d.Decode(&this.Data) - d.Decode(&this.Echo) +func (this *CreateStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.KV) + r.DecodeString(&this.NS) + r.DecodeString(&this.DB) + r.DecodeAny(&this.What) + r.DecodeAny(&this.Data) + r.DecodeAny(&this.Echo) + r.DecodeAny(&this.Timeout) return } @@ -974,25 +972,27 @@ func (this *UpdateStatement) ExtendCORK() byte { return 0x74 } -func (this *UpdateStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Hard) - e.Encode(this.What) - e.Encode(this.Data) - e.Encode(this.Cond) - e.Encode(this.Echo) - return b.Bytes(), nil +func (this *UpdateStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.KV) + w.EncodeString(this.NS) + w.EncodeString(this.DB) + w.EncodeAny(this.What) + w.EncodeAny(this.Data) + w.EncodeAny(this.Cond) + w.EncodeAny(this.Echo) + w.EncodeAny(this.Timeout) + return } -func (this *UpdateStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Hard) - d.Decode(&this.What) - d.Decode(&this.Data) - d.Decode(&this.Cond) - d.Decode(&this.Echo) +func (this *UpdateStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.KV) + r.DecodeString(&this.NS) + r.DecodeString(&this.DB) + r.DecodeAny(&this.What) + r.DecodeAny(&this.Data) + r.DecodeAny(&this.Cond) + r.DecodeAny(&this.Echo) + r.DecodeAny(&this.Timeout) return } @@ -1016,23 +1016,27 @@ func (this *DeleteStatement) ExtendCORK() byte { return 0x75 } -func (this *DeleteStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Hard) - e.Encode(this.What) - e.Encode(this.Cond) - e.Encode(this.Echo) - return b.Bytes(), nil +func (this *DeleteStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.KV) + w.EncodeString(this.NS) + w.EncodeString(this.DB) + w.EncodeBool(this.Hard) + w.EncodeAny(this.What) + w.EncodeAny(this.Cond) + w.EncodeAny(this.Echo) + w.EncodeAny(this.Timeout) + return } -func (this *DeleteStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Hard) - d.Decode(&this.What) - d.Decode(&this.Cond) - d.Decode(&this.Echo) +func (this *DeleteStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.KV) + r.DecodeString(&this.NS) + r.DecodeString(&this.DB) + r.DecodeBool(&this.Hard) + r.DecodeAny(&this.What) + r.DecodeAny(&this.Cond) + r.DecodeAny(&this.Echo) + r.DecodeAny(&this.Timeout) return } @@ -1056,27 +1060,115 @@ func (this *RelateStatement) ExtendCORK() byte { return 0x76 } -func (this *RelateStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Type) - e.Encode(this.From) - e.Encode(this.With) - e.Encode(this.Data) - e.Encode(this.Uniq) - e.Encode(this.Echo) - return b.Bytes(), nil +func (this *RelateStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.KV) + w.EncodeString(this.NS) + w.EncodeString(this.DB) + w.EncodeAny(this.Type) + w.EncodeAny(this.From) + w.EncodeAny(this.With) + w.EncodeAny(this.Data) + w.EncodeBool(this.Uniq) + w.EncodeAny(this.Echo) + w.EncodeAny(this.Timeout) + return } -func (this *RelateStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Type) - d.Decode(&this.From) - d.Decode(&this.With) - d.Decode(&this.Data) - d.Decode(&this.Uniq) - d.Decode(&this.Echo) +func (this *RelateStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.KV) + r.DecodeString(&this.NS) + r.DecodeString(&this.DB) + r.DecodeAny(&this.Type) + r.DecodeAny(&this.From) + r.DecodeAny(&this.With) + r.DecodeAny(&this.Data) + r.DecodeBool(&this.Uniq) + r.DecodeAny(&this.Echo) + r.DecodeAny(&this.Timeout) + return +} + +// -------------------------------------------------- +// InsertStatement +// -------------------------------------------------- + +func init() { + cork.Register(&InsertStatement{}) +} + +func (this *InsertStatement) Decode(src []byte) { + pack.Decode(src, this) +} + +func (this *InsertStatement) Encode() (dst []byte) { + return pack.Encode(this) +} + +func (this *InsertStatement) ExtendCORK() byte { + return 0x77 +} + +func (this *InsertStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.KV) + w.EncodeString(this.NS) + w.EncodeString(this.DB) + w.EncodeAny(this.Data) + w.EncodeAny(this.Into) + w.EncodeAny(this.Echo) + w.EncodeAny(this.Timeout) + return +} + +func (this *InsertStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.KV) + r.DecodeString(&this.NS) + r.DecodeString(&this.DB) + r.DecodeAny(&this.Data) + r.DecodeAny(&this.Into) + r.DecodeAny(&this.Echo) + r.DecodeAny(&this.Timeout) + return +} + +// -------------------------------------------------- +// UpsertStatement +// -------------------------------------------------- + +func init() { + cork.Register(&UpsertStatement{}) +} + +func (this *UpsertStatement) Decode(src []byte) { + pack.Decode(src, this) +} + +func (this *UpsertStatement) Encode() (dst []byte) { + return pack.Encode(this) +} + +func (this *UpsertStatement) ExtendCORK() byte { + return 0x78 +} + +func (this *UpsertStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeString(this.KV) + w.EncodeString(this.NS) + w.EncodeString(this.DB) + w.EncodeAny(this.Data) + w.EncodeAny(this.Into) + w.EncodeAny(this.Echo) + w.EncodeAny(this.Timeout) + return +} + +func (this *UpsertStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeString(&this.KV) + r.DecodeString(&this.NS) + r.DecodeString(&this.DB) + r.DecodeAny(&this.Data) + r.DecodeAny(&this.Into) + r.DecodeAny(&this.Echo) + r.DecodeAny(&this.Timeout) return } @@ -1097,20 +1189,16 @@ func (this *DefineNamespaceStatement) Encode() (dst []byte) { } func (this *DefineNamespaceStatement) ExtendCORK() byte { - return 0x77 + return 0x79 } -func (this *DefineNamespaceStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - return b.Bytes(), nil +func (this *DefineNamespaceStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + return } -func (this *DefineNamespaceStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) +func (this *DefineNamespaceStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) return } @@ -1131,20 +1219,16 @@ func (this *RemoveNamespaceStatement) Encode() (dst []byte) { } func (this *RemoveNamespaceStatement) ExtendCORK() byte { - return 0x78 + return 0x80 } -func (this *RemoveNamespaceStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - return b.Bytes(), nil +func (this *RemoveNamespaceStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + return } -func (this *RemoveNamespaceStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) +func (this *RemoveNamespaceStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) return } @@ -1165,20 +1249,16 @@ func (this *DefineDatabaseStatement) Encode() (dst []byte) { } func (this *DefineDatabaseStatement) ExtendCORK() byte { - return 0x79 + return 0x81 } -func (this *DefineDatabaseStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - return b.Bytes(), nil +func (this *DefineDatabaseStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + return } -func (this *DefineDatabaseStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) +func (this *DefineDatabaseStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) return } @@ -1199,20 +1279,16 @@ func (this *RemoveDatabaseStatement) Encode() (dst []byte) { } func (this *RemoveDatabaseStatement) ExtendCORK() byte { - return 0x80 + return 0x82 } -func (this *RemoveDatabaseStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - return b.Bytes(), nil +func (this *RemoveDatabaseStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + return } -func (this *RemoveDatabaseStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) +func (this *RemoveDatabaseStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) return } @@ -1233,26 +1309,22 @@ func (this *DefineLoginStatement) Encode() (dst []byte) { } func (this *DefineLoginStatement) ExtendCORK() byte { - return 0x81 + return 0x83 } -func (this *DefineLoginStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Kind) - e.Encode(this.User) - e.Encode(this.Pass) - e.Encode(this.Code) - return b.Bytes(), nil +func (this *DefineLoginStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Kind) + w.EncodeAny(this.User) + w.EncodeBytes(this.Pass) + w.EncodeBytes(this.Code) + return } -func (this *DefineLoginStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Kind) - d.Decode(&this.User) - d.Decode(&this.Pass) - d.Decode(&this.Code) +func (this *DefineLoginStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Kind) + r.DecodeAny(&this.User) + r.DecodeBytes(&this.Pass) + r.DecodeBytes(&this.Code) return } @@ -1273,22 +1345,18 @@ func (this *RemoveLoginStatement) Encode() (dst []byte) { } func (this *RemoveLoginStatement) ExtendCORK() byte { - return 0x82 + return 0x84 } -func (this *RemoveLoginStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Kind) - e.Encode(this.User) - return b.Bytes(), nil +func (this *RemoveLoginStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Kind) + w.EncodeAny(this.User) + return } -func (this *RemoveLoginStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Kind) - d.Decode(&this.User) +func (this *RemoveLoginStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Kind) + r.DecodeAny(&this.User) return } @@ -1309,26 +1377,22 @@ func (this *DefineTokenStatement) Encode() (dst []byte) { } func (this *DefineTokenStatement) ExtendCORK() byte { - return 0x83 + return 0x85 } -func (this *DefineTokenStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Kind) - e.Encode(this.Name) - e.Encode(this.Type) - e.Encode(this.Code) - return b.Bytes(), nil +func (this *DefineTokenStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Kind) + w.EncodeAny(this.Name) + w.EncodeAny(this.Type) + w.EncodeBytes(this.Code) + return } -func (this *DefineTokenStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Kind) - d.Decode(&this.Name) - d.Decode(&this.Type) - d.Decode(&this.Code) +func (this *DefineTokenStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Kind) + r.DecodeAny(&this.Name) + r.DecodeAny(&this.Type) + r.DecodeBytes(&this.Code) return } @@ -1349,22 +1413,18 @@ func (this *RemoveTokenStatement) Encode() (dst []byte) { } func (this *RemoveTokenStatement) ExtendCORK() byte { - return 0x84 + return 0x86 } -func (this *RemoveTokenStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Kind) - e.Encode(this.Name) - return b.Bytes(), nil +func (this *RemoveTokenStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Kind) + w.EncodeAny(this.Name) + return } -func (this *RemoveTokenStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Kind) - d.Decode(&this.Name) +func (this *RemoveTokenStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Kind) + r.DecodeAny(&this.Name) return } @@ -1385,28 +1445,26 @@ func (this *DefineScopeStatement) Encode() (dst []byte) { } func (this *DefineScopeStatement) ExtendCORK() byte { - return 0x85 + return 0x87 } -func (this *DefineScopeStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - e.Encode(this.Time) - e.Encode(this.Code) - e.Encode(this.Signup) - e.Encode(this.Signin) - return b.Bytes(), nil +func (this *DefineScopeStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + w.EncodeAny(this.Time) + w.EncodeBytes(this.Code) + w.EncodeAny(this.Signup) + w.EncodeAny(this.Signin) + w.EncodeAny(this.Connect) + return } -func (this *DefineScopeStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) - d.Decode(&this.Time) - d.Decode(&this.Code) - d.Decode(&this.Signup) - d.Decode(&this.Signin) +func (this *DefineScopeStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) + r.DecodeAny(&this.Time) + r.DecodeBytes(&this.Code) + r.DecodeAny(&this.Signup) + r.DecodeAny(&this.Signin) + r.DecodeAny(&this.Connect) return } @@ -1427,20 +1485,16 @@ func (this *RemoveScopeStatement) Encode() (dst []byte) { } func (this *RemoveScopeStatement) ExtendCORK() byte { - return 0x86 + return 0x88 } -func (this *RemoveScopeStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - return b.Bytes(), nil +func (this *RemoveScopeStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + return } -func (this *RemoveScopeStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) +func (this *RemoveScopeStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) return } @@ -1461,22 +1515,32 @@ func (this *DefineTableStatement) Encode() (dst []byte) { } func (this *DefineTableStatement) ExtendCORK() byte { - return 0x87 + return 0x89 } -func (this *DefineTableStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.What) - e.Encode(this.Full) - return b.Bytes(), nil +func (this *DefineTableStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + w.EncodeBool(this.Full) + w.EncodeBool(this.Drop) + w.EncodeBool(this.Lock) + w.EncodeAny(this.Expr) + w.EncodeAny(this.From) + w.EncodeAny(this.Cond) + w.EncodeAny(this.Group) + w.EncodeAny(this.Perms) + return } -func (this *DefineTableStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.What) - d.Decode(&this.Full) +func (this *DefineTableStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) + r.DecodeBool(&this.Full) + r.DecodeBool(&this.Drop) + r.DecodeBool(&this.Lock) + r.DecodeAny(&this.Expr) + r.DecodeAny(&this.From) + r.DecodeAny(&this.Cond) + r.DecodeAny(&this.Group) + r.DecodeAny(&this.Perms) return } @@ -1497,20 +1561,84 @@ func (this *RemoveTableStatement) Encode() (dst []byte) { } func (this *RemoveTableStatement) ExtendCORK() byte { - return 0x88 + return 0x90 } -func (this *RemoveTableStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.What) - return b.Bytes(), nil +func (this *RemoveTableStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.What) + return } -func (this *RemoveTableStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.What) +func (this *RemoveTableStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.What) + return +} + +// -------------------------------------------------- +// DefineEventStatement +// -------------------------------------------------- + +func init() { + cork.Register(&DefineEventStatement{}) +} + +func (this *DefineEventStatement) Decode(src []byte) { + pack.Decode(src, this) +} + +func (this *DefineEventStatement) Encode() (dst []byte) { + return pack.Encode(this) +} + +func (this *DefineEventStatement) ExtendCORK() byte { + return 0x91 +} + +func (this *DefineEventStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + w.EncodeAny(this.What) + w.EncodeAny(this.When) + w.EncodeAny(this.Then) + return +} + +func (this *DefineEventStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) + r.DecodeAny(&this.What) + r.DecodeAny(&this.When) + r.DecodeAny(&this.Then) + return +} + +// -------------------------------------------------- +// RemoveEventStatement +// -------------------------------------------------- + +func init() { + cork.Register(&RemoveEventStatement{}) +} + +func (this *RemoveEventStatement) Decode(src []byte) { + pack.Decode(src, this) +} + +func (this *RemoveEventStatement) Encode() (dst []byte) { + return pack.Encode(this) +} + +func (this *RemoveEventStatement) ExtendCORK() byte { + return 0x92 +} + +func (this *RemoveEventStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + w.EncodeAny(this.What) + return +} + +func (this *RemoveEventStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) + r.DecodeAny(&this.What) return } @@ -1531,44 +1659,28 @@ func (this *DefineFieldStatement) Encode() (dst []byte) { } func (this *DefineFieldStatement) ExtendCORK() byte { - return 0x89 + return 0x93 } -func (this *DefineFieldStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - e.Encode(this.What) - e.Encode(this.Type) - e.Encode(this.Enum) - e.Encode(this.Code) - e.Encode(this.Min) - e.Encode(this.Max) - e.Encode(this.Match) - e.Encode(this.Default) - e.Encode(this.Notnull) - e.Encode(this.Readonly) - e.Encode(this.Mandatory) - e.Encode(this.Validate) - return b.Bytes(), nil +func (this *DefineFieldStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + w.EncodeAny(this.What) + w.EncodeString(this.Type) + w.EncodeString(this.Kind) + w.EncodeAny(this.Perms) + w.EncodeAny(this.Value) + w.EncodeAny(this.Assert) + return } -func (this *DefineFieldStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) - d.Decode(&this.What) - d.Decode(&this.Type) - d.Decode(&this.Enum) - d.Decode(&this.Code) - d.Decode(&this.Min) - d.Decode(&this.Max) - d.Decode(&this.Match) - d.Decode(&this.Default) - d.Decode(&this.Notnull) - d.Decode(&this.Readonly) - d.Decode(&this.Mandatory) - d.Decode(&this.Validate) +func (this *DefineFieldStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) + r.DecodeAny(&this.What) + r.DecodeString(&this.Type) + r.DecodeString(&this.Kind) + r.DecodeAny(&this.Perms) + r.DecodeAny(&this.Value) + r.DecodeAny(&this.Assert) return } @@ -1589,22 +1701,18 @@ func (this *RemoveFieldStatement) Encode() (dst []byte) { } func (this *RemoveFieldStatement) ExtendCORK() byte { - return 0x90 + return 0x94 } -func (this *RemoveFieldStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - e.Encode(this.What) - return b.Bytes(), nil +func (this *RemoveFieldStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + w.EncodeAny(this.What) + return } -func (this *RemoveFieldStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) - d.Decode(&this.What) +func (this *RemoveFieldStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) + r.DecodeAny(&this.What) return } @@ -1625,26 +1733,22 @@ func (this *DefineIndexStatement) Encode() (dst []byte) { } func (this *DefineIndexStatement) ExtendCORK() byte { - return 0x91 + return 0x95 } -func (this *DefineIndexStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - e.Encode(this.What) - e.Encode(this.Cols) - e.Encode(this.Uniq) - return b.Bytes(), nil +func (this *DefineIndexStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + w.EncodeAny(this.What) + w.EncodeAny(this.Cols) + w.EncodeBool(this.Uniq) + return } -func (this *DefineIndexStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) - d.Decode(&this.What) - d.Decode(&this.Cols) - d.Decode(&this.Uniq) +func (this *DefineIndexStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) + r.DecodeAny(&this.What) + r.DecodeAny(&this.Cols) + r.DecodeBool(&this.Uniq) return } @@ -1665,97 +1769,17 @@ func (this *RemoveIndexStatement) Encode() (dst []byte) { } func (this *RemoveIndexStatement) ExtendCORK() byte { - return 0x92 + return 0x96 } -func (this *RemoveIndexStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - e.Encode(this.What) - return b.Bytes(), nil -} - -func (this *RemoveIndexStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) - d.Decode(&this.What) +func (this *RemoveIndexStatement) MarshalCORK(w *cork.Writer) (err error) { + w.EncodeAny(this.Name) + w.EncodeAny(this.What) return } -// -------------------------------------------------- -// DefineViewStatement -// -------------------------------------------------- - -func init() { - cork.Register(&DefineViewStatement{}) -} - -func (this *DefineViewStatement) Decode(src []byte) { - pack.Decode(src, this) -} - -func (this *DefineViewStatement) Encode() (dst []byte) { - return pack.Encode(this) -} - -func (this *DefineViewStatement) ExtendCORK() byte { - return 0x93 -} - -func (this *DefineViewStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - e.Encode(this.Expr) - e.Encode(this.What) - e.Encode(this.Cond) - e.Encode(this.Group) - return b.Bytes(), nil -} - -func (this *DefineViewStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) - d.Decode(&this.Expr) - d.Decode(&this.What) - d.Decode(&this.Cond) - d.Decode(&this.Group) - return -} - -// -------------------------------------------------- -// RemoveViewStatement -// -------------------------------------------------- - -func init() { - cork.Register(&RemoveViewStatement{}) -} - -func (this *RemoveViewStatement) Decode(src []byte) { - pack.Decode(src, this) -} - -func (this *RemoveViewStatement) Encode() (dst []byte) { - return pack.Encode(this) -} - -func (this *RemoveViewStatement) ExtendCORK() byte { - return 0x94 -} - -func (this *RemoveViewStatement) MarshalCORK() (dst []byte, err error) { - b := bytes.NewBuffer(dst) - e := cork.NewEncoder(b) - e.Encode(this.Name) - return b.Bytes(), nil -} - -func (this *RemoveViewStatement) UnmarshalCORK(src []byte) (err error) { - b := bytes.NewBuffer(src) - d := cork.NewDecoder(b) - d.Decode(&this.Name) +func (this *RemoveIndexStatement) UnmarshalCORK(r *cork.Reader) (err error) { + r.DecodeAny(&this.Name) + r.DecodeAny(&this.What) return } diff --git a/sql/create.go b/sql/create.go index 1a100f64..6850fabd 100644 --- a/sql/create.go +++ b/sql/create.go @@ -16,9 +16,9 @@ package sql func (p *parser) parseCreateStatement() (stmt *CreateStatement, err error) { - stmt = &CreateStatement{} + stmt = &CreateStatement{RW: true} - if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthSC); err != nil { + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil { return nil, err } @@ -38,10 +38,6 @@ func (p *parser) parseCreateStatement() (stmt *CreateStatement, err error) { return nil, err } - if _, _, err = p.shouldBe(EOF, RPAREN, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/data.go b/sql/data.go index 6de2dfb3..18d1ea93 100644 --- a/sql/data.go +++ b/sql/data.go @@ -63,7 +63,7 @@ func (p *parser) parseSet() (mul Expr, err error) { // always be an identifier, specifying a // record field to set. - tok, lit, err = p.shouldBe(IDENT) + tok, lit, err = p.shouldBe(IDENT, EXPR) if err != nil { return nil, &ParseError{Found: lit, Expected: []string{"field name"}} } diff --git a/sql/database.go b/sql/database.go index 3f5a2b7c..7239fd33 100644 --- a/sql/database.go +++ b/sql/database.go @@ -16,7 +16,7 @@ package sql func (p *parser) parseDefineDatabaseStatement() (stmt *DefineDatabaseStatement, err error) { - stmt = &DefineDatabaseStatement{} + stmt = &DefineDatabaseStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNS); err != nil { return nil, err @@ -32,7 +32,7 @@ func (p *parser) parseDefineDatabaseStatement() (stmt *DefineDatabaseStatement, func (p *parser) parseRemoveDatabaseStatement() (stmt *RemoveDatabaseStatement, err error) { - stmt = &RemoveDatabaseStatement{} + stmt = &RemoveDatabaseStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNS); err != nil { return nil, err diff --git a/sql/define.go b/sql/define.go index cd93569c..8dee0e2c 100644 --- a/sql/define.go +++ b/sql/define.go @@ -17,7 +17,7 @@ package sql func (p *parser) parseDefineStatement() (Statement, error) { // Inspect the next token. - tok, _, err := p.shouldBe(NAMESPACE, DATABASE, LOGIN, TOKEN, SCOPE, TABLE, FIELD, INDEX, VIEW) + tok, _, err := p.shouldBe(NAMESPACE, DATABASE, LOGIN, TOKEN, SCOPE, TABLE, EVENT, FIELD, INDEX) switch tok { case NAMESPACE: @@ -32,12 +32,12 @@ func (p *parser) parseDefineStatement() (Statement, error) { return p.parseDefineScopeStatement() case TABLE: return p.parseDefineTableStatement() + case EVENT: + return p.parseDefineEventStatement() case FIELD: return p.parseDefineFieldStatement() case INDEX: return p.parseDefineIndexStatement() - case VIEW: - return p.parseDefineViewStatement() default: return nil, err } diff --git a/sql/delete.go b/sql/delete.go index 9c0676ef..1b736025 100644 --- a/sql/delete.go +++ b/sql/delete.go @@ -16,9 +16,9 @@ package sql func (p *parser) parseDeleteStatement() (stmt *DeleteStatement, err error) { - stmt = &DeleteStatement{} + stmt = &DeleteStatement{RW: true} - if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthSC); err != nil { + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil { return nil, err } @@ -47,10 +47,6 @@ func (p *parser) parseDeleteStatement() (stmt *DeleteStatement, err error) { return nil, err } - if _, _, err = p.shouldBe(EOF, RPAREN, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/echo.go b/sql/echo.go index 9e38a65b..200b4549 100644 --- a/sql/echo.go +++ b/sql/echo.go @@ -14,9 +14,9 @@ package sql -func (p *parser) parseEcho(empty Token) (exp Token, err error) { +func (p *parser) parseEcho(fallback Token) (exp Token, err error) { - exp = empty + exp = fallback // The next token that we expect to see is a // RETURN token, and if we don't find one then @@ -24,7 +24,7 @@ func (p *parser) parseEcho(empty Token) (exp Token, err error) { if _, _, exi := p.mightBe(RETURN); exi { - exp, _, err = p.shouldBe(ID, NONE, INFO, BOTH, DIFF, BEFORE, AFTER) + exp, _, err = p.shouldBe(NONE, INFO, BOTH, DIFF, BEFORE, AFTER) if err != nil { return 0, err } diff --git a/sql/error.go b/sql/error.go index c4582f77..6c3c159c 100644 --- a/sql/error.go +++ b/sql/error.go @@ -43,6 +43,14 @@ func (e *BlankError) Error() string { return fmt.Sprint("You need to specify a namespace and a database to use") } +// TransError represents an error that occured when switching access. +type TransError struct{} + +// Error returns the string representation of the error. +func (e *TransError) Error() string { + return fmt.Sprintf("You can't change NAMESPACE or DATABASE inside of a transaction") +} + // PermsError represents an error that occured when switching access. type PermsError struct { Resource string @@ -53,6 +61,16 @@ func (e *PermsError) Error() string { return fmt.Sprintf("You don't have permission to access the '%s' resource", e.Resource) } +// GroupError occurs when a 'group' expression is invalid. +type GroupError struct { + found interface{} +} + +// Error returns the string representation of the error. +func (e *GroupError) Error() string { + return fmt.Sprintf("Found '%v' but field is not an aggregate function, and is not present in GROUP expression", e.found) +} + // ParseError represents an error that occurred during parsing. type ParseError struct { Found string diff --git a/sql/view.go b/sql/event.go similarity index 61% rename from sql/view.go rename to sql/event.go index 270482c8..52fd5163 100644 --- a/sql/view.go +++ b/sql/event.go @@ -14,9 +14,9 @@ package sql -func (p *parser) parseDefineViewStatement() (stmt *DefineViewStatement, err error) { +func (p *parser) parseDefineEventStatement() (stmt *DefineEventStatement, err error) { - stmt = &DefineViewStatement{} + stmt = &DefineEventStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { return nil, err @@ -26,38 +26,27 @@ func (p *parser) parseDefineViewStatement() (stmt *DefineViewStatement, err erro return nil, err } - _, _, err = p.shouldBe(AS) - if err != nil { + if _, _, err = p.shouldBe(ON); err != nil { return nil, err } - _, _, err = p.shouldBe(SELECT) - if err != nil { + if stmt.What, err = p.parseTables(); err != nil { return nil, err } - if stmt.Expr, err = p.parseFields(); err != nil { + if _, _, err = p.shouldBe(WHEN); err != nil { return nil, err } - _, _, err = p.shouldBe(FROM) - if err != nil { + if stmt.When, err = p.parseExpr(); err != nil { return nil, err } - if stmt.What, err = p.parseWhat(); err != nil { + if _, _, err = p.shouldBe(THEN); err != nil { return nil, err } - if stmt.Cond, err = p.parseCond(); err != nil { - return nil, err - } - - if stmt.Group, err = p.parseGroup(); err != nil { - return nil, err - } - - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { + if stmt.Then, err = p.parseExpr(); err != nil { return nil, err } @@ -65,9 +54,9 @@ func (p *parser) parseDefineViewStatement() (stmt *DefineViewStatement, err erro } -func (p *parser) parseRemoveViewStatement() (stmt *RemoveViewStatement, err error) { +func (p *parser) parseRemoveEventStatement() (stmt *RemoveEventStatement, err error) { - stmt = &RemoveViewStatement{} + stmt = &RemoveEventStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { return nil, err @@ -77,7 +66,11 @@ func (p *parser) parseRemoveViewStatement() (stmt *RemoveViewStatement, err erro return nil, err } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { + if _, _, err = p.shouldBe(ON); err != nil { + return nil, err + } + + if stmt.What, err = p.parseTables(); err != nil { return nil, err } diff --git a/sql/exprs.go b/sql/exprs.go index 27eb9f26..2058200a 100644 --- a/sql/exprs.go +++ b/sql/exprs.go @@ -16,42 +16,22 @@ package sql import ( "fmt" - "regexp" + "sort" "time" - "golang.org/x/crypto/bcrypt" - - "github.com/abcum/surreal/util/rand" + "golang.org/x/text/language" ) func (p *parser) parseWhat() (mul []Expr, err error) { for { - tok, lit, err := p.shouldBe(IDENT, THING, PARAM, MODEL) + exp, err := p.parsePart() if err != nil { - return nil, &ParseError{Found: lit, Expected: []string{"table, or thing"}} + return nil, err } - if p.is(tok, IDENT) { - one, _ := p.declare(TABLE, lit) - mul = append(mul, one) - } - - if p.is(tok, THING) { - one, _ := p.declare(THING, lit) - mul = append(mul, one) - } - - if p.is(tok, PARAM) { - one, _ := p.declare(PARAM, lit) - mul = append(mul, one) - } - - if p.is(tok, MODEL) { - one, _ := p.declare(MODEL, lit) - mul = append(mul, one) - } + mul = append(mul, exp) // Check to see if the next token is a comma // and if not, then break out of the loop, @@ -67,6 +47,19 @@ func (p *parser) parseWhat() (mul []Expr, err error) { } +func (p *parser) parseValue() (*Value, error) { + + tok, lit, err := p.shouldBe(STRING, REGION) + if err != nil { + return nil, &ParseError{Found: lit, Expected: []string{"string"}} + } + + val, err := p.declare(tok, lit) + + return val.(*Value), err + +} + func (p *parser) parseIdent() (*Ident, error) { _, lit, err := p.shouldBe(IDENT) @@ -135,40 +128,6 @@ func (p *parser) parseTables() (mul Tables, err error) { } -func (p *parser) parseThing() (*Thing, error) { - - _, lit, err := p.shouldBe(THING) - if err != nil { - return nil, &ParseError{Found: lit, Expected: []string{"thing"}} - } - - val, err := p.declare(THING, lit) - - return val.(*Thing), err - -} - -func (p *parser) parseThings() (mul Things, err error) { - - for { - - one, err := p.parseThing() - if err != nil { - return nil, err - } - - mul = append(mul, one) - - if _, _, exi := p.mightBe(COMMA); !exi { - break - } - - } - - return - -} - func (p *parser) parseIdiom() (*Ident, error) { _, lit, err := p.shouldBe(IDENT, EXPR) @@ -225,92 +184,6 @@ func (p *parser) parseCond() (exp Expr, err error) { // // -------------------------------------------------- -func (p *parser) parseRand() (exp []byte, err error) { - - exp = rand.New(128) - - return - -} - -// -------------------------------------------------- -// -// -------------------------------------------------- - -func (p *parser) parseArray() (Array, error) { - - _, lit, err := p.shouldBe(ARRAY) - if err != nil { - return nil, &ParseError{Found: lit, Expected: []string{"array"}} - } - - val, err := p.declare(ARRAY, lit) - - return val.(Array), err - -} - -func (p *parser) parseObject() (Object, error) { - - _, lit, err := p.shouldBe(JSON) - if err != nil { - return nil, &ParseError{Found: lit, Expected: []string{"object"}} - } - - val, err := p.declare(JSON, lit) - - return val.(Object), err - -} - -func (p *parser) parseNumber() (int64, error) { - - _, lit, err := p.shouldBe(NUMBER) - if err != nil { - return int64(0), &ParseError{Found: lit, Expected: []string{"number"}} - } - - val, err := p.declare(NUMBER, lit) - - return val.(int64), err - -} - -func (p *parser) parseDouble() (float64, error) { - - _, lit, err := p.shouldBe(NUMBER, DOUBLE) - if err != nil { - return float64(0), &ParseError{Found: lit, Expected: []string{"number"}} - } - - val, err := p.declare(DOUBLE, lit) - - return val.(float64), err - -} - -func (p *parser) parseString() (string, error) { - - _, lit, err := p.shouldBe(STRING) - if err != nil { - return string(""), &ParseError{Found: lit, Expected: []string{"string"}} - } - - return lit, err - -} - -func (p *parser) parseRegion() (string, error) { - - _, lit, err := p.shouldBe(STRING, REGION) - if err != nil { - return string(""), &ParseError{Found: lit, Expected: []string{"string"}} - } - - return lit, err - -} - func (p *parser) parseBinary() ([]byte, error) { _, lit, err := p.shouldBe(STRING, REGION) @@ -322,40 +195,13 @@ func (p *parser) parseBinary() ([]byte, error) { } -func (p *parser) parseScript() (string, error) { +func (p *parser) parseTimeout() (time.Duration, error) { - _, lit, err := p.shouldBe(STRING, REGION) - if err != nil { - return string(""), &ParseError{Found: lit, Expected: []string{"script"}} + if _, _, exi := p.mightBe(TIMEOUT); !exi { + return 0, nil } - return lit, err - -} - -func (p *parser) parseRegexp() (string, error) { - - tok, lit, err := p.shouldBe(REGEX) - if err != nil { - return string(""), &ParseError{Found: lit, Expected: []string{"regular expression"}} - } - - val, err := p.declare(tok, lit) - - return val.(*regexp.Regexp).String(), err - -} - -func (p *parser) parseBoolean() (bool, error) { - - tok, lit, err := p.shouldBe(TRUE, FALSE) - if err != nil { - return bool(false), &ParseError{Found: lit, Expected: []string{"boolean"}} - } - - val, err := p.declare(tok, lit) - - return val.(bool), err + return p.parseDuration() } @@ -372,48 +218,69 @@ func (p *parser) parseDuration() (time.Duration, error) { } -func (p *parser) parseTimeout() (time.Duration, error) { +func (p *parser) parseType() (t, k string, err error) { - if _, _, exi := p.mightBe(TIMEOUT); !exi { - return 0, nil + _, t, err = p.shouldBe(IDENT, STRING) + if err != nil { + err = &ParseError{Found: t, Expected: allowedTypes} + return } - return p.parseDuration() + if !p.contains(t, allowedTypes) { + err = &ParseError{Found: t, Expected: allowedTypes} + return + } + + if t == "record" { + if _, _, exi := p.mightBe(LPAREN); exi { + if _, k, err = p.shouldBe(IDENT); err != nil { + return + } + if _, _, err = p.shouldBe(RPAREN); err != nil { + return + } + } + } + + return } -func (p *parser) parseBcrypt() ([]byte, error) { +func (p *parser) parseLanguage() (language.Tag, error) { - _, lit, err := p.shouldBe(STRING) + _, lit, err := p.shouldBe(IDENT, STRING) if err != nil { - return nil, &ParseError{Found: lit, Expected: []string{"string"}} + return language.English, &ParseError{Found: lit, Expected: []string{"string"}} } - return bcrypt.GenerateFromPassword([]byte(lit), bcrypt.DefaultCost) + tag, err := language.Parse(lit) + if err != nil { + return language.English, &ParseError{Found: lit, Expected: []string{"BCP47 language"}} + } + + if _, _, exi := p.mightBe(NUMERIC); exi { + tag, _ = tag.SetTypeForKey("kn", "true") + } + + return tag, err } func (p *parser) parseAlgorithm() (string, error) { - expected := []string{ - "ES256", "ES384", "ES512", - "HS256", "HS384", "HS512", - "PS256", "PS384", "PS512", - "RS256", "RS384", "RS512", - } - _, lit, err := p.shouldBe(IDENT, STRING) if err != nil { - return string(""), &ParseError{Found: lit, Expected: expected} + return string(""), &ParseError{Found: lit, Expected: allowedAlgorithms} } switch lit { - case "ES256", "ES384", "ES512": - case "HS256", "HS384", "HS512": - case "PS256", "PS384", "PS512": - case "RS256", "RS384", "RS512": + case + "ES256", "ES384", "ES512", + "HS256", "HS384", "HS512", + "PS256", "PS384", "PS512", + "RS256", "RS384", "RS512": default: - return string(""), &ParseError{Found: lit, Expected: expected} + return string(""), &ParseError{Found: lit, Expected: allowedAlgorithms} } return lit, err @@ -426,28 +293,40 @@ func (p *parser) parseExpr() (exp Expr, err error) { root := &BinaryExpression{} - // If the subsequent token is an in, out, or - // multi way path expression, then parse all - // following expressions as a path. + // If the primary token is an in, out, or + // multi way path expression, then follow + // the path through to the end. if tok, _, exi := p.mightBe(OEDGE, IEDGE, BEDGE); exi { - return p.parsePath(tok) - } - // Begin with parsing the first expression - // as the root of the tree to start with. + root.RHS, err = p.parsePath(tok) + if err != nil { + return nil, err + } - root.RHS, err = p.parsePart() - if err != nil { - return nil, err - } + } else { - // If the subsequent token is an in, out, or - // multi way path expression, then parse all - // following expressions as a path. + // Otherwise begin with parsing the first + // expression, as the root of the tree. + + root.RHS, err = p.parsePart() + if err != nil { + return nil, err + } + + // But if the subsequent token is an in, out, + // or multi way path expression, then follow + // the path through to the end. + + if tok, _, exi := p.mightBe(DOT, OEDGE, IEDGE, BEDGE); exi { + + root.RHS, err = p.parsePath(root.RHS, tok) + if err != nil { + return nil, err + } + + } - if tok, _, exi := p.mightBe(OEDGE, IEDGE, BEDGE); exi { - return p.parsePath(root.RHS, tok) } // Loop over the operations and expressions @@ -548,7 +427,7 @@ func (p *parser) parseExpr() (exp Expr, err error) { // of the expression and add it to the right. if rhs == nil { - rhs, err = p.parsePart() + rhs, err = p.parseExpr() if err != nil { return nil, err } @@ -562,6 +441,21 @@ func (p *parser) parseExpr() (exp Expr, err error) { for node := root; ; { r, ok := node.RHS.(*BinaryExpression) + // IMPORTANT fix binary OR/AND expressions + /*if !ok { + if node.Op.precedence() >= tok.precedence() { + node.RHS = &BinaryExpression{LHS: node.RHS, Op: tok, RHS: rhs} + break + } else { + r = &BinaryExpression{LHS: node, Op: tok, RHS: rhs} + break + } + } else { + if r.Op.precedence() >= tok.precedence() { + node.RHS = &BinaryExpression{LHS: node.RHS, Op: tok, RHS: rhs} + break + } + }*/ if !ok || r.Op.precedence() >= tok.precedence() { node.RHS = &BinaryExpression{LHS: node.RHS, Op: tok, RHS: rhs} break @@ -578,10 +472,10 @@ func (p *parser) parseExpr() (exp Expr, err error) { func (p *parser) parsePart() (exp Expr, err error) { toks := []Token{ - MUL, ID, EXPR, IDENT, THING, + MUL, EXPR, IDENT, THING, MODEL, NULL, VOID, EMPTY, MISSING, TRUE, FALSE, STRING, REGION, NUMBER, DOUBLE, - NOW, DATE, TIME, DURATION, JSON, ARRAY, PARAM, LPAREN, + DATE, TIME, DURATION, JSON, ARRAY, PARAM, LPAREN, IF, } tok, lit, _ := p.scan() @@ -595,6 +489,14 @@ func (p *parser) parsePart() (exp Expr, err error) { return nil, err } + // If the current token is a IF word clause + // then we will parse anything from here on + // as an IF expression clause. + + if p.is(tok, IF) { + return p.parseIfel() + } + // If the current token is a left parenthesis // bracket, then we will parse this complete // expression part as a subquery. @@ -628,33 +530,114 @@ func (p *parser) parseSubq() (sub *SubExpression, err error) { var exp Expr var tok Token - tok, _, _ = p.mightBe(SELECT, CREATE, UPDATE, DELETE, RELATE) + tok, _, _ = p.mightBe(SELECT, CREATE, UPDATE, DELETE, RELATE, INSERT, UPSERT) switch tok { - default: - exp, err = p.parseExpr() case SELECT: exp, err = p.parseSelectStatement() case CREATE: + p.buf.rw = true exp, err = p.parseCreateStatement() case UPDATE: + p.buf.rw = true exp, err = p.parseUpdateStatement() case DELETE: + p.buf.rw = true exp, err = p.parseDeleteStatement() case RELATE: + p.buf.rw = true exp, err = p.parseRelateStatement() + case INSERT: + p.buf.rw = true + exp, err = p.parseInsertStatement() + case UPSERT: + p.buf.rw = true + exp, err = p.parseUpsertStatement() + default: + exp, err = p.parseExpr() } - p.mightBe(RPAREN) + if err != nil { + return nil, err + } + + _, _, err = p.shouldBe(RPAREN) return &SubExpression{Expr: exp}, err } +func (p *parser) parseIfel() (exp *IfelExpression, err error) { + + exp = &IfelExpression{} + + for { + + var tok Token + + if cond, err := p.parseExpr(); err != nil { + return nil, err + } else { + exp.Cond = append(exp.Cond, cond) + } + + if _, _, err = p.shouldBe(THEN); err != nil { + return nil, err + } + + if then, err := p.parseExpr(); err != nil { + return nil, err + } else { + exp.Then = append(exp.Then, then) + } + + // Check to see if the next token is an + // ELSE keyword and if it is then check to + // see if there is another if statement. + + if tok, _, err = p.shouldBe(ELSE, END); err != nil { + return nil, err + } + + if tok == END { + return + } + + if tok == ELSE { + if _, _, exi := p.mightBe(IF); !exi { + break + } + } + + } + + if then, err := p.parseExpr(); err != nil { + return nil, err + } else { + exp.Else = then + } + + if _, _, err = p.shouldBe(END); err != nil { + return nil, err + } + + return + +} + func (p *parser) parseCall(name string) (fnc *FuncExpression, err error) { fnc = &FuncExpression{Name: name} + // Check to see if this is an aggregate + // function, and if it is then mark it, + // so we can process it correcyly in the + // 'iterator' and 'document' layers. + + if _, ok := aggrs[name]; ok { + fnc.Aggr = true + } + // Check to see if the immediate token // is a right parenthesis bracket, and if // it is then this function has no args. @@ -702,13 +685,27 @@ func (p *parser) parseCall(name string) (fnc *FuncExpression, err error) { } + // Check to see if this function is allowed to + // have an undefined number of arguments, and + // if it is then skip argument checking. + + if _, ok := funcs[fnc.Name][-1]; ok { + return + } + // Check to see if the number of arguments // is correct for the specified function name, // and if not, then return an error. if _, ok := funcs[fnc.Name][len(fnc.Args)]; !ok { - s, t := "", len(funcs[fnc.Name]) + s, a, t := "", []int{}, len(funcs[fnc.Name]) + + for i := range funcs[fnc.Name] { + a = append(a, i) + } + + sort.Ints(a) for i := 0; i < t; i++ { switch { @@ -717,13 +714,13 @@ func (p *parser) parseCall(name string) (fnc *FuncExpression, err error) { case i > 0: s = s + ", " } - s = s + fmt.Sprintf("%d", i) + s = s + fmt.Sprintf("%d", a[i]) } - switch { - case t == 1: + switch t { + case 1: s = s + " argument" - case t >= 2: + default: s = s + " arguments" } @@ -740,6 +737,17 @@ func (p *parser) parseCall(name string) (fnc *FuncExpression, err error) { func (p *parser) parsePath(expr ...Expr) (path *PathExpression, err error) { + defer func() { + if val, ok := path.Expr[len(path.Expr)-1].(*JoinExpression); ok { + if val.Join == DOT { + err = &ParseError{ + Found: fmt.Sprintf("."), + Expected: []string{"field expression"}, + } + } + } + }() + path = &PathExpression{} // Take the previosuly scanned expression @@ -820,7 +828,7 @@ func (p *parser) parsePath(expr ...Expr) (path *PathExpression, err error) { func (p *parser) parseJoin() (exp Expr, err error) { toks := []Token{ - OEDGE, IEDGE, BEDGE, + DOT, OEDGE, IEDGE, BEDGE, } tok, _, _ := p.scan() @@ -837,7 +845,7 @@ func (p *parser) parseJoin() (exp Expr, err error) { func (p *parser) parseStep() (exp Expr, err error) { toks := []Token{ - QMARK, IDENT, THING, PARAM, LPAREN, + QMARK, IDENT, THING, PARAM, LPAREN, EXPR, MUL, } tok, lit, _ := p.scan() @@ -876,6 +884,8 @@ func (p *parser) parseSubp() (stmt *SubpExpression, err error) { stmt = &SubpExpression{} + // IMPORTANT maybe we should not accept any expression here + if stmt.What, err = p.parseWhat(); err != nil { return nil, err } diff --git a/sql/field.go b/sql/field.go index 68decfb7..5a652d57 100644 --- a/sql/field.go +++ b/sql/field.go @@ -16,13 +16,13 @@ package sql func (p *parser) parseDefineFieldStatement() (stmt *DefineFieldStatement, err error) { - stmt = &DefineFieldStatement{} + stmt = &DefineFieldStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { return nil, err } - if stmt.Name, err = p.parseIdent(); err != nil { + if stmt.Name, err = p.parseIdiom(); err != nil { return nil, err } @@ -36,108 +36,44 @@ func (p *parser) parseDefineFieldStatement() (stmt *DefineFieldStatement, err er for { - tok, _, exi := p.mightBe(MIN, MAX, TYPE, ENUM, CODE, MATCH, DEFAULT, NOTNULL, READONLY, MANDATORY, VALIDATE, PERMISSIONS) + tok, _, exi := p.mightBe(TYPE, VALUE, ASSERT, PERMISSIONS) if !exi { break } - if p.is(tok, MIN) { - if stmt.Min, err = p.parseDouble(); err != nil { - return nil, err - } - } - - if p.is(tok, MAX) { - if stmt.Max, err = p.parseDouble(); err != nil { - return nil, err - } - } - if p.is(tok, TYPE) { - if stmt.Type, err = p.parseType(); err != nil { + if stmt.Type, stmt.Kind, err = p.parseType(); err != nil { return nil, err } } - if p.is(tok, ENUM) { - if stmt.Enum, err = p.parseArray(); err != nil { + if p.is(tok, VALUE) { + if stmt.Value, err = p.parseExpr(); err != nil { return nil, err } } - if p.is(tok, CODE) { - if stmt.Code, err = p.parseScript(); err != nil { + if p.is(tok, ASSERT) { + if stmt.Assert, err = p.parseExpr(); err != nil { return nil, err } } - if p.is(tok, MATCH) { - if stmt.Match, err = p.parseRegexp(); err != nil { - return nil, err - } - } - - if p.is(tok, DEFAULT) { - if stmt.Default, err = p.parseExpr(); err != nil { - return nil, err - } - } - - if p.is(tok, NOTNULL) { - stmt.Notnull = true - if tok, _, exi := p.mightBe(TRUE, FALSE); exi { - if tok == FALSE { - stmt.Notnull = false - } - } - } - - if p.is(tok, READONLY) { - stmt.Readonly = true - if tok, _, exi := p.mightBe(TRUE, FALSE); exi { - if tok == FALSE { - stmt.Readonly = false - } - } - } - - if p.is(tok, MANDATORY) { - stmt.Mandatory = true - if tok, _, exi := p.mightBe(TRUE, FALSE); exi { - if tok == FALSE { - stmt.Mandatory = false - } - } - } - - if p.is(tok, VALIDATE) { - stmt.Validate = true - if tok, _, exi := p.mightBe(TRUE, FALSE); exi { - if tok == FALSE { - stmt.Validate = false - } - } - } - if p.is(tok, PERMISSIONS) { - if stmt.Perm, err = p.parsePerms(); err != nil { + if stmt.Perms, err = p.parsePerms(); err != nil { return nil, err } } } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } func (p *parser) parseRemoveFieldStatement() (stmt *RemoveFieldStatement, err error) { - stmt = &RemoveFieldStatement{} + stmt = &RemoveFieldStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { return nil, err @@ -155,10 +91,6 @@ func (p *parser) parseRemoveFieldStatement() (stmt *RemoveFieldStatement, err er return nil, err } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/funcs.go b/sql/funcs.go index 7f398d5b..0c13af5e 100644 --- a/sql/funcs.go +++ b/sql/funcs.go @@ -14,233 +14,272 @@ package sql -var funcs = map[string]map[int]bool{ +var rolls = map[string]bool{ - "abs": { - 1: true, - }, + "distinct": true, - "avg": { - 1: true, - }, + // Count implementation - "ceil": { - 1: true, - }, + "count": true, + "count.if": true, + "count.not": true, - "count": { - 1: true, - }, + // Math implementation - "date": { - 0: true, - 1: true, - }, + "geometricmean": true, + "mean": true, + "percentile": true, + "stddev": true, + "sum": true, + "variance": true, - "day": { - 0: true, - 1: true, - }, + // Math implementation - "derivative": { - 1: true, - }, + "math.geometricmean": true, + "math.mean": true, + "math.percentile": true, + "math.stddev": true, + "math.sum": true, + "math.variance": true, +} - "difference": { - 1: true, - 2: true, - 3: true, - 4: true, - 5: true, - 6: true, - 7: true, - 8: true, - 9: true, - }, +var aggrs = map[string]bool{ - "distinct": { - 1: true, - }, + "distinct": true, - "floor": { - 1: true, - }, + // Count implementation - "hour": { - 0: true, - 1: true, - }, + "count": true, + "count.if": true, + "count.not": true, - "intersect": { - 1: true, - 2: true, - 3: true, - 4: true, - 5: true, - 6: true, - 7: true, - 8: true, - 9: true, - }, + // Math implementation - "max": { - 1: true, - }, + "bottom": true, + "geometricmean": true, + "harmonicmean": true, + "interquartile": true, + "max": true, + "mean": true, + "median": true, + "midhinge": true, + "min": true, + "mode": true, + "percentile": true, + "sample": true, + "spread": true, + "stddev": true, + "sum": true, + "top": true, + "trimean": true, + "variance": true, - "md5": { - 1: true, - }, + // Math implementation - "mean": { - 1: true, - }, + "math.bottom": true, + "math.geometricmean": true, + "math.harmonicmean": true, + "math.interquartile": true, + "math.max": true, + "math.mean": true, + "math.median": true, + "math.midhinge": true, + "math.min": true, + "math.mode": true, + "math.percentile": true, + "math.sample": true, + "math.spread": true, + "math.stddev": true, + "math.sum": true, + "math.top": true, + "math.trimean": true, + "math.variance": true, +} - "median": { - 1: true, - }, +var funcs = map[string]map[int]interface{}{ - "min": { - 1: true, - }, + "batch": {2: nil}, + "binary": {1: nil}, + "difference": {-1: nil}, + "distinct": {1: nil}, + "get": {2: nil}, + "if": {3: nil}, + "intersect": {-1: nil}, + "model": {2: nil, 3: nil, 4: nil}, + "table": {1: nil}, + "thing": {2: nil}, + "union": {-1: nil}, - "mins": { - 0: true, - 1: true, - }, + // Count implementation - "mode": { - 1: true, - }, + "count": {1: nil}, + "count.if": {2: nil}, + "count.not": {2: nil}, - "month": { - 0: true, - 1: true, - }, + // Json implementation + "json.decode": {1: nil}, + "json.encode": {1: nil}, - "now": { - 0: true, - }, + // Geo implementation + "geo.point": {1: nil, 2: nil}, + "geo.circle": {2: nil}, + "geo.polygon": {-1: nil}, + "geo.distance": {2: nil}, + "geo.inside": {2: nil}, + "geo.intersects": {2: nil}, + "geo.hash.decode": {1: nil}, + "geo.hash.encode": {2: nil}, - "percentile": { - 1: true, - }, + // Http implementation + "http.head": {1: nil, 2: nil}, + "http.get": {1: nil, 2: nil}, + "http.put": {1: nil, 2: nil, 3: nil}, + "http.post": {1: nil, 2: nil, 3: nil}, + "http.patch": {1: nil, 2: nil, 3: nil}, + "http.delete": {1: nil, 2: nil}, + "http.async.head": {1: nil, 2: nil}, + "http.async.get": {1: nil, 2: nil}, + "http.async.put": {1: nil, 2: nil, 3: nil}, + "http.async.post": {1: nil, 2: nil, 3: nil}, + "http.async.patch": {1: nil, 2: nil, 3: nil}, + "http.async.delete": {1: nil, 2: nil}, - "round": { - 1: true, - }, + // Math implementation + "abs": {1: nil}, + "bottom": {2: nil}, + "ceil": {1: nil}, + "correlation": {2: nil}, + "covariance": {2: nil}, + "floor": {1: nil}, + "geometricmean": {1: nil}, + "harmonicmean": {1: nil}, + "interquartile": {1: nil}, + "max": {1: nil}, + "mean": {1: nil}, + "median": {1: nil}, + "midhinge": {1: nil}, + "min": {1: nil}, + "mode": {1: nil}, + "percentile": {2: nil}, + "round": {2: nil}, + "sample": {2: nil}, + "spread": {1: nil}, + "stddev": {1: nil}, + "sum": {1: nil}, + "top": {2: nil}, + "trimean": {1: nil}, + "variance": {1: nil}, + "math.abs": {1: nil}, + "math.bottom": {2: nil}, + "math.ceil": {1: nil}, + "math.correlation": {2: nil}, + "math.covariance": {2: nil}, + "math.floor": {1: nil}, + "math.geometricmean": {1: nil}, + "math.harmonicmean": {1: nil}, + "math.interquartile": {1: nil}, + "math.max": {1: nil}, + "math.mean": {1: nil}, + "math.median": {1: nil}, + "math.midhinge": {1: nil}, + "math.min": {1: nil}, + "math.mode": {1: nil}, + "math.percentile": {2: nil}, + "math.round": {1: nil}, + "math.sample": {2: nil}, + "math.spread": {1: nil}, + "math.stddev": {1: nil}, + "math.sum": {1: nil}, + "math.top": {2: nil}, + "math.trimean": {1: nil}, + "math.variance": {1: nil}, - "stddev": { - 1: true, - }, + // String implementation + "string.concat": {-1: nil}, + "string.contains": {2: nil}, + "string.endsWith": {2: nil}, + "string.format": {-1: nil}, + "string.includes": {2: nil}, + "string.join": {-1: nil}, + "string.length": {1: nil}, + "string.lowercase": {1: nil}, + "string.repeat": {2: nil}, + "string.replace": {3: nil}, + "string.reverse": {3: nil}, + "string.search": {2: nil}, + "string.slice": {3: nil}, + "string.split": {2: nil}, + "string.startsWith": {2: nil}, + "string.substr": {3: nil}, + "string.trim": {1: nil}, + "string.uppercase": {1: nil}, + "string.words": {1: nil}, - "sum": { - 1: true, - }, + // Hash implementation + "hash.md5": {1: nil}, + "hash.sha1": {1: nil}, + "hash.sha256": {1: nil}, + "hash.sha512": {1: nil}, - "table": { - 1: true, - }, + // Time implementation + "time.now": {0: nil}, + "time.add": {2: nil}, + "time.age": {2: nil}, + "time.floor": {2: nil}, + "time.round": {2: nil}, + "time.day": {0: nil, 1: nil}, + "time.hour": {0: nil, 1: nil}, + "time.mins": {0: nil, 1: nil}, + "time.month": {0: nil, 1: nil}, + "time.nano": {0: nil, 1: nil}, + "time.secs": {0: nil, 1: nil}, + "time.unix": {0: nil, 1: nil}, + "time.year": {0: nil, 1: nil}, - "thing": { - 2: true, - }, - - "union": { - 1: true, - 2: true, - 3: true, - 4: true, - 5: true, - 6: true, - 7: true, - 8: true, - 9: true, - }, - - "unixtime": { - 0: true, - 1: true, - }, - - "uuid": { - 0: true, - }, - - "variance": { - 1: true, - }, - - "year": { - 0: true, - 1: true, - }, - - // HOTP implementation - - "hotp.compare": { - 2: true, - }, - - "hotp.generate": { - 1: true, - }, - - // TOTP implementation - - "totp.compare": { - 2: true, - }, - - "totp.generate": { - 1: true, - }, + // Email implementation + "email.user": {1: nil}, + "email.domain": {1: nil}, + "email.valid": {1: nil}, // Bcrypt implementation - - "bcrypt.compare": { - 2: true, - }, - - "bcrypt.generate": { - 1: true, - }, + "bcrypt.compare": {2: nil}, + "bcrypt.generate": {1: nil}, // Scrypt implementation + "scrypt.compare": {2: nil}, + "scrypt.generate": {1: nil}, - "scrypt.compare": { - 2: true, - }, - - "scrypt.generate": { - 1: true, - }, - - // Pbkdf2 implementation - - "pbkdf2.compare": { - 2: true, - }, - - "pbkdf2.generate": { - 1: true, - }, - - // Yubikey implementation - - "yubikey.id": { - 1: true, - }, - - "yubikey.ctr": { - 1: true, - }, - - "yubikey.use": { - 1: true, - }, - - "yubikey.verify": { - 2: true, // yubikey.verify(AUTHSERV, $otp) - 3: true, // yubikey.verify(CLIENTID, SECRET, $otp) - }, + // Random implementation + "rand": {0: nil}, + "uuid": {0: nil}, + "rand.bool": {0: nil}, + "rand.uuid": {0: nil}, + "rand.enum": {-1: nil}, + "rand.time": {0: nil, 2: nil}, + "rand.string": {0: nil, 1: nil, 2: nil}, + "rand.integer": {0: nil, 2: nil}, + "rand.decimal": {0: nil, 2: nil}, + "rand.sentence": {0: nil, 2: nil}, + "rand.paragraph": {0: nil, 2: nil}, + "rand.person.email": {0: nil}, + "rand.person.phone": {0: nil}, + "rand.person.fullname": {0: nil}, + "rand.person.firstname": {0: nil}, + "rand.person.lastname": {0: nil}, + "rand.person.username": {0: nil}, + "rand.person.jobtitle": {0: nil}, + "rand.company.name": {0: nil}, + "rand.company.industry": {0: nil}, + "rand.location.name": {0: nil}, + "rand.location.address": {0: nil}, + "rand.location.street": {0: nil}, + "rand.location.city": {0: nil}, + "rand.location.state": {0: nil}, + "rand.location.county": {0: nil}, + "rand.location.zipcode": {0: nil}, + "rand.location.postcode": {0: nil}, + "rand.location.country": {0: nil}, + "rand.location.altitude": {0: nil}, + "rand.location.latitude": {0: nil}, + "rand.location.longitude": {0: nil}, } diff --git a/sql/gen.go b/sql/gen.go index f46a7dce..d32764a1 100644 --- a/sql/gen.go +++ b/sql/gen.go @@ -17,3 +17,7 @@ package sql //go:generate go get -u github.com/abcum/tmpl //go:generate tmpl -file=auth.gen.json auth.gen.go.tmpl //go:generate tmpl -file=kill.gen.json kill.gen.go.tmpl +//go:generate tmpl -file=rdwr.gen.json rdwr.gen.go.tmpl + +//go:generate go get -u github.com/ugorji/go/codec/codecgen +//go:generate codecgen -o ast.gen.go ast.go diff --git a/sql/if.go b/sql/if.go new file mode 100644 index 00000000..4c15442f --- /dev/null +++ b/sql/if.go @@ -0,0 +1,83 @@ +// Copyright © 2016 Abcum Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sql + +func (p *parser) parseIfStatement() (stmt *IfStatement, err error) { + + stmt = &IfStatement{} + + for { + + var tok Token + + if cond, err := p.parseExpr(); err != nil { + return nil, err + } else { + stmt.Cond = append(stmt.Cond, cond) + } + + if _, _, err = p.shouldBe(THEN); err != nil { + return nil, err + } + + if then, err := p.parseExpr(); err != nil { + return nil, err + } else { + stmt.Then = append(stmt.Then, then) + } + + // Check to see if the next token is an + // ELSE keyword and if it is then check to + // see if there is another if statement. + + if tok, _, err = p.shouldBe(ELSE, END); err != nil { + return nil, err + } + + if tok == END { + return + } + + if tok == ELSE { + if _, _, exi := p.mightBe(IF); !exi { + break + } + } + + } + + // Check to see if the next token is an + // ELSE keyword and if it is then check to + // see if there is another if statement. + + if then, err := p.parseExpr(); err != nil { + return nil, err + } else { + stmt.Else = then + } + + if _, _, err = p.shouldBe(END); err != nil { + return nil, err + } + + // If this query has any subqueries which + // need to alter the database then mark + // this query as a writeable statement. + + stmt.RW = p.buf.rw + + return + +} diff --git a/sql/index.go b/sql/index.go index 123111b5..918d3f31 100644 --- a/sql/index.go +++ b/sql/index.go @@ -16,7 +16,7 @@ package sql func (p *parser) parseDefineIndexStatement() (stmt *DefineIndexStatement, err error) { - stmt = &DefineIndexStatement{} + stmt = &DefineIndexStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { return nil, err @@ -44,17 +44,13 @@ func (p *parser) parseDefineIndexStatement() (stmt *DefineIndexStatement, err er _, _, stmt.Uniq = p.mightBe(UNIQUE) - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } func (p *parser) parseRemoveIndexStatement() (stmt *RemoveIndexStatement, err error) { - stmt = &RemoveIndexStatement{} + stmt = &RemoveIndexStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { return nil, err @@ -72,10 +68,6 @@ func (p *parser) parseRemoveIndexStatement() (stmt *RemoveIndexStatement, err er return nil, err } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/info.go b/sql/info.go index 92a8b9af..46d42eae 100644 --- a/sql/info.go +++ b/sql/info.go @@ -16,7 +16,7 @@ package sql func (p *parser) parseInfoStatement() (stmt *InfoStatement, err error) { - stmt = &InfoStatement{} + stmt = &InfoStatement{RW: false} if _, _, err = p.shouldBe(FOR); err != nil { return nil, err @@ -47,10 +47,6 @@ func (p *parser) parseInfoStatement() (stmt *InfoStatement, err error) { } } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/insert.go b/sql/insert.go new file mode 100644 index 00000000..d7808f45 --- /dev/null +++ b/sql/insert.go @@ -0,0 +1,49 @@ +// Copyright © 2016 Abcum Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sql + +func (p *parser) parseInsertStatement() (stmt *InsertStatement, err error) { + + stmt = &InsertStatement{RW: true} + + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil { + return nil, err + } + + if stmt.Data, err = p.parseExpr(); err != nil { + return nil, err + } + + if _, _, err = p.shouldBe(INTO); err != nil { + return nil, err + } + + _, _, _ = p.mightBe(TABLE) + + if stmt.Into, err = p.parseTable(); err != nil { + return nil, err + } + + if stmt.Echo, err = p.parseEcho(AFTER); err != nil { + return nil, err + } + + if stmt.Timeout, err = p.parseTimeout(); err != nil { + return nil, err + } + + return + +} diff --git a/sql/kill.gen.go b/sql/kill.gen.go index bf71ffdb..a2f81a12 100644 --- a/sql/kill.gen.go +++ b/sql/kill.gen.go @@ -22,202 +22,30 @@ import ( "time" ) -func (s *SelectStatement) Begin() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - s.killable.ticker = time.AfterFunc(s.Timeout, func() { - s.killable.ticker.Stop() - s.killable.ticker = nil - close(s.killable.closer) - }) -} - -func (s *SelectStatement) Cease() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - if s.killable.ticker != nil { - s.killable.ticker.Stop() - } -} - func (s *SelectStatement) Duration() time.Duration { return s.Timeout } -func (s *SelectStatement) Timedout() <-chan struct{} { - if s.Timeout == 0 { - return nil - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - return s.killable.closer -} - -func (s *CreateStatement) Begin() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - s.killable.ticker = time.AfterFunc(s.Timeout, func() { - s.killable.ticker.Stop() - s.killable.ticker = nil - close(s.killable.closer) - }) -} - -func (s *CreateStatement) Cease() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - if s.killable.ticker != nil { - s.killable.ticker.Stop() - } -} - func (s *CreateStatement) Duration() time.Duration { return s.Timeout } -func (s *CreateStatement) Timedout() <-chan struct{} { - if s.Timeout == 0 { - return nil - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - return s.killable.closer -} - -func (s *UpdateStatement) Begin() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - s.killable.ticker = time.AfterFunc(s.Timeout, func() { - s.killable.ticker.Stop() - s.killable.ticker = nil - close(s.killable.closer) - }) -} - -func (s *UpdateStatement) Cease() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - if s.killable.ticker != nil { - s.killable.ticker.Stop() - } -} - func (s *UpdateStatement) Duration() time.Duration { return s.Timeout } -func (s *UpdateStatement) Timedout() <-chan struct{} { - if s.Timeout == 0 { - return nil - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - return s.killable.closer -} - -func (s *DeleteStatement) Begin() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - s.killable.ticker = time.AfterFunc(s.Timeout, func() { - s.killable.ticker.Stop() - s.killable.ticker = nil - close(s.killable.closer) - }) -} - -func (s *DeleteStatement) Cease() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - if s.killable.ticker != nil { - s.killable.ticker.Stop() - } -} - func (s *DeleteStatement) Duration() time.Duration { return s.Timeout } -func (s *DeleteStatement) Timedout() <-chan struct{} { - if s.Timeout == 0 { - return nil - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - return s.killable.closer -} - -func (s *RelateStatement) Begin() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - s.killable.ticker = time.AfterFunc(s.Timeout, func() { - s.killable.ticker.Stop() - s.killable.ticker = nil - close(s.killable.closer) - }) -} - -func (s *RelateStatement) Cease() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - if s.killable.ticker != nil { - s.killable.ticker.Stop() - } -} - func (s *RelateStatement) Duration() time.Duration { return s.Timeout } -func (s *RelateStatement) Timedout() <-chan struct{} { - if s.Timeout == 0 { - return nil - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - return s.killable.closer +func (s *InsertStatement) Duration() time.Duration { + return s.Timeout +} + +func (s *UpsertStatement) Duration() time.Duration { + return s.Timeout } diff --git a/sql/kill.gen.go.tmpl b/sql/kill.gen.go.tmpl index 29f046df..c4b69eaf 100644 --- a/sql/kill.gen.go.tmpl +++ b/sql/kill.gen.go.tmpl @@ -20,44 +20,8 @@ import ( {{with $types := .}}{{range $k := $types}} -func (s *{{$k.name}}Statement) Begin() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - s.killable.ticker = time.AfterFunc(s.Timeout, func() { - s.killable.ticker.Stop() - s.killable.ticker = nil - close(s.killable.closer) - }) -} - -func (s *{{$k.name}}Statement) Cease() { - if s.Timeout == 0 { - return - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - if s.killable.ticker != nil { - s.killable.ticker.Stop() - } -} - func (s *{{$k.name}}Statement) Duration() time.Duration { return s.Timeout } -func (s *{{$k.name}}Statement) Timedout() <-chan struct{} { - if s.Timeout == 0 { - return nil - } - if s.killable.closer == nil { - s.killable.closer = make(chan struct{}) - } - return s.killable.closer -} - {{end}}{{end}} diff --git a/sql/kill.gen.json b/sql/kill.gen.json index c0c45a41..067d9045 100644 --- a/sql/kill.gen.json +++ b/sql/kill.gen.json @@ -3,5 +3,7 @@ { "name": "Create" }, { "name": "Update" }, { "name": "Delete" }, - { "name": "Relate" } + { "name": "Relate" }, + { "name": "Insert" }, + { "name": "Upsert" } ] diff --git a/sql/kill_test.go b/sql/kill_test.go new file mode 100644 index 00000000..1c73541c --- /dev/null +++ b/sql/kill_test.go @@ -0,0 +1,65 @@ +// Code generated by https://github.com/abcum/tmpl +// Source file: kill.gen.go.tmpl +// DO NOT EDIT! + +// Copyright © 2016 Abcum Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sql + +import ( + "testing" + "time" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestKill(t *testing.T) { + + Convey("SelectStatement should have duration", t, func() { + So((&SelectStatement{}).Duration(), ShouldEqual, 0) + So((&SelectStatement{Timeout: 1 * time.Second}).Duration(), ShouldEqual, 1*time.Second) + }) + + Convey("CreateStatement should have duration", t, func() { + So((&CreateStatement{}).Duration(), ShouldEqual, 0) + So((&CreateStatement{Timeout: 1 * time.Second}).Duration(), ShouldEqual, 1*time.Second) + }) + + Convey("UpdateStatement should have duration", t, func() { + So((&UpdateStatement{}).Duration(), ShouldEqual, 0) + So((&UpdateStatement{Timeout: 1 * time.Second}).Duration(), ShouldEqual, 1*time.Second) + }) + + Convey("DeleteStatement should have duration", t, func() { + So((&DeleteStatement{}).Duration(), ShouldEqual, 0) + So((&DeleteStatement{Timeout: 1 * time.Second}).Duration(), ShouldEqual, 1*time.Second) + }) + + Convey("RelateStatement should have duration", t, func() { + So((&RelateStatement{}).Duration(), ShouldEqual, 0) + So((&RelateStatement{Timeout: 1 * time.Second}).Duration(), ShouldEqual, 1*time.Second) + }) + + Convey("InsertStatement should have duration", t, func() { + So((&InsertStatement{}).Duration(), ShouldEqual, 0) + So((&InsertStatement{Timeout: 1 * time.Second}).Duration(), ShouldEqual, 1*time.Second) + }) + + Convey("UpsertStatement should have duration", t, func() { + So((&UpsertStatement{}).Duration(), ShouldEqual, 0) + So((&UpsertStatement{Timeout: 1 * time.Second}).Duration(), ShouldEqual, 1*time.Second) + }) + +} diff --git a/sql/let.go b/sql/let.go index 6d9e6112..21b0cc85 100644 --- a/sql/let.go +++ b/sql/let.go @@ -14,8 +14,6 @@ package sql -import "time" - func (p *parser) parseLetStatement() (stmt *LetStatement, err error) { stmt = &LetStatement{} @@ -51,31 +49,11 @@ func (p *parser) parseLetStatement() (stmt *LetStatement, err error) { return nil, err } - // If the defined paramater is a basic type, - // then instead of defining it at a later - // stage, convert it to that type here. + // If this query has any subqueries which + // need to alter the database then mark + // this query as a writeable statement. - switch stmt.What.(type) { - case bool, int64, float64, string: - p.v[stmt.Name.ID] = stmt.What - case []interface{}, map[string]interface{}: - p.v[stmt.Name.ID] = stmt.What - case time.Time, time.Duration: - p.v[stmt.Name.ID] = stmt.What - case Array, Object: - p.v[stmt.Name.ID] = stmt.What - case *Null, *Void, *Empty: - p.v[stmt.Name.ID] = stmt.What - case *Table, *Thing, *Param, *Ident, *Value: - p.v[stmt.Name.ID] = stmt.What - } - - // Check that we have reached the end of the - // statement with either a ';' or EOF. - - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } + stmt.RW = p.buf.rw return diff --git a/sql/live.go b/sql/live.go new file mode 100644 index 00000000..879db673 --- /dev/null +++ b/sql/live.go @@ -0,0 +1,71 @@ +// Copyright © 2016 Abcum Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sql + +func (p *parser) parseLiveStatement() (stmt *LiveStatement, err error) { + + stmt = &LiveStatement{RW: true} + + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthSC); err != nil { + return nil, err + } + + _, _, err = p.shouldBe(SELECT) + if err != nil { + return nil, err + } + + _, _, stmt.Diff = p.mightBe(DIFF) + + if stmt.Diff == false { + + if stmt.Expr, err = p.parseFields(); err != nil { + return nil, err + } + + } + + _, _, err = p.shouldBe(FROM) + if err != nil { + return nil, err + } + + if stmt.What, err = p.parseTable(); err != nil { + return nil, err + } + + if stmt.Cond, err = p.parseCond(); err != nil { + return nil, err + } + + return + +} + +func (p *parser) parseKillStatement() (stmt *KillStatement, err error) { + + stmt = &KillStatement{RW: true} + + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthSC); err != nil { + return nil, err + } + + if stmt.Name, err = p.parseValue(); err != nil { + return nil, err + } + + return + +} diff --git a/sql/login.go b/sql/login.go index 49847d93..8cb57b61 100644 --- a/sql/login.go +++ b/sql/login.go @@ -16,7 +16,7 @@ package sql func (p *parser) parseDefineLoginStatement() (stmt *DefineLoginStatement, err error) { - stmt = &DefineLoginStatement{} + stmt = &DefineLoginStatement{RW: true} if stmt.User, err = p.parseIdent(); err != nil { return nil, err @@ -50,17 +50,13 @@ func (p *parser) parseDefineLoginStatement() (stmt *DefineLoginStatement, err er return nil, err } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } func (p *parser) parseRemoveLoginStatement() (stmt *RemoveLoginStatement, err error) { - stmt = &RemoveLoginStatement{} + stmt = &RemoveLoginStatement{RW: true} if stmt.User, err = p.parseIdent(); err != nil { return nil, err @@ -86,10 +82,6 @@ func (p *parser) parseRemoveLoginStatement() (stmt *RemoveLoginStatement, err er } } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/namespace.go b/sql/namespace.go index be7a30cc..cd2cc3bd 100644 --- a/sql/namespace.go +++ b/sql/namespace.go @@ -16,7 +16,7 @@ package sql func (p *parser) parseDefineNamespaceStatement() (stmt *DefineNamespaceStatement, err error) { - stmt = &DefineNamespaceStatement{} + stmt = &DefineNamespaceStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthKV); err != nil { return nil, err @@ -32,7 +32,7 @@ func (p *parser) parseDefineNamespaceStatement() (stmt *DefineNamespaceStatement func (p *parser) parseRemoveNamespaceStatement() (stmt *RemoveNamespaceStatement, err error) { - stmt = &RemoveNamespaceStatement{} + stmt = &RemoveNamespaceStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthKV); err != nil { return nil, err diff --git a/sql/options.go b/sql/options.go index 96baf56c..e330684a 100644 --- a/sql/options.go +++ b/sql/options.go @@ -73,9 +73,15 @@ func (o *options) ns(ns string) (err error) { // Check to see that the current user has // the necessary authentication privileges // to be able to specify this namespace. + // This is only run if we are using the + // KV, NS, or DB authentication levels, as + // SC authentication levels make use of + // table and field permissions instead. - if o.auth.Possible.NS != "*" && o.auth.Possible.NS != ns { - return &PermsError{Resource: ns} + if o.auth.Kind < cnf.Kind(AuthSC) { + if o.auth.Possible.NS != "*" && o.auth.Possible.NS != ns { + return &PermsError{Resource: ns} + } } // Specify the NS on the context session, so @@ -93,9 +99,15 @@ func (o *options) db(db string) (err error) { // Check to see that the current user has // the necessary authentication privileges // to be able to specify this namespace. + // This is only run if we are using the + // KV, NS, or DB authentication levels, as + // SC authentication levels make use of + // table and field permissions instead. - if o.auth.Possible.DB != "*" && o.auth.Possible.DB != db { - return &PermsError{Resource: db} + if o.auth.Kind < cnf.Kind(AuthSC) { + if o.auth.Possible.DB != "*" && o.auth.Possible.DB != db { + return &PermsError{Resource: db} + } } // Specify the DB on the context session, so diff --git a/sql/parser.go b/sql/parser.go index aae93f33..f9fbe608 100644 --- a/sql/parser.go +++ b/sql/parser.go @@ -29,9 +29,9 @@ type parser struct { s *scanner o *options c *fibre.Context - v map[string]interface{} buf struct { n int // buffer size + rw bool // writeable txn bool // inside txn tok Token // last read token lit string // last read literal @@ -40,51 +40,47 @@ type parser struct { } // Parse parses sql from a []byte, string, or io.Reader. -func Parse(c *fibre.Context, i interface{}, v map[string]interface{}) (*Query, error) { +func Parse(c *fibre.Context, i interface{}) (*Query, error) { defer trace.FromContext(c.Context()).NewChild("sql.Parse").Finish() - if v == nil { - v = make(map[string]interface{}) - } - switch x := i.(type) { default: return nil, &EmptyError{} case []byte: - return parseBytes(c, x, v) + return parseBytes(c, x) case string: - return parseString(c, x, v) + return parseString(c, x) case io.Reader: - return parseBuffer(c, x, v) + return parseBuffer(c, x) } } // newParser returns a new instance of Parser. -func newParser(c *fibre.Context, v map[string]interface{}) *parser { - return &parser{c: c, v: v, o: newOptions(c)} +func newParser(c *fibre.Context) *parser { + return &parser{c: c, o: newOptions(c)} } // parseBytes parses a byte array. -func parseBytes(c *fibre.Context, i []byte, v map[string]interface{}) (*Query, error) { +func parseBytes(c *fibre.Context, i []byte) (*Query, error) { + p := newParser(c) r := bytes.NewReader(i) - p := newParser(c, v) p.s = newScanner(p, r) return p.parse() } // parseString parses a string. -func parseString(c *fibre.Context, i string, v map[string]interface{}) (*Query, error) { +func parseString(c *fibre.Context, i string) (*Query, error) { + p := newParser(c) r := strings.NewReader(i) - p := newParser(c, v) p.s = newScanner(p, r) return p.parse() } // parseBuffer parses a buffer. -func parseBuffer(c *fibre.Context, r io.Reader, v map[string]interface{}) (*Query, error) { - p := newParser(c, v) +func parseBuffer(c *fibre.Context, r io.Reader) (*Query, error) { + p := newParser(c) p.s = newScanner(p, r) return p.parse() } @@ -97,40 +93,91 @@ func (p *parser) parse() (*Query, error) { // parseMulti parses multiple SQL SELECT statements. func (p *parser) parseMulti() (*Query, error) { - var statements Statements - var semi bool - var text bool + + var stmts Statements for { - if tok, _, _ := p.scan(); tok == EOF { - if !text { - return nil, &EmptyError{} + + // If the next token is an EOF then + // check to see if the query is empty + // or return the parsed statements. + + if _, _, exi := p.mightBe(EOF); exi { + if len(stmts) == 0 { + return nil, new(EmptyError) } - return &Query{Statements: statements}, nil - } else if !semi && tok == SEMICOLON { - semi = true - } else { - text = true - p.unscan() - s, err := p.parseSingle() - if err != nil { - return nil, err - } - statements = append(statements, s) - semi = false + return &Query{Statements: stmts}, nil } + + // If this is a multi statement query + // and there is no semicolon separating + // the statements, then return an error. + + if len(stmts) > 0 { + switch semi { + case true: + _, _, exi := p.mightBe(SEMICOLON) + if exi { + continue + } + case false: + _, _, err := p.shouldBe(SEMICOLON) + if err != nil { + return nil, err + } + semi = true + continue + } + } + + // Parse the next token as a statement + // and append it to the statements + // array for the current sql query. + + stmt, err := p.parseSingle() + if err != nil { + return nil, err + } + + stmts = append(stmts, stmt) + } } // parseSingle parses a single SQL SELECT statement. -func (p *parser) parseSingle() (Statement, error) { +func (p *parser) parseSingle() (stmt Statement, err error) { - tok, _, err := p.shouldBe(USE, INFO, BEGIN, CANCEL, COMMIT, LET, RETURN, SELECT, CREATE, UPDATE, DELETE, RELATE, DEFINE, REMOVE) + p.buf.rw = false + + tok, _, err := p.shouldBe( + USE, + INFO, + BEGIN, + CANCEL, + COMMIT, + IF, + LET, + RETURN, + LIVE, + KILL, + SELECT, + CREATE, + UPDATE, + DELETE, + RELATE, + INSERT, + UPSERT, + DEFINE, + REMOVE, + ) switch tok { + case IF: + return p.parseIfStatement() + case USE: return p.parseUseStatement() @@ -140,12 +187,18 @@ func (p *parser) parseSingle() (Statement, error) { case INFO: return p.parseInfoStatement() + case LIVE: + return p.parseLiveStatement() + case KILL: + return p.parseKillStatement() + case BEGIN: return p.parseBeginStatement() case CANCEL: return p.parseCancelStatement() case COMMIT: return p.parseCommitStatement() + case RETURN: return p.parseReturnStatement() @@ -160,6 +213,11 @@ func (p *parser) parseSingle() (Statement, error) { case RELATE: return p.parseRelateStatement() + case INSERT: + return p.parseInsertStatement() + case UPSERT: + return p.parseUpsertStatement() + case DEFINE: return p.parseDefineStatement() case REMOVE: diff --git a/sql/perms.go b/sql/perms.go index 1f16658a..79a7ca6d 100644 --- a/sql/perms.go +++ b/sql/perms.go @@ -21,7 +21,6 @@ func (p *parser) parsePerms() (exp *PermExpression, err error) { Create: false, Update: false, Delete: false, - Relate: false, } tok, _, err := p.shouldBe(FOR, NONE, FULL, WHERE) @@ -48,7 +47,6 @@ func (p *parser) parsePerms() (exp *PermExpression, err error) { exp.Create = expr exp.Update = expr exp.Delete = expr - exp.Relate = expr return @@ -62,7 +60,7 @@ func (p *parser) parsePerms() (exp *PermExpression, err error) { var when []Token for { - tok, _, err := p.shouldBe(SELECT, CREATE, UPDATE, DELETE, RELATE) + tok, _, err := p.shouldBe(SELECT, CREATE, UPDATE, DELETE) if err != nil { return exp, err } @@ -98,8 +96,6 @@ func (p *parser) parsePerms() (exp *PermExpression, err error) { exp.Update = expr case DELETE: exp.Delete = expr - case RELATE: - exp.Relate = expr } } diff --git a/sql/rdwr.gen.go b/sql/rdwr.gen.go new file mode 100644 index 00000000..5403f279 --- /dev/null +++ b/sql/rdwr.gen.go @@ -0,0 +1,143 @@ +// Code generated by https://github.com/abcum/tmpl +// Source file: rdwr.gen.go.tmpl +// DO NOT EDIT! + +// Copyright © 2016 Abcum Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sql + +func (s *InfoStatement) Writeable() bool { + return s.RW +} + +func (s *IfStatement) Writeable() bool { + return s.RW +} + +func (s *LetStatement) Writeable() bool { + return s.RW +} + +func (s *ReturnStatement) Writeable() bool { + return s.RW +} + +func (s *LiveStatement) Writeable() bool { + return s.RW +} + +func (s *KillStatement) Writeable() bool { + return s.RW +} + +func (s *SelectStatement) Writeable() bool { + return s.RW +} + +func (s *CreateStatement) Writeable() bool { + return s.RW +} + +func (s *UpdateStatement) Writeable() bool { + return s.RW +} + +func (s *DeleteStatement) Writeable() bool { + return s.RW +} + +func (s *RelateStatement) Writeable() bool { + return s.RW +} + +func (s *InsertStatement) Writeable() bool { + return s.RW +} + +func (s *UpsertStatement) Writeable() bool { + return s.RW +} + +func (s *DefineNamespaceStatement) Writeable() bool { + return s.RW +} + +func (s *RemoveNamespaceStatement) Writeable() bool { + return s.RW +} + +func (s *DefineDatabaseStatement) Writeable() bool { + return s.RW +} + +func (s *RemoveDatabaseStatement) Writeable() bool { + return s.RW +} + +func (s *DefineLoginStatement) Writeable() bool { + return s.RW +} + +func (s *RemoveLoginStatement) Writeable() bool { + return s.RW +} + +func (s *DefineTokenStatement) Writeable() bool { + return s.RW +} + +func (s *RemoveTokenStatement) Writeable() bool { + return s.RW +} + +func (s *DefineScopeStatement) Writeable() bool { + return s.RW +} + +func (s *RemoveScopeStatement) Writeable() bool { + return s.RW +} + +func (s *DefineTableStatement) Writeable() bool { + return s.RW +} + +func (s *RemoveTableStatement) Writeable() bool { + return s.RW +} + +func (s *DefineEventStatement) Writeable() bool { + return s.RW +} + +func (s *RemoveEventStatement) Writeable() bool { + return s.RW +} + +func (s *DefineFieldStatement) Writeable() bool { + return s.RW +} + +func (s *RemoveFieldStatement) Writeable() bool { + return s.RW +} + +func (s *DefineIndexStatement) Writeable() bool { + return s.RW +} + +func (s *RemoveIndexStatement) Writeable() bool { + return s.RW +} diff --git a/sql/type.go b/sql/rdwr.gen.go.tmpl similarity index 54% rename from sql/type.go rename to sql/rdwr.gen.go.tmpl index 68a4fc3a..7ec78df0 100644 --- a/sql/type.go +++ b/sql/rdwr.gen.go.tmpl @@ -14,19 +14,10 @@ package sql -func (p *parser) parseType() (exp string, err error) { - - allowed := []string{"any", "url", "uuid", "color", "email", "phone", "array", "object", "domain", "record", "string", "number", "double", "custom", "boolean", "password", "datetime", "latitude", "longitude"} - - _, lit, err := p.shouldBe(IDENT) - if err != nil { - return string(""), &ParseError{Found: lit, Expected: allowed} - } - - if !p.contains(lit, allowed) { - return string(""), &ParseError{Found: lit, Expected: allowed} - } - - return lit, err +{{with $types := .}}{{range $k := $types}} +func (s *{{$k.name}}Statement) Writeable() bool { + return s.RW } + +{{end}}{{end}} diff --git a/sql/rdwr.gen.json b/sql/rdwr.gen.json new file mode 100644 index 00000000..802d6941 --- /dev/null +++ b/sql/rdwr.gen.json @@ -0,0 +1,36 @@ +[ + { "name": "Info" }, + + { "name": "If" }, + { "name": "Let" }, + { "name": "Return" }, + + { "name": "Live" }, + { "name": "Kill" }, + { "name": "Select" }, + { "name": "Create" }, + { "name": "Update" }, + { "name": "Delete" }, + { "name": "Relate" }, + { "name": "Insert" }, + { "name": "Upsert" }, + + { "name": "DefineNamespace" }, + { "name": "RemoveNamespace" }, + { "name": "DefineDatabase" }, + { "name": "RemoveDatabase" }, + { "name": "DefineLogin" }, + { "name": "RemoveLogin" }, + { "name": "DefineToken" }, + { "name": "RemoveToken" }, + { "name": "DefineScope" }, + { "name": "RemoveScope" }, + { "name": "DefineTable" }, + { "name": "RemoveTable" }, + { "name": "DefineEvent" }, + { "name": "RemoveEvent" }, + { "name": "DefineField" }, + { "name": "RemoveField" }, + { "name": "DefineIndex" }, + { "name": "RemoveIndex" } +] diff --git a/sql/rdwr_test.go b/sql/rdwr_test.go new file mode 100644 index 00000000..9090e8ec --- /dev/null +++ b/sql/rdwr_test.go @@ -0,0 +1,215 @@ +// Code generated by https://github.com/abcum/tmpl +// Source file: auth.gen.go.tmpl +// DO NOT EDIT! + +// Copyright © 2016 Abcum Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sql + +import ( + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestRdwr(t *testing.T) { + + Convey("InfoStatement should auth correctly", t, func() { + s := &InfoStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("IfStatement should auth correctly", t, func() { + s := &IfStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("LetStatement should auth correctly", t, func() { + s := &LetStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("ReturnStatement should auth correctly", t, func() { + s := &ReturnStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("LiveStatement should auth correctly", t, func() { + s := &LiveStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("KillStatement should auth correctly", t, func() { + s := &KillStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("SelectStatement should auth correctly", t, func() { + s := &SelectStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("CreateStatement should auth correctly", t, func() { + s := &CreateStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("UpdateStatement should auth correctly", t, func() { + s := &UpdateStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("DeleteStatement should auth correctly", t, func() { + s := &DeleteStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("RelateStatement should auth correctly", t, func() { + s := &RelateStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("InsertStatement should auth correctly", t, func() { + s := &InsertStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("UpsertStatement should auth correctly", t, func() { + s := &UpsertStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("DefineNamespaceStatement should auth correctly", t, func() { + s := &DefineNamespaceStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("RemoveNamespaceStatement should auth correctly", t, func() { + s := &RemoveNamespaceStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("DefineDatabaseStatement should auth correctly", t, func() { + s := &DefineDatabaseStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("RemoveDatabaseStatement should auth correctly", t, func() { + s := &RemoveDatabaseStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("DefineLoginStatement should auth correctly", t, func() { + s := &DefineLoginStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("RemoveLoginStatement should auth correctly", t, func() { + s := &RemoveLoginStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("DefineTokenStatement should auth correctly", t, func() { + s := &DefineTokenStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("RemoveTokenStatement should auth correctly", t, func() { + s := &RemoveTokenStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("DefineScopeStatement should auth correctly", t, func() { + s := &DefineScopeStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("RemoveScopeStatement should auth correctly", t, func() { + s := &RemoveScopeStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("DefineTableStatement should auth correctly", t, func() { + s := &DefineTableStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("RemoveTableStatement should auth correctly", t, func() { + s := &RemoveTableStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("DefineEventStatement should auth correctly", t, func() { + s := &DefineEventStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("RemoveEventStatement should auth correctly", t, func() { + s := &RemoveEventStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("DefineFieldStatement should auth correctly", t, func() { + s := &DefineFieldStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("RemoveFieldStatement should auth correctly", t, func() { + s := &RemoveFieldStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("DefineIndexStatement should auth correctly", t, func() { + s := &DefineIndexStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + + Convey("RemoveIndexStatement should auth correctly", t, func() { + s := &RemoveIndexStatement{RW: true} + w := s.Writeable() + So(w, ShouldEqual, true) + }) + +} diff --git a/sql/relate.go b/sql/relate.go index 9edc26a0..b2cc7eff 100644 --- a/sql/relate.go +++ b/sql/relate.go @@ -16,9 +16,9 @@ package sql func (p *parser) parseRelateStatement() (stmt *RelateStatement, err error) { - stmt = &RelateStatement{} + stmt = &RelateStatement{RW: true} - if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthSC); err != nil { + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil { return nil, err } @@ -56,10 +56,6 @@ func (p *parser) parseRelateStatement() (stmt *RelateStatement, err error) { return nil, err } - if _, _, err = p.shouldBe(EOF, RPAREN, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/remove.go b/sql/remove.go index dec2e8a2..97bb9ec3 100644 --- a/sql/remove.go +++ b/sql/remove.go @@ -17,7 +17,7 @@ package sql func (p *parser) parseRemoveStatement() (Statement, error) { // Inspect the next token. - tok, _, err := p.shouldBe(NAMESPACE, DATABASE, LOGIN, TOKEN, SCOPE, TABLE, FIELD, INDEX, VIEW) + tok, _, err := p.shouldBe(NAMESPACE, DATABASE, LOGIN, TOKEN, SCOPE, TABLE, EVENT, FIELD, INDEX) switch tok { case NAMESPACE: @@ -32,12 +32,12 @@ func (p *parser) parseRemoveStatement() (Statement, error) { return p.parseRemoveScopeStatement() case TABLE: return p.parseRemoveTableStatement() + case EVENT: + return p.parseRemoveEventStatement() case FIELD: return p.parseRemoveFieldStatement() case INDEX: return p.parseRemoveIndexStatement() - case VIEW: - return p.parseRemoveViewStatement() default: return nil, err } diff --git a/sql/return.go b/sql/return.go index b41658be..b7046912 100644 --- a/sql/return.go +++ b/sql/return.go @@ -26,17 +26,16 @@ func (p *parser) parseReturnStatement() (stmt *ReturnStatement, err error) { // including a parenthesised expression or a // binary expression so handle accordingly. - stmt.What, err = p.parseExpr() + stmt.What, err = p.parseWhat() if err != nil { return nil, err } - // Check that we have reached the end of the - // statement with either a ';' or EOF. + // If this query has any subqueries which + // need to alter the database then mark + // this query as a writeable statement. - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } + stmt.RW = p.buf.rw return diff --git a/sql/scanner.go b/sql/scanner.go index b516670c..9ad3e5af 100644 --- a/sql/scanner.go +++ b/sql/scanner.go @@ -17,7 +17,6 @@ package sql import ( "bufio" "bytes" - "fmt" "io" "regexp" "strconv" @@ -51,7 +50,7 @@ func (s *scanner) scan() (tok Token, lit string, val interface{}) { // If we see a letter then consume as a string. if isLetter(ch) { - return s.scanIdent(ch) + return s.scanIdiom(ch) } // If we see a number then consume as a number. @@ -351,7 +350,11 @@ func (s *scanner) scanCommentMultiple(chp ...rune) (tok Token, lit string, val i func (s *scanner) scanParams(chp ...rune) (tok Token, lit string, val interface{}) { - tok, lit, _ = s.scanIdent() + tok, lit, _ = s.scanIdiom() + + if s.p.is(tok, THING) { + return ILLEGAL, lit, val + } if s.p.is(tok, REGION) { return ILLEGAL, lit, val @@ -367,6 +370,49 @@ func (s *scanner) scanParams(chp ...rune) (tok Token, lit string, val interface{ func (s *scanner) scanQuoted(chp ...rune) (tok Token, lit string, val interface{}) { + var tbv string + var idv interface{} + + // Create a buffer + var buf bytes.Buffer + + tok, lit, _ = s.scanString(chp...) + + if s.p.is(tok, REGION) { + return ILLEGAL, lit, val + } + + if s.p.is(tok, ILLEGAL) { + return ILLEGAL, lit, val + } + + if ch := s.next(); ch == ':' { + + tbv = lit + + buf.WriteString(lit) + + buf.WriteRune(ch) + + if tok, lit, idv = s.part(); tok == ILLEGAL { + buf.WriteString(lit) + return ILLEGAL, buf.String(), val + } else { + buf.WriteString(lit) + } + + return THING, buf.String(), NewThing(tbv, idv) + + } else if ch != eof { + s.undo() + } + + return IDENT, lit, val + +} + +func (s *scanner) scanSection(chp ...rune) (tok Token, lit string, val interface{}) { + tok, lit, _ = s.scanString(chp...) if s.p.is(tok, REGION) { @@ -394,6 +440,48 @@ func (s *scanner) scanIdent(chp ...rune) (tok Token, lit string, val interface{} buf.WriteRune(ch) } + // Read subsequent characters + for { + if ch := s.next(); ch == eof { + break + } else if isIdentChar(ch) { + buf.WriteRune(ch) + } else { + s.undo() + break + } + } + + // If the string matches a keyword then return that keyword. + if tok := keywords[strings.ToUpper(buf.String())]; tok > 0 { + return tok, buf.String(), val + } + + if val, err := time.ParseDuration(buf.String()); err == nil { + return DURATION, buf.String(), val + } + + // Otherwise return as a regular identifier. + return tok, buf.String(), val + +} + +// scanIdiom consumes the current rune and all contiguous ident runes. +func (s *scanner) scanIdiom(chp ...rune) (tok Token, lit string, val interface{}) { + + tok = IDENT + + var tbv string + var idv interface{} + + // Create a buffer + var buf bytes.Buffer + + // Read passed in runes + for _, ch := range chp { + buf.WriteRune(ch) + } + // Read subsequent characters for { if ch := s.next(); ch == eof { @@ -403,6 +491,26 @@ func (s *scanner) scanIdent(chp ...rune) (tok Token, lit string, val interface{} } else if isExprsChar(ch) { tok = EXPR buf.WriteRune(ch) + } else if ch == ':' { + + if tok == EXPR { + s.undo() + break + } + + tbv = buf.String() + + buf.WriteRune(ch) + + if tok, lit, idv = s.part(); tok == ILLEGAL { + buf.WriteString(lit) + return ILLEGAL, buf.String(), val + } else { + buf.WriteString(lit) + } + + return THING, buf.String(), NewThing(tbv, idv) + } else { s.undo() break @@ -640,6 +748,16 @@ func (s *scanner) scanNumber(chp ...rune) (tok Token, lit string, val interface{ tok = IDENT buf.WriteRune(ch) switch ch { + case 'e', 'E': + if chn := s.next(); chn == '+' { + tok = DOUBLE + buf.WriteRune(chn) + } else if ch == '-' { + tok = DOUBLE + buf.WriteRune(chn) + } else { + s.undo() + } case 's', 'h', 'd', 'w': tok = DURATION case 'n', 'u', 'µ', 'm': @@ -692,10 +810,6 @@ func (s *scanner) scanString(chp ...rune) (tok Token, lit string, val interface{ end = '⟩' } - if beg == '{' { - end = '}' - } - tok = STRING // Create a buffer @@ -744,14 +858,6 @@ func (s *scanner) scanString(chp ...rune) (tok Token, lit string, val interface{ return TIME, buf.String(), val.UTC() } - if val, err := time.Parse(RFCNorm, buf.String()); err == nil { - return TIME, buf.String(), val.UTC() - } - - if val, err := time.Parse(RFCText, buf.String()); err == nil { - return TIME, buf.String(), val.UTC() - } - return tok, buf.String(), val } @@ -850,6 +956,10 @@ func (s *scanner) scanObject(chp ...rune) (tok Token, lit string, val interface{ } +func (s *scanner) scanPart() { + +} + func (s *scanner) part() (tok Token, lit string, val interface{}) { if ch := s.next(); isLetter(ch) { @@ -857,33 +967,15 @@ func (s *scanner) part() (tok Token, lit string, val interface{}) { } else if isNumber(ch) { tok, lit, _ = s.scanNumber(ch) } else if ch == '`' { - tok, lit, _ = s.scanQuoted(ch) - } else if ch == '{' { - tok, lit, _ = s.scanQuoted(ch) + tok, lit, _ = s.scanSection(ch) } else if ch == '⟨' { - tok, lit, _ = s.scanQuoted(ch) - } else if ch == '$' { - tok, lit, _ = s.scanParams(ch) - if p, ok := s.p.v[lit]; ok { - switch v := p.(type) { - case bool, int64, float64, string: - val, lit = v, fmt.Sprint(v) - case *Ident: - lit = v.ID - case *Value: - lit = v.ID - default: - tok = ILLEGAL - } - } else { - tok = ILLEGAL - } + tok, lit, _ = s.scanSection(ch) } else { s.undo() tok = ILLEGAL } - if tok != IDENT && tok != PARAM && tok != NUMBER && tok != DOUBLE { + if tok != IDENT && tok != NUMBER && tok != DOUBLE { tok = ILLEGAL } diff --git a/sql/scope.go b/sql/scope.go index 010ce149..01f0c945 100644 --- a/sql/scope.go +++ b/sql/scope.go @@ -16,7 +16,7 @@ package sql func (p *parser) parseDefineScopeStatement() (stmt *DefineScopeStatement, err error) { - stmt = &DefineScopeStatement{} + stmt = &DefineScopeStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { return nil, err @@ -28,7 +28,7 @@ func (p *parser) parseDefineScopeStatement() (stmt *DefineScopeStatement, err er for { - tok, _, exi := p.mightBe(SESSION, SIGNUP, SIGNIN) + tok, _, exi := p.mightBe(SESSION, SIGNUP, SIGNIN, CONNECT) if !exi { break } @@ -53,10 +53,13 @@ func (p *parser) parseDefineScopeStatement() (stmt *DefineScopeStatement, err er } } - } + if p.is(tok, CONNECT) { + _, _, _ = p.mightBe(AS) + if stmt.Connect, err = p.parseExpr(); err != nil { + return nil, err + } + } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err } return @@ -65,7 +68,7 @@ func (p *parser) parseDefineScopeStatement() (stmt *DefineScopeStatement, err er func (p *parser) parseRemoveScopeStatement() (stmt *RemoveScopeStatement, err error) { - stmt = &RemoveScopeStatement{} + stmt = &RemoveScopeStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { return nil, err @@ -75,10 +78,6 @@ func (p *parser) parseRemoveScopeStatement() (stmt *RemoveScopeStatement, err er return nil, err } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/select.go b/sql/select.go index 4d597eb9..56cc2e9a 100644 --- a/sql/select.go +++ b/sql/select.go @@ -18,7 +18,7 @@ func (p *parser) parseSelectStatement() (stmt *SelectStatement, err error) { stmt = &SelectStatement{} - if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthSC); err != nil { + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil { return nil, err } @@ -63,19 +63,22 @@ func (p *parser) parseSelectStatement() (stmt *SelectStatement, err error) { return nil, err } - if _, _, err = p.shouldBe(EOF, RPAREN, SEMICOLON); err != nil { + if err = checkExpression(aggrs, stmt.Expr, stmt.Group); err != nil { return nil, err } - return stmt, nil + // If this query has any subqueries which + // need to alter the database then mark + // this query as a writeable statement. + + stmt.RW = p.buf.rw + + return } func (p *parser) parseFields() (mul Fields, err error) { - var lit string - var exi bool - for { one := &Field{} @@ -89,10 +92,25 @@ func (p *parser) parseFields() (mul Fields, err error) { // clause, and if it is read the defined // field alias name from the scanner. - if _, _, exi = p.mightBe(AS); exi { + if _, _, exi := p.mightBe(AS); exi { - if one.Alias, err = p.parseIdent(); err != nil { - return nil, &ParseError{Found: lit, Expected: []string{"alias name"}} + if _, one.Alias, err = p.shouldBe(IDENT); err != nil { + return nil, &ParseError{Found: one.Alias, Expected: []string{"alias name"}} + } + + one.Field = one.Alias + + } else { + + switch v := one.Expr.(type) { + case *Param: + one.Field = v.ID + case *Value: + one.Field = v.ID + case *Ident: + one.Field = v.ID + default: + one.Field = one.String() } } @@ -106,7 +124,7 @@ func (p *parser) parseFields() (mul Fields, err error) { // and if not, then break out of the loop, // otherwise repeat until we find no comma. - if _, _, exi = p.mightBe(COMMA); !exi { + if _, _, exi := p.mightBe(COMMA); !exi { break } @@ -116,20 +134,6 @@ func (p *parser) parseFields() (mul Fields, err error) { } -func (p *parser) parseWhere() (exp Expr, err error) { - - // The next token that we expect to see is a - // WHERE token, and if we don't find one then - // return nil, with no error. - - if _, _, exi := p.mightBe(WHERE); !exi { - return nil, nil - } - - return p.parseExpr() - -} - func (p *parser) parseGroup() (mul Groups, err error) { // The next token that we expect to see is a @@ -153,7 +157,7 @@ func (p *parser) parseGroup() (mul Groups, err error) { one := &Group{} - tok, lit, err = p.shouldBe(IDENT, ID) + tok, lit, err = p.shouldBe(IDENT, EXPR) if err != nil { return nil, &ParseError{Found: lit, Expected: []string{"field name"}} } @@ -206,23 +210,38 @@ func (p *parser) parseOrder() (mul Orders, err error) { one := &Order{} - tok, lit, err = p.shouldBe(IDENT, ID) + tok, lit, err = p.shouldBe(IDENT, EXPR, RAND) if err != nil { return nil, &ParseError{Found: lit, Expected: []string{"field name"}} } - one.Expr, err = p.declare(tok, lit) - if err != nil { - return nil, err + switch tok { + default: + one.Expr, err = p.declare(tok, lit) + if err != nil { + return nil, err + } + case RAND: + one.Expr = &FuncExpression{Name: "rand"} + if _, _, exi = p.mightBe(LPAREN); exi { + _, _, err = p.shouldBe(RPAREN) + if err != nil { + return nil, err + } + } } - if tok, lit, exi = p.mightBe(ASC, DESC); !exi { - tok = ASC + if _, _, exi = p.mightBe(COLLATE); exi { + one.Tag, err = p.parseLanguage() + if err != nil { + return nil, err + } } - one.Dir, err = p.declare(tok, lit) - if err != nil { - return nil, err + if tok, _, exi = p.mightBe(ASC, DESC); exi { + one.Dir = (tok == ASC) + } else { + one.Dir = true } // Append the single expression to the array @@ -302,7 +321,7 @@ func (p *parser) parseVersion() (Expr, error) { tok, lit, err := p.shouldBe(DATE, TIME, PARAM) if err != nil { - return nil, &ParseError{Found: lit, Expected: []string{"timestamp"}} + return nil, &ParseError{Found: lit, Expected: []string{"version date or time"}} } return p.declare(tok, lit) diff --git a/sql/sql.go b/sql/sql.go index 358bea94..efbaab06 100644 --- a/sql/sql.go +++ b/sql/sql.go @@ -30,3 +30,22 @@ const ( // Parsing format for readable text format date times RFCText = "2006-01-02 15:04:05.999999999 -0700 MST" ) + +var ( + allowedTypes = []string{ + "array", "boolean", "circle", + "color", "datetime", "domain", + "double", "email", "latitude", + "longitude", "number", "object", + "password", "phone", "point", + "polygon", "record", "string", + "url", "uuid", + } + + allowedAlgorithms = []string{ + "ES256", "ES384", "ES512", + "HS256", "HS384", "HS512", + "PS256", "PS384", "PS512", + "RS256", "RS384", "RS512", + } +) diff --git a/sql/sql_test.go b/sql/sql_test.go index 4f21c855..66177b32 100644 --- a/sql/sql_test.go +++ b/sql/sql_test.go @@ -15,6 +15,7 @@ package sql import ( + "fmt" "testing" "time" @@ -27,6 +28,7 @@ type tester struct { skip bool sql string err string + str string res Statement } @@ -39,6 +41,8 @@ func testerr(err error) string { var c *fibre.Context +type Selfer interface{} + func testsql(t *testing.T, test tester) { if test.skip { @@ -46,21 +50,26 @@ func testsql(t *testing.T, test tester) { return } - s, e := Parse(c, test.sql, nil) + s, e := Parse(c, test.sql) Convey(test.sql, t, func() { - if test.err == "" { - So(e, ShouldBeNil) - So(s, ShouldResemble, test.res) - } - if test.err != "" { Convey(testerr(e), func() { So(testerr(e), ShouldResemble, test.err) }) } + if test.err == "" { + So(e, ShouldBeNil) + So(s, ShouldResemble, test.res) + if test.str != "" { + So(fmt.Sprint(test.res.(*Query).Statements[0]), ShouldEqual, test.str) + } else { + So(fmt.Sprint(test.res.(*Query).Statements[0]), ShouldEqual, test.sql) + } + } + }) } @@ -68,6 +77,7 @@ func testsql(t *testing.T, test tester) { func TestMain(t *testing.T) { cnf.Settings = &cnf.Options{} + cnf.Settings.DB.Path = "memory" cnf.Settings.DB.Base = "*" auth := &cnf.Auth{} @@ -83,15 +93,15 @@ func TestMain(t *testing.T) { var tests = []tester{ { sql: `USE`, - err: "Found `` but expected `NAMESPACE, NS, DATABASE, DB`", + err: "Found `` but expected `NAMESPACE, DATABASE, NS, DB`", }, { sql: `USE NAMESPACE`, - err: "Found `` but expected `name`", + err: "Found `` but expected `IDENT, STRING, NUMBER, DOUBLE, DATE, TIME`", }, { sql: `USE NAMESPACE ''`, - err: "Found `` but expected `name`", + err: "Found `` but expected `namespace name`", }, { sql: `USE NAMESPACE name`, @@ -101,11 +111,15 @@ func TestMain(t *testing.T) { }, { sql: `USE NAMESPACE 1`, - err: "Found `1` but expected `name`", + res: &Query{Statements: []Statement{&UseStatement{ + NS: "1", + }}}, }, { sql: `USE NAMESPACE 1.3000`, - err: "Found `1.3000` but expected `name`", + res: &Query{Statements: []Statement{&UseStatement{ + NS: "1.3000", + }}}, }, { sql: `USE NAMESPACE 123.123.123.123`, @@ -115,19 +129,19 @@ func TestMain(t *testing.T) { }, { sql: `USE NAMESPACE {"some":"thing"}`, - err: "Found `{\"some\":\"thing\"}` but expected `name`", + err: "Found `{\"some\":\"thing\"}` but expected `IDENT, STRING, NUMBER, DOUBLE, DATE, TIME`", }, { sql: `USE NAMESPACE name something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, { sql: `USE DATABASE`, - err: "Found `` but expected `name`", + err: "Found `` but expected `IDENT, STRING, NUMBER, DOUBLE, DATE, TIME`", }, { sql: `USE DATABASE ''`, - err: "Found `` but expected `name`", + err: "Found `` but expected `database name`", }, { sql: `USE DATABASE name`, @@ -137,11 +151,15 @@ func TestMain(t *testing.T) { }, { sql: `USE DATABASE 1`, - err: "Found `1` but expected `name`", + res: &Query{Statements: []Statement{&UseStatement{ + DB: "1", + }}}, }, { sql: `USE DATABASE 1.3000`, - err: "Found `1.3000` but expected `name`", + res: &Query{Statements: []Statement{&UseStatement{ + DB: "1.3000", + }}}, }, { sql: `USE DATABASE 123.123.123.123`, @@ -150,12 +168,24 @@ func TestMain(t *testing.T) { }}}, }, { - sql: `USE DATABASE {"some":"thing"}`, - err: "Found `{\"some\":\"thing\"}` but expected `name`", + sql: `USE DATABASE {}`, + err: "Found `{}` but expected `IDENT, STRING, NUMBER, DOUBLE, DATE, TIME`", }, { sql: `USE DATABASE name something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", + }, + { + sql: `BEGIN; USE NS name DB name; COMMIT;`, + err: "You can't change NAMESPACE or DATABASE inside of a transaction", + }, + { + sql: "USE NS `*` DB `*`", + str: "USE NAMESPACE `*` DATABASE `*`", + res: &Query{Statements: []Statement{&UseStatement{ + NS: "*", + DB: "*", + }}}, }, { sql: "USE NAMESPACE `*` DATABASE `*`", @@ -176,7 +206,7 @@ func TestMain(t *testing.T) { func Test_Parse_General(t *testing.T) { s := `SELECT a FROM b` - q, err := Parse(c, s, nil) + q, err := Parse(c, s) if err != nil { t.Fatalf("unexpected error: %s", err) @@ -190,7 +220,7 @@ func Test_Parse_General(t *testing.T) { func Test_Parse_General_Single(t *testing.T) { s := `SELECT a FROM b` - q, err := Parse(c, s, nil) + q, err := Parse(c, s) if err != nil { t.Fatalf("unexpected error: %s", err) @@ -204,7 +234,7 @@ func Test_Parse_General_Single(t *testing.T) { func Test_Parse_General_Multi(t *testing.T) { s := `SELECT a FROM b; SELECT c FROM d` - q, err := Parse(c, s, nil) + q, err := Parse(c, s) if err != nil { t.Fatalf("unexpected error: %s", err) @@ -239,11 +269,56 @@ func Test_Parse_Queries_Malformed(t *testing.T) { }, { sql: `!`, - err: "Found `!` but expected `USE, INFO, BEGIN, CANCEL, COMMIT, LET, RETURN, SELECT, CREATE, UPDATE, DELETE, RELATE, DEFINE, REMOVE`", + err: "Found `!` but expected `USE, INFO, BEGIN, CANCEL, COMMIT, IF, LET, RETURN, LIVE, KILL, SELECT, CREATE, UPDATE, DELETE, RELATE, INSERT, UPSERT, DEFINE, REMOVE`", + }, + } + + for _, test := range tests { + testsql(t, test) + } + +} + +func Test_Parse_Queries_Info(t *testing.T) { + + var tests = []tester{ + { + sql: `INFO`, + err: "Found `` but expected `FOR`", }, { - sql: `SELECT * FROM person;;;`, - err: "Found `;` but expected `USE, INFO, BEGIN, CANCEL, COMMIT, LET, RETURN, SELECT, CREATE, UPDATE, DELETE, RELATE, DEFINE, REMOVE`", + sql: `INFO FOR`, + err: "Found `` but expected `NAMESPACE, DATABASE, TABLE`", + }, + { + sql: `INFO FOR NAMESPACE`, + res: &Query{Statements: []Statement{&InfoStatement{ + RW: false, KV: "*", NS: "*", DB: "*", + Kind: NAMESPACE, + }}}, + }, + { + sql: `INFO FOR DATABASE`, + res: &Query{Statements: []Statement{&InfoStatement{ + RW: false, KV: "*", NS: "*", DB: "*", + Kind: DATABASE, + }}}, + }, + { + sql: `INFO FOR TABLE`, + err: "Found `` but expected `table`", + }, + { + sql: `INFO FOR TABLE test`, + res: &Query{Statements: []Statement{&InfoStatement{ + RW: false, KV: "*", NS: "*", DB: "*", + Kind: TABLE, + What: &Table{"test"}, + }}}, + }, + { + sql: `INFO FOR TABLE test something`, + err: "Found `something` but expected `;`", }, } @@ -271,7 +346,7 @@ func Test_Parse_Queries_Let(t *testing.T) { { sql: `LET name = true`, res: &Query{Statements: []Statement{&LetStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Name: &Ident{"name"}, What: true, }}}, @@ -279,7 +354,7 @@ func Test_Parse_Queries_Let(t *testing.T) { { sql: `LET name = false`, res: &Query{Statements: []Statement{&LetStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Name: &Ident{"name"}, What: false, }}}, @@ -287,7 +362,7 @@ func Test_Parse_Queries_Let(t *testing.T) { { sql: `LET name = "test"`, res: &Query{Statements: []Statement{&LetStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Name: &Ident{"name"}, What: &Value{"test"}, }}}, @@ -295,15 +370,16 @@ func Test_Parse_Queries_Let(t *testing.T) { { sql: `LET name = 1`, res: &Query{Statements: []Statement{&LetStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Name: &Ident{"name"}, - What: int64(1), + What: float64(1), }}}, }, { sql: `LET name = 1.0`, + str: `LET name = 1`, res: &Query{Statements: []Statement{&LetStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Name: &Ident{"name"}, What: float64(1), }}}, @@ -311,50 +387,77 @@ func Test_Parse_Queries_Let(t *testing.T) { { sql: `LET name = 1.1`, res: &Query{Statements: []Statement{&LetStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Name: &Ident{"name"}, What: float64(1.1), }}}, }, { - sql: `LET name = @thing:test`, + sql: `LET name = thing:test`, res: &Query{Statements: []Statement{&LetStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", + Name: &Ident{"name"}, + What: &Thing{TB: "thing", ID: "test"}, + }}}, + }, + { + sql: `LET name = thing:test`, + res: &Query{Statements: []Statement{&LetStatement{ + RW: false, KV: "*", NS: "*", DB: "*", + Name: &Ident{"name"}, + What: &Thing{TB: "thing", ID: "test"}, + }}}, + }, + { + sql: `LET name = @thing:test`, + str: `LET name = thing:test`, + res: &Query{Statements: []Statement{&LetStatement{ + RW: false, KV: "*", NS: "*", DB: "*", Name: &Ident{"name"}, What: &Thing{TB: "thing", ID: "test"}, }}}, }, { sql: `LET name = {"key": "val"}`, + str: `LET name = {"key":"val"}`, res: &Query{Statements: []Statement{&LetStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Name: &Ident{"name"}, - What: Object{"key": "val"}, + What: map[string]interface{}{"key": "val"}, }}}, }, { sql: `LET name = ["key", "val"]`, + str: `LET name = ["key","val"]`, res: &Query{Statements: []Statement{&LetStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Name: &Ident{"name"}, - What: Array{"key", "val"}, + What: []interface{}{"key", "val"}, }}}, }, { sql: `LET name = $test`, res: &Query{Statements: []Statement{&LetStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Name: &Ident{"name"}, What: &Param{ID: "test"}, }}}, }, { - sql: `LET name = {"key"::"val"}`, - err: "Invalid JSON: {\"key\"::\"val\"}", + sql: `LET name = (CREATE person)`, + res: &Query{Statements: []Statement{&LetStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"name"}, + What: &SubExpression{Expr: &CreateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Exprs{&Ident{ID: "person"}}, + Echo: AFTER, + }}, + }}}, }, { sql: `LET name = "test" something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, } @@ -374,87 +477,98 @@ func Test_Parse_Queries_Return(t *testing.T) { { sql: `RETURN true`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: true, + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{true}, }}}, }, { sql: `RETURN true`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: true, + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{true}, }}}, }, { sql: `RETURN false`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: false, + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{false}, }}}, }, { sql: `RETURN "test"`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: &Value{"test"}, + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{&Value{"test"}}, }}}, }, { sql: `RETURN 1`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: int64(1), + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{float64(1)}, }}}, }, { sql: `RETURN 1.0`, + str: `RETURN 1`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: float64(1), + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{float64(1)}, }}}, }, { sql: `RETURN 1.1`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: float64(1.1), + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{float64(1.1)}, }}}, }, { sql: `RETURN @thing:test`, + str: `RETURN thing:test`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: &Thing{TB: "thing", ID: "test"}, + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{&Thing{TB: "thing", ID: "test"}}, }}}, }, { sql: `RETURN {"key": "val"}`, + str: `RETURN {"key":"val"}`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: Object{"key": "val"}, + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{map[string]interface{}{"key": "val"}}, }}}, }, { sql: `RETURN ["key", "val"]`, + str: `RETURN ["key","val"]`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: Array{"key", "val"}, + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{[]interface{}{"key", "val"}}, }}}, }, { sql: `RETURN $test`, res: &Query{Statements: []Statement{&ReturnStatement{ - KV: "*", NS: "*", DB: "*", - What: &Param{ID: "test"}, + RW: false, KV: "*", NS: "*", DB: "*", + What: Exprs{&Param{ID: "test"}}, }}}, }, { - sql: `RETURN {"key"::"val"}`, - err: "Invalid JSON: {\"key\"::\"val\"}", + sql: `RETURN (CREATE person)`, + res: &Query{Statements: []Statement{&ReturnStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Exprs{&SubExpression{Expr: &CreateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Exprs{&Ident{ID: "person"}}, + Echo: AFTER, + }}}, + }}}, }, { sql: `RETURN $test something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, } @@ -484,376 +598,288 @@ func Test_Parse_Queries_Select(t *testing.T) { }, { sql: `SELECT * FROM`, - err: "Found `` but expected `table, or thing`", + err: "Found `` but expected `expression`", }, { sql: `SELECT * FROM per!son`, - err: "Found `!` but expected `EOF, ), ;`", + err: "Found `!` but expected `;`", }, { - sql: `SELECT * FROM person;`, + sql: `SELECT * FROM person`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, }}}, }, { sql: `SELECT * FROM @`, - err: "Found `@` but expected `table, or thing`", + err: "Found `@` but expected `expression`", }, { sql: `SELECT * FROM @person`, - err: "Found `@person` but expected `table, or thing`", + err: "Found `@person` but expected `expression`", }, { sql: `SELECT * FROM @person:`, - err: "Found `@person:` but expected `table, or thing`", + err: "Found `@person:` but expected `expression`", }, { sql: `SELECT * FROM @person WHERE`, - err: "Found `@person` but expected `table, or thing`", - }, - { - sql: `SELECT * FROM person:uuid`, - err: "Found `:` but expected `EOF, ), ;`", + err: "Found `@person` but expected `expression`", }, { sql: "SELECT * FROM 111", - err: "Found `111` but expected `table, or thing`", + res: &Query{Statements: []Statement{&SelectStatement{ + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{float64(111)}, + }}}, }, { sql: "SELECT * FROM `111`", + str: "SELECT * FROM 111", res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"111"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"111"}}, }}}, }, { sql: "SELECT * FROM `2006-01-02`", res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"2006-01-02"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"2006-01-02"}}, }}}, }, { sql: "SELECT * FROM `2006-01-02T15:04:05+07:00`", res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"2006-01-02T15:04:05+07:00"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"2006-01-02T15:04:05+07:00"}}, }}}, }, { sql: "SELECT * FROM `2006-01-02T15:04:05.999999999+07:00`", res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"2006-01-02T15:04:05.999999999+07:00"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"2006-01-02T15:04:05.999999999+07:00"}}, }}}, }, { sql: `SELECT * FROM person`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, }}}, }, { sql: `SELECT * FROM person, tweet`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}, &Table{"tweet"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}, &Ident{"tweet"}}, }}}, }, { - sql: `SELECT * FROM @111:1a`, + sql: `SELECT * FROM person:1a`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "111", ID: "1a"}}, - }}}, - }, - { - sql: `SELECT * FROM @person:1a`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: "1a"}}, }}}, }, { - sql: `SELECT * FROM @person:⟨1a⟩`, + sql: `SELECT * FROM person:⟨1a⟩`, + str: `SELECT * FROM person:1a`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: "1a"}}, }}}, }, { - sql: `SELECT * FROM @person:{1a}`, + sql: `SELECT * FROM person:123456`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: "1a"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Thing{TB: "person", ID: float64(123456)}}, }}}, }, { - sql: `SELECT * FROM @person:123456`, + sql: `SELECT * FROM person:⟨123456⟩`, + str: `SELECT * FROM person:123456`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: int64(123456)}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Thing{TB: "person", ID: float64(123456)}}, }}}, }, { - sql: `SELECT * FROM @person:⟨123456⟩`, + sql: `SELECT * FROM person:123.456`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: int64(123456)}}, - }}}, - }, - { - sql: `SELECT * FROM @person:{123456}`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: int64(123456)}}, - }}}, - }, - { - sql: `SELECT * FROM @person:123.456`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: float64(123.456)}}, }}}, }, { - sql: `SELECT * FROM @person:⟨123.456⟩`, + sql: `SELECT * FROM person:⟨123.456⟩`, + str: `SELECT * FROM person:123.456`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: float64(123.456)}}, }}}, }, { - sql: `SELECT * FROM @person:{123.456}`, + sql: `SELECT * FROM person:123.456.789.012`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: float64(123.456)}}, - }}}, - }, - { - sql: `SELECT * FROM @person:123.456.789.012`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: "123.456.789.012"}}, }}}, }, { - sql: `SELECT * FROM @person:⟨123.456.789.012⟩`, + sql: `SELECT * FROM person:⟨123.456.789.012⟩`, + str: `SELECT * FROM person:123.456.789.012`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: "123.456.789.012"}}, }}}, }, { - sql: `SELECT * FROM @person:{123.456.789.012}`, + sql: `SELECT * FROM person:⟨1987-06-22⟩`, + str: `SELECT * FROM person:⟨1987-06-22T00:00:00Z⟩`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: "123.456.789.012"}}, - }}}, - }, - { - sql: `SELECT * FROM @person:⟨1987-06-22⟩`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: date}}, }}}, }, { - sql: `SELECT * FROM @person:{1987-06-22}`, + sql: `SELECT * FROM person:⟨1987-06-22T08:30:30.511Z⟩`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: date}}, - }}}, - }, - { - sql: `SELECT * FROM @person:⟨1987-06-22T08:30:30.511Z⟩`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: nano}}, }}}, }, { - sql: `SELECT * FROM @person:{1987-06-22T08:30:30.511Z}`, + sql: `SELECT * FROM person:⟨A250C5A3-948F-4657-88AD-FF5F27B5B24E⟩`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: nano}}, - }}}, - }, - { - sql: `SELECT * FROM @person:⟨A250C5A3-948F-4657-88AD-FF5F27B5B24E⟩`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: "A250C5A3-948F-4657-88AD-FF5F27B5B24E"}}, }}}, }, { - sql: `SELECT * FROM @person:{A250C5A3-948F-4657-88AD-FF5F27B5B24E}`, + sql: `SELECT * FROM person:⟨8250C5A3-948F-4657-88AD-FF5F27B5B24E⟩`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: "A250C5A3-948F-4657-88AD-FF5F27B5B24E"}}, - }}}, - }, - { - sql: `SELECT * FROM @person:⟨8250C5A3-948F-4657-88AD-FF5F27B5B24E⟩`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: "8250C5A3-948F-4657-88AD-FF5F27B5B24E"}}, }}}, }, { - sql: `SELECT * FROM @person:{8250C5A3-948F-4657-88AD-FF5F27B5B24E}`, + sql: `SELECT * FROM person:⟨Tobie Morgan Hitchcock⟩`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: "8250C5A3-948F-4657-88AD-FF5F27B5B24E"}}, - }}}, - }, - { - sql: `SELECT * FROM @person:⟨Tobie Morgan Hitchcock⟩`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "person", ID: "Tobie Morgan Hitchcock"}}, }}}, }, { - sql: `SELECT * FROM @person:{Tobie Morgan Hitchcock}`, + sql: `SELECT * FROM ⟨email addresses⟩:⟨tobie@abcum.com⟩`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "person", ID: "Tobie Morgan Hitchcock"}}, - }}}, - }, - { - sql: `SELECT * FROM @⟨email addresses⟩:⟨tobie@abcum.com⟩`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "email addresses", ID: "tobie@abcum.com"}}, }}}, }, { - sql: `SELECT * FROM @{email addresses}:{tobie@abcum.com}`, + sql: `SELECT * FROM ⟨email addresses⟩:⟨tobie+spam@abcum.com⟩`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "email addresses", ID: "tobie@abcum.com"}}, - }}}, - }, - { - sql: `SELECT * FROM @⟨email addresses⟩:⟨tobie+spam@abcum.com⟩`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, What: []Expr{&Thing{TB: "email addresses", ID: "tobie+spam@abcum.com"}}, }}}, }, - { - sql: `SELECT * FROM @{email addresses}:{tobie+spam@abcum.com}`, - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Thing{TB: "email addresses", ID: "tobie+spam@abcum.com"}}, - }}}, - }, - { - sql: `SELECT * FROM @{person}test:id`, - err: "Found `@person` but expected `table, or thing`", - }, - { - sql: `SELECT * FROM @⟨email addresses⟩:⟨this\qis\nodd⟩`, - err: "Found `@email addresses:thisqis\nodd` but expected `table, or thing`", - }, - { - sql: `SELECT * FROM @{email addresses}:{this\qis\nodd}`, - err: "Found `@email addresses:thisqis\nodd` but expected `table, or thing`", - }, { sql: `SELECT *, temp AS test FROM person`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Expr: []*Field{ - {Expr: &All{}}, - {Expr: &Ident{"temp"}, Alias: &Ident{"test"}}, + {Expr: &All{}, Field: "*"}, + {Expr: &Ident{"temp"}, Field: "test", Alias: "test"}, }, - What: []Expr{&Table{"person"}}, + What: []Expr{&Ident{"person"}}, }}}, }, { sql: "SELECT `email addresses` AS emails FROM person", res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Expr: []*Field{ - {Expr: &Ident{"email addresses"}, Alias: &Ident{"emails"}}, + {Expr: &Ident{"email addresses"}, Field: "emails", Alias: "emails"}, }, - What: []Expr{&Table{"person"}}, + What: []Expr{&Ident{"person"}}, }}}, }, { sql: "SELECT emails AS `email addresses` FROM person", res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", + RW: false, KV: "*", NS: "*", DB: "*", Expr: []*Field{ - {Expr: &Ident{"emails"}, Alias: &Ident{"email addresses"}}, + {Expr: &Ident{"emails"}, Field: "email addresses", Alias: "email addresses"}, }, - What: []Expr{&Table{"person"}}, + What: []Expr{&Ident{"person"}}, }}}, }, { - sql: "SELECT * FROM person WHERE id = '\x0A'", + sql: `SELECT * FROM (CREATE person)`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + Expr: []*Field{ + {Expr: &All{}, Field: "*"}, + }, + What: Exprs{&SubExpression{Expr: &CreateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Exprs{&Ident{ID: "person"}}, + Echo: AFTER, + }}}, + }}}, + }, + { + sql: "SELECT * FROM person WHERE id = \"\x0A\"", + res: &Query{Statements: []Statement{&SelectStatement{ + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"id"}, Op: EQ, RHS: &Value{"\n"}}, }}}, }, { - sql: "SELECT * FROM person WHERE id = '\x0D'", + sql: "SELECT * FROM person WHERE id = \"\x0D\"", res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"id"}, Op: EQ, RHS: &Value{"\r"}}, }}}, }, { - sql: `SELECT * FROM person WHERE id = "\b\n\r\t"`, + sql: "SELECT * FROM person WHERE id = \"\b\n\r\t\"", res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: &Ident{"id"}, Op: EQ, RHS: &Value{"\n\r\t"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + Cond: &BinaryExpression{LHS: &Ident{"id"}, Op: EQ, RHS: &Value{"\b\n\r\t"}}, }}}, }, { @@ -863,9 +889,9 @@ func Test_Parse_Queries_Select(t *testing.T) { { sql: `SELECT * FROM person WHERE id`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &Ident{"id"}, }}}, }, @@ -876,108 +902,114 @@ func Test_Parse_Queries_Select(t *testing.T) { { sql: `SELECT * FROM person WHERE id = 1`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: &Ident{"id"}, Op: EQ, RHS: int64(1)}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + Cond: &BinaryExpression{LHS: &Ident{"id"}, Op: EQ, RHS: float64(1)}, }}}, }, { sql: `SELECT * FROM person WHERE old = EMPTY`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"old"}, Op: EQ, RHS: &Empty{}}, }}}, }, { sql: `SELECT * FROM person WHERE old != EMPTY`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"old"}, Op: NEQ, RHS: &Empty{}}, }}}, }, { sql: `SELECT * FROM person WHERE old = MISSING`, + str: `SELECT * FROM person WHERE old = VOID`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"old"}, Op: EQ, RHS: &Void{}}, }}}, }, { sql: `SELECT * FROM person WHERE old != MISSING`, + str: `SELECT * FROM person WHERE old != VOID`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"old"}, Op: NEQ, RHS: &Void{}}, }}}, }, { sql: `SELECT * FROM person WHERE old IS EMPTY`, + str: `SELECT * FROM person WHERE old = EMPTY`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"old"}, Op: EQ, RHS: &Empty{}}, }}}, }, { sql: `SELECT * FROM person WHERE old IS NOT EMPTY`, + str: `SELECT * FROM person WHERE old != EMPTY`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"old"}, Op: NEQ, RHS: &Empty{}}, }}}, }, { sql: `SELECT * FROM person WHERE old IS MISSING`, + str: `SELECT * FROM person WHERE old = VOID`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"old"}, Op: EQ, RHS: &Void{}}, }}}, }, { sql: `SELECT * FROM person WHERE old IS NOT MISSING`, + str: `SELECT * FROM person WHERE old != VOID`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"old"}, Op: NEQ, RHS: &Void{}}, }}}, }, { sql: `SELECT * FROM person WHERE old = true`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"old"}, Op: EQ, RHS: true}, }}}, }, { sql: `SELECT * FROM person WHERE old = false`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{LHS: &Ident{"old"}, Op: EQ, RHS: false}, }}}, }, - { + /*{ sql: `SELECT * FROM person WHERE id != null AND id > 13.9 AND id < 31 AND id >= 15 AND id <= 29.9`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{ LHS: &BinaryExpression{ LHS: &BinaryExpression{ @@ -985,7 +1017,7 @@ func Test_Parse_Queries_Select(t *testing.T) { LHS: &BinaryExpression{ LHS: &Ident{ID: "id"}, Op: NEQ, - RHS: &Null{}, + RHS: nil, }, Op: AND, RHS: &BinaryExpression{ @@ -998,14 +1030,14 @@ func Test_Parse_Queries_Select(t *testing.T) { RHS: &BinaryExpression{ LHS: &Ident{ID: "id"}, Op: LT, - RHS: int64(31), + RHS: float64(31), }, }, Op: AND, RHS: &BinaryExpression{ LHS: &Ident{ID: "id"}, Op: GTE, - RHS: int64(15), + RHS: float64(15), }, }, Op: AND, @@ -1016,121 +1048,95 @@ func Test_Parse_Queries_Select(t *testing.T) { }, }, }}}, - }, - { - sql: `SELECT * FROM person WHERE test IN ["London":"Paris"]`, - err: `Invalid JSON: ["London":"Paris"]`, - }, + },*/ { sql: `SELECT * FROM person WHERE test IN ["London","Paris"]`, + str: `SELECT * FROM person WHERE test ∈ ["London","Paris"]`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: INS, RHS: Array{"London", "Paris"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: INS, RHS: []interface{}{"London", "Paris"}}, }}}, }, { sql: `SELECT * FROM person WHERE test IS IN ["London","Paris"]`, + str: `SELECT * FROM person WHERE test ∈ ["London","Paris"]`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: INS, RHS: Array{"London", "Paris"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: INS, RHS: []interface{}{"London", "Paris"}}, }}}, }, { sql: `SELECT * FROM person WHERE test IS NOT IN ["London","Paris"]`, + str: `SELECT * FROM person WHERE test ∉ ["London","Paris"]`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: NIS, RHS: Array{"London", "Paris"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: NIS, RHS: []interface{}{"London", "Paris"}}, }}}, }, { sql: `SELECT * FROM person WHERE ["London","Paris"] CONTAINS test`, + str: `SELECT * FROM person WHERE ["London","Paris"] ∋ test`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: Array{"London", "Paris"}, Op: SIN, RHS: &Ident{"test"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + Cond: &BinaryExpression{LHS: []interface{}{"London", "Paris"}, Op: SIN, RHS: &Ident{"test"}}, }}}, }, { sql: `SELECT * FROM person WHERE ["London","Paris"] CONTAINS NOT test`, + str: `SELECT * FROM person WHERE ["London","Paris"] ∌ test`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: Array{"London", "Paris"}, Op: SNI, RHS: &Ident{"test"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + Cond: &BinaryExpression{LHS: []interface{}{"London", "Paris"}, Op: SNI, RHS: &Ident{"test"}}, }}}, }, { sql: `SELECT * FROM person WHERE test = {`, err: "Found `{` but expected `expression`", }, - { - sql: `SELECT * FROM person WHERE test = {"name","London"}`, - err: `Invalid JSON: {"name","London"}`, - }, - { - sql: "SELECT * FROM person WHERE {\"name\":\"\x0A\"} = test", - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: Object{"name": "\n"}, Op: EQ, RHS: &Ident{"test"}}, - }}}, - }, - { - sql: "SELECT * FROM person WHERE test = {\"name\":\"\x0A\"}", - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: EQ, RHS: Object{"name": "\n"}}, - }}}, - }, - { - sql: "SELECT * FROM person WHERE test = {\"name\":\"\x0D\"}", - res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: EQ, RHS: Object{"name": "\r"}}, - }}}, - }, { sql: `SELECT * FROM person WHERE test = {"name":"London"}`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: EQ, RHS: Object{"name": "London"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: EQ, RHS: map[string]interface{}{"name": "London"}}, }}}, }, { - sql: `SELECT * FROM person WHERE test = {"name":"\b\t\r\n\f\"\\"}`, + sql: `SELECT * FROM person WHERE test = {"name":{"f":"first","l":"last"}}`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: EQ, RHS: Object{"name": "\b\t\r\n\f\"\\"}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: EQ, RHS: map[string]interface{}{"name": map[string]interface{}{"f": "first", "l": "last"}}}, }}}, }, { - sql: `SELECT * FROM person WHERE test = {"name":{"f":"first", "l":"last"}}`, + sql: `SELECT * FROM person TIMEOUT 1s`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, - Cond: &BinaryExpression{LHS: &Ident{"test"}, Op: EQ, RHS: Object{"name": map[string]interface{}{"f": "first", "l": "last"}}}, + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + Timeout: 1 * time.Second, }}}, }, + { + sql: `SELECT * FROM person TIMEOUT null`, + err: "Found `null` but expected `duration`", + }, } - bday1, _ := time.Parse("2006-01-02", "1987-06-22") + /*bday1, _ := time.Parse("2006-01-02", "1987-06-22") bday2, _ := time.Parse(time.RFC3339, "1987-06-22T08:00:00Z") bday3, _ := time.Parse(time.RFC3339, "1987-06-22T08:30:00.193943735Z") bday4, _ := time.Parse(time.RFC3339, "2016-03-14T11:19:31.193943735Z") @@ -1138,9 +1144,9 @@ func Test_Parse_Queries_Select(t *testing.T) { tests = append(tests, tester{ sql: `SELECT * FROM person WHERE bday >= "1987-06-22" AND bday >= "1987-06-22T08:00:00Z" AND bday >= "1987-06-22T08:30:00.193943735Z" AND bday <= "2016-03-14T11:19:31.193943735Z"`, res: &Query{Statements: []Statement{&SelectStatement{ - KV: "*", NS: "*", DB: "*", - Expr: []*Field{{Expr: &All{}}}, - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, Cond: &BinaryExpression{ LHS: &BinaryExpression{ LHS: &BinaryExpression{ @@ -1171,7 +1177,7 @@ func Test_Parse_Queries_Select(t *testing.T) { }, }, }}}, - }) + })*/ for _, test := range tests { testsql(t, test) @@ -1184,15 +1190,13 @@ func Test_Parse_Queries_Create(t *testing.T) { var tests = []tester{ { sql: `CREATE`, - err: "Found `` but expected `table, or thing`", + err: "Found `` but expected `expression`", }, { sql: `CREATE person`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{ - &Table{"person"}, - }, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: AFTER, }}}, }, @@ -1207,8 +1211,8 @@ func Test_Parse_Queries_Create(t *testing.T) { { sql: `CREATE person SET firstname = VOID`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Data: &DataExpression{Data: []*ItemExpression{{LHS: &Ident{"firstname"}, Op: EQ, RHS: &Void{}}}}, Echo: AFTER, }}}, @@ -1216,21 +1220,21 @@ func Test_Parse_Queries_Create(t *testing.T) { { sql: `CREATE person SET firstname = EMPTY`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Data: &DataExpression{Data: []*ItemExpression{{LHS: &Ident{"firstname"}, Op: EQ, RHS: &Empty{}}}}, Echo: AFTER, }}}, }, { sql: `CREATE person SET firstname = "Tobie" something`, - err: "Found `something` but expected `EOF, ), ;`", + err: "Found `something` but expected `;`", }, { sql: `CREATE person SET firstname = "Tobie"`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Data: &DataExpression{Data: []*ItemExpression{{LHS: &Ident{"firstname"}, Op: EQ, RHS: &Value{"Tobie"}}}}, Echo: AFTER, }}}, @@ -1245,14 +1249,14 @@ func Test_Parse_Queries_Create(t *testing.T) { }, { sql: `CREATE person MERGE {"firstname":"Tobie"} something`, - err: "Found `something` but expected `EOF, ), ;`", + err: "Found `something` but expected `;`", }, { sql: `CREATE person MERGE {"firstname":"Tobie"}`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, - Data: &MergeExpression{Data: Object{"firstname": "Tobie"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, + Data: &MergeExpression{Data: map[string]interface{}{"firstname": "Tobie"}}, Echo: AFTER, }}}, }, @@ -1266,68 +1270,78 @@ func Test_Parse_Queries_Create(t *testing.T) { }, { sql: `CREATE person CONTENT {"firstname":"Tobie"} something`, - err: "Found `something` but expected `EOF, ), ;`", + err: "Found `something` but expected `;`", }, { sql: `CREATE person CONTENT {"firstname":"Tobie"}`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, - Data: &ContentExpression{Data: Object{"firstname": "Tobie"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, + Data: &ContentExpression{Data: map[string]interface{}{"firstname": "Tobie"}}, Echo: AFTER, }}}, }, { - sql: `CREATE person RETURN ID`, - res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, - Echo: ID, - }}}, + sql: `CREATE person RETURN`, + err: "Found `` but expected `NONE, INFO, BOTH, DIFF, BEFORE, AFTER`", }, { sql: `CREATE person RETURN NONE`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: NONE, }}}, }, { sql: `CREATE person RETURN BOTH`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: BOTH, }}}, }, { sql: `CREATE person RETURN DIFF`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: DIFF, }}}, }, { sql: `CREATE person RETURN BEFORE`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: BEFORE, }}}, }, { sql: `CREATE person RETURN AFTER`, + str: `CREATE person`, res: &Query{Statements: []Statement{&CreateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: AFTER, }}}, }, { - sql: `CREATE person RETURN SOMETHING`, - err: "Found `SOMETHING` but expected `ID, NONE, INFO, BOTH, DIFF, BEFORE, AFTER`", + sql: `CREATE person TIMEOUT 1s`, + res: &Query{Statements: []Statement{&CreateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, + Echo: AFTER, + Timeout: 1 * time.Second, + }}}, + }, + { + sql: `CREATE person TIMEOUT null`, + err: "Found `null` but expected `duration`", + }, + { + sql: `CREATE person something`, + err: "Found `something` but expected `;`", }, } @@ -1342,15 +1356,13 @@ func Test_Parse_Queries_Update(t *testing.T) { var tests = []tester{ { sql: `UPDATE`, - err: "Found `` but expected `table, or thing`", + err: "Found `` but expected `expression`", }, { sql: `UPDATE person`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{ - &Table{"person"}, - }, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: AFTER, }}}, }, @@ -1365,8 +1377,8 @@ func Test_Parse_Queries_Update(t *testing.T) { { sql: `UPDATE person SET firstname = VOID`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Data: &DataExpression{Data: []*ItemExpression{{LHS: &Ident{"firstname"}, Op: EQ, RHS: &Void{}}}}, Echo: AFTER, }}}, @@ -1374,21 +1386,21 @@ func Test_Parse_Queries_Update(t *testing.T) { { sql: `UPDATE person SET firstname = EMPTY`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Data: &DataExpression{Data: []*ItemExpression{{LHS: &Ident{"firstname"}, Op: EQ, RHS: &Empty{}}}}, Echo: AFTER, }}}, }, { sql: `UPDATE person SET firstname = "Tobie" something`, - err: "Found `something` but expected `EOF, ), ;`", + err: "Found `something` but expected `;`", }, { sql: `UPDATE person SET firstname = "Tobie"`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Data: &DataExpression{Data: []*ItemExpression{{LHS: &Ident{"firstname"}, Op: EQ, RHS: &Value{"Tobie"}}}}, Echo: AFTER, }}}, @@ -1403,14 +1415,14 @@ func Test_Parse_Queries_Update(t *testing.T) { }, { sql: `UPDATE person DIFF [] something`, - err: "Found `something` but expected `EOF, ), ;`", + err: "Found `something` but expected `;`", }, { sql: `UPDATE person DIFF []`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, - Data: &DiffExpression{Data: Array{}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, + Data: &DiffExpression{Data: []interface{}{}}, Echo: AFTER, }}}, }, @@ -1424,14 +1436,14 @@ func Test_Parse_Queries_Update(t *testing.T) { }, { sql: `UPDATE person MERGE {"firstname":"Tobie"} something`, - err: "Found `something` but expected `EOF, ), ;`", + err: "Found `something` but expected `;`", }, { sql: `UPDATE person MERGE {"firstname":"Tobie"}`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, - Data: &MergeExpression{Data: Object{"firstname": "Tobie"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, + Data: &MergeExpression{Data: map[string]interface{}{"firstname": "Tobie"}}, Echo: AFTER, }}}, }, @@ -1445,68 +1457,78 @@ func Test_Parse_Queries_Update(t *testing.T) { }, { sql: `UPDATE person CONTENT {"firstname":"Tobie"} something`, - err: "Found `something` but expected `EOF, ), ;`", + err: "Found `something` but expected `;`", }, { sql: `UPDATE person CONTENT {"firstname":"Tobie"}`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, - Data: &ContentExpression{Data: Object{"firstname": "Tobie"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, + Data: &ContentExpression{Data: map[string]interface{}{"firstname": "Tobie"}}, Echo: AFTER, }}}, }, { - sql: `UPDATE person RETURN ID`, - res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, - Echo: ID, - }}}, + sql: `UPDATE person RETURN`, + err: "Found `` but expected `NONE, INFO, BOTH, DIFF, BEFORE, AFTER`", }, { sql: `UPDATE person RETURN NONE`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: NONE, }}}, }, { sql: `UPDATE person RETURN BOTH`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: BOTH, }}}, }, { sql: `UPDATE person RETURN DIFF`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: DIFF, }}}, }, { sql: `UPDATE person RETURN BEFORE`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: BEFORE, }}}, }, { sql: `UPDATE person RETURN AFTER`, + str: `UPDATE person`, res: &Query{Statements: []Statement{&UpdateStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: AFTER, }}}, }, { - sql: `UPDATE person RETURN SOMETHING`, - err: "Found `SOMETHING` but expected `ID, NONE, INFO, BOTH, DIFF, BEFORE, AFTER`", + sql: `UPDATE person TIMEOUT 1s`, + res: &Query{Statements: []Statement{&UpdateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, + Echo: AFTER, + Timeout: 1 * time.Second, + }}}, + }, + { + sql: `UPDATE person TIMEOUT null`, + err: "Found `null` but expected `duration`", + }, + { + sql: `UPDATE person something`, + err: "Found `something` but expected `;`", }, } @@ -1521,73 +1543,90 @@ func Test_Parse_Queries_Delete(t *testing.T) { var tests = []tester{ { sql: `DELETE`, - err: "Found `` but expected `table, or thing`", + err: "Found `` but expected `expression`", }, { sql: `DELETE FROM`, - err: "Found `` but expected `table, or thing`", + err: "Found `` but expected `expression`", }, { sql: `DELETE person`, res: &Query{Statements: []Statement{&DeleteStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{ - &Table{"person"}, - }, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: NONE, }}}, }, { - sql: `DELETE person RETURN ID`, + sql: `DELETE AND EXPUNGE person`, res: &Query{Statements: []Statement{&DeleteStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, - Echo: ID, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, + Hard: true, + Echo: NONE, }}}, }, + { + sql: `DELETE person RETURN`, + err: "Found `` but expected `NONE, INFO, BOTH, DIFF, BEFORE, AFTER`", + }, { sql: `DELETE person RETURN NONE`, + str: `DELETE person`, res: &Query{Statements: []Statement{&DeleteStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: NONE, }}}, }, { sql: `DELETE person RETURN BOTH`, res: &Query{Statements: []Statement{&DeleteStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: BOTH, }}}, }, { sql: `DELETE person RETURN DIFF`, res: &Query{Statements: []Statement{&DeleteStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: DIFF, }}}, }, { sql: `DELETE person RETURN BEFORE`, res: &Query{Statements: []Statement{&DeleteStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: BEFORE, }}}, }, { sql: `DELETE person RETURN AFTER`, res: &Query{Statements: []Statement{&DeleteStatement{ - KV: "*", NS: "*", DB: "*", - What: []Expr{&Table{"person"}}, + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, Echo: AFTER, }}}, }, { - sql: `DELETE person RETURN SOMETHING`, - err: "Found `SOMETHING` but expected `ID, NONE, INFO, BOTH, DIFF, BEFORE, AFTER`", + sql: `DELETE person TIMEOUT 1s`, + res: &Query{Statements: []Statement{&DeleteStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: []Expr{&Ident{"person"}}, + Echo: NONE, + Timeout: 1 * time.Second, + }}}, + }, + { + sql: `DELETE person TIMEOUT null`, + err: "Found `null` but expected `duration`", + }, + { + sql: `DELETE person something`, + err: "Found `something` but expected `;`", }, } @@ -1599,7 +1638,142 @@ func Test_Parse_Queries_Delete(t *testing.T) { func Test_Parse_Queries_Relate(t *testing.T) { - var tests = []tester{} + var tests = []tester{ + { + sql: `RELATE`, + err: "Found `` but expected `table`", + }, + { + sql: `RELATE purchase`, + err: "Found `` but expected `FROM`", + }, + { + sql: `RELATE purchase FROM`, + err: "Found `` but expected `expression`", + }, + { + sql: `RELATE purchase FROM person`, + err: "Found `` but expected `TO, WITH`", + }, + { + sql: `RELATE purchase FROM person WITH`, + err: "Found `` but expected `expression`", + }, + { + sql: `RELATE purchase FROM person WITH item`, + res: &Query{Statements: []Statement{&RelateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Type: &Table{"purchase"}, + From: []Expr{&Ident{"person"}}, + With: []Expr{&Ident{"item"}}, + Echo: AFTER, + }}}, + }, + { + sql: `RELATE purchase FROM person WITH item UNIQUE`, + res: &Query{Statements: []Statement{&RelateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Type: &Table{"purchase"}, + From: []Expr{&Ident{"person"}}, + With: []Expr{&Ident{"item"}}, + Uniq: true, + Echo: AFTER, + }}}, + }, + { + sql: `RELATE purchase FROM person WITH item SET 123`, + err: "Found `123` but expected `field name`", + }, + { + sql: `RELATE purchase FROM person WITH item SET firstname`, + err: "Found `` but expected `=, +=, -=`", + }, + { + sql: `RELATE purchase FROM person WITH item SET public = true`, + res: &Query{Statements: []Statement{&RelateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Type: &Table{"purchase"}, + From: []Expr{&Ident{"person"}}, + With: []Expr{&Ident{"item"}}, + Data: &DataExpression{Data: []*ItemExpression{{LHS: &Ident{"public"}, Op: EQ, RHS: true}}}, + Echo: AFTER, + }}}, + }, + { + sql: `RELATE purchase FROM person WITH item RETURN`, + err: "Found `` but expected `NONE, INFO, BOTH, DIFF, BEFORE, AFTER`", + }, + { + sql: `RELATE purchase FROM person WITH item RETURN NONE`, + res: &Query{Statements: []Statement{&RelateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Type: &Table{"purchase"}, + From: []Expr{&Ident{"person"}}, + With: []Expr{&Ident{"item"}}, + Echo: NONE, + }}}, + }, + { + sql: `RELATE purchase FROM person WITH item RETURN BOTH`, + res: &Query{Statements: []Statement{&RelateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Type: &Table{"purchase"}, + From: []Expr{&Ident{"person"}}, + With: []Expr{&Ident{"item"}}, + Echo: BOTH, + }}}, + }, + { + sql: `RELATE purchase FROM person WITH item RETURN DIFF`, + res: &Query{Statements: []Statement{&RelateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Type: &Table{"purchase"}, + From: []Expr{&Ident{"person"}}, + With: []Expr{&Ident{"item"}}, + Echo: DIFF, + }}}, + }, + { + sql: `RELATE purchase FROM person WITH item RETURN BEFORE`, + res: &Query{Statements: []Statement{&RelateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Type: &Table{"purchase"}, + From: []Expr{&Ident{"person"}}, + With: []Expr{&Ident{"item"}}, + Echo: BEFORE, + }}}, + }, + { + sql: `RELATE purchase FROM person WITH item RETURN AFTER`, + str: `RELATE purchase FROM person WITH item`, + res: &Query{Statements: []Statement{&RelateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Type: &Table{"purchase"}, + From: []Expr{&Ident{"person"}}, + With: []Expr{&Ident{"item"}}, + Echo: AFTER, + }}}, + }, + { + sql: `RELATE purchase FROM person WITH item TIMEOUT 1s`, + res: &Query{Statements: []Statement{&RelateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Type: &Table{"purchase"}, + From: []Expr{&Ident{"person"}}, + With: []Expr{&Ident{"item"}}, + Echo: AFTER, + Timeout: 1 * time.Second, + }}}, + }, + { + sql: `RELATE purchase FROM person WITH item TIMEOUT null`, + err: "Found `null` but expected `duration`", + }, + { + sql: `RELATE purchase FROM person WITH item something`, + err: "Found `something` but expected `;`", + }, + } for _, test := range tests { testsql(t, test) @@ -1607,9 +1781,315 @@ func Test_Parse_Queries_Relate(t *testing.T) { } -func Test_Parse_Queries_Record(t *testing.T) { +func Test_Parse_Queries_Insert(t *testing.T) { - var tests = []tester{} + var tests = []tester{ + { + sql: `INSERT`, + err: "Found `` but expected `expression`", + }, + { + sql: `INSERT ["one","two","tre"]`, + err: "Found `` but expected `INTO`", + }, + { + sql: `INSERT ["one","two","tre"] INTO`, + err: "Found `` but expected `table`", + }, + { + sql: `INSERT ["one","two","tre"] INTO person`, + res: &Query{Statements: []Statement{&InsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: AFTER, + }}}, + }, + { + sql: `INSERT ["one","two","tre"] INTO person RETURN`, + err: "Found `` but expected `NONE, INFO, BOTH, DIFF, BEFORE, AFTER`", + }, + { + sql: `INSERT ["one","two","tre"] INTO person RETURN NONE`, + res: &Query{Statements: []Statement{&InsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: NONE, + }}}, + }, + { + sql: `INSERT ["one","two","tre"] INTO person RETURN INFO`, + res: &Query{Statements: []Statement{&InsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: INFO, + }}}, + }, + { + sql: `INSERT ["one","two","tre"] INTO person RETURN BOTH`, + res: &Query{Statements: []Statement{&InsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: BOTH, + }}}, + }, + { + sql: `INSERT ["one","two","tre"] INTO person RETURN DIFF`, + res: &Query{Statements: []Statement{&InsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: DIFF, + }}}, + }, + { + sql: `INSERT ["one","two","tre"] INTO person RETURN BEFORE`, + res: &Query{Statements: []Statement{&InsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: BEFORE, + }}}, + }, + { + sql: `INSERT ["one","two","tre"] INTO person RETURN AFTER`, + str: `INSERT ["one","two","tre"] INTO person`, + res: &Query{Statements: []Statement{&InsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: AFTER, + }}}, + }, + { + sql: `INSERT ["one","two","tre"] INTO person TIMEOUT 1s`, + res: &Query{Statements: []Statement{&InsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: AFTER, + Timeout: 1 * time.Second, + }}}, + }, + { + sql: `INSERT ["one","two","tre"] INTO person TIMEOUT null`, + err: "Found `null` but expected `duration`", + }, + { + sql: `INSERT ["one","two","tre"] INTO person something`, + err: "Found `something` but expected `;`", + }, + } + + for _, test := range tests { + testsql(t, test) + } + +} + +func Test_Parse_Queries_Upsert(t *testing.T) { + + var tests = []tester{ + { + sql: `UPSERT`, + err: "Found `` but expected `expression`", + }, + { + sql: `UPSERT ["one","two","tre"]`, + err: "Found `` but expected `INTO`", + }, + { + sql: `UPSERT ["one","two","tre"] INTO`, + err: "Found `` but expected `table`", + }, + { + sql: `UPSERT ["one","two","tre"] INTO person`, + res: &Query{Statements: []Statement{&UpsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: AFTER, + }}}, + }, + { + sql: `UPSERT ["one","two","tre"] INTO person RETURN`, + err: "Found `` but expected `NONE, INFO, BOTH, DIFF, BEFORE, AFTER`", + }, + { + sql: `UPSERT ["one","two","tre"] INTO person RETURN NONE`, + res: &Query{Statements: []Statement{&UpsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: NONE, + }}}, + }, + { + sql: `UPSERT ["one","two","tre"] INTO person RETURN INFO`, + res: &Query{Statements: []Statement{&UpsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: INFO, + }}}, + }, + { + sql: `UPSERT ["one","two","tre"] INTO person RETURN BOTH`, + res: &Query{Statements: []Statement{&UpsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: BOTH, + }}}, + }, + { + sql: `UPSERT ["one","two","tre"] INTO person RETURN DIFF`, + res: &Query{Statements: []Statement{&UpsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: DIFF, + }}}, + }, + { + sql: `UPSERT ["one","two","tre"] INTO person RETURN BEFORE`, + res: &Query{Statements: []Statement{&UpsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: BEFORE, + }}}, + }, + { + sql: `UPSERT ["one","two","tre"] INTO person RETURN AFTER`, + str: `UPSERT ["one","two","tre"] INTO person`, + res: &Query{Statements: []Statement{&UpsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: AFTER, + }}}, + }, + { + sql: `UPSERT ["one","two","tre"] INTO person TIMEOUT 1s`, + res: &Query{Statements: []Statement{&UpsertStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Data: []interface{}{"one", "two", "tre"}, + Into: &Table{"person"}, + Echo: AFTER, + Timeout: 1 * time.Second, + }}}, + }, + { + sql: `UPSERT ["one","two","tre"] INTO person TIMEOUT null`, + err: "Found `null` but expected `duration`", + }, + { + sql: `UPSERT ["one","two","tre"] INTO person something`, + err: "Found `something` but expected `;`", + }, + } + + for _, test := range tests { + testsql(t, test) + } + +} + +func Test_Parse_Queries_Live(t *testing.T) { + + var tests = []tester{ + { + sql: `LIVE`, + err: "Found `` but expected `SELECT`", + }, + { + sql: `LIVE SELECT`, + err: "Found `` but expected `expression`", + }, + { + sql: `LIVE SELECT *`, + err: "Found `` but expected `FROM`", + }, + { + sql: `LIVE SELECT * FROM`, + err: "Found `` but expected `table`", + }, + { + sql: `LIVE SELECT * FROM person`, + res: &Query{Statements: []Statement{&LiveStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: &Table{"person"}, + }}}, + }, + { + sql: `LIVE SELECT * FROM person WHERE`, + err: "Found `` but expected `expression`", + }, + { + sql: `LIVE SELECT * FROM person WHERE public = true`, + res: &Query{Statements: []Statement{&LiveStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: &Table{"person"}, + Cond: &BinaryExpression{ + LHS: &Ident{"public"}, + Op: EQ, + RHS: true, + }, + }}}, + }, + { + sql: `LIVE SELECT * FROM person WHERE public = true something`, + err: "Found `something` but expected `;`", + }, + } + + for _, test := range tests { + testsql(t, test) + } + +} + +func Test_Parse_Queries_Kill(t *testing.T) { + + var tests = []tester{ + { + sql: `KILL`, + err: "Found `` but expected `string`", + }, + { + sql: `KILL null`, + err: "Found `null` but expected `string`", + }, + { + sql: `KILL 1`, + err: "Found `1` but expected `string`", + }, + { + sql: `KILL 1.3000`, + err: "Found `1.3000` but expected `string`", + }, + { + sql: `KILL identifier`, + err: "Found `identifier` but expected `string`", + }, + { + sql: `KILL "identifier"`, + res: &Query{Statements: []Statement{&KillStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Value{"identifier"}, + }}}, + }, + { + sql: `KILL "identifier" something`, + err: "Found `something` but expected `;`", + }, + } for _, test := range tests { testsql(t, test) @@ -1622,7 +2102,305 @@ func Test_Parse_Queries_Define(t *testing.T) { var tests = []tester{ { sql: `DEFINE`, - err: "Found `` but expected `NAMESPACE, DATABASE, LOGIN, TOKEN, SCOPE, TABLE, FIELD, INDEX, VIEW`", + err: "Found `` but expected `NAMESPACE, DATABASE, LOGIN, TOKEN, SCOPE, TABLE, EVENT, FIELD, INDEX`", + }, + // ---------------------------------------------------------------------- + { + sql: `DEFINE NAMESPACE`, + err: "Found `` but expected `name`", + }, + { + sql: `DEFINE NAMESPACE 111`, + err: "Found `111` but expected `name`", + }, + { + sql: `DEFINE NAMESPACE 111.111`, + err: "Found `111.111` but expected `name`", + }, + { + sql: `DEFINE NAMESPACE test`, + res: &Query{Statements: []Statement{&DefineNamespaceStatement{ + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"test"}, + }}}, + }, + { + sql: `DEFINE NAMESPACE test something`, + err: "Found `something` but expected `;`", + }, + // ---------------------------------------------------------------------- + { + sql: `DEFINE DATABASE`, + err: "Found `` but expected `name`", + }, + { + sql: `DEFINE DATABASE 111`, + err: "Found `111` but expected `name`", + }, + { + sql: `DEFINE DATABASE 111.111`, + err: "Found `111.111` but expected `name`", + }, + { + sql: `DEFINE DATABASE test`, + res: &Query{Statements: []Statement{&DefineDatabaseStatement{ + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"test"}, + }}}, + }, + { + sql: `DEFINE DATABASE test something`, + err: "Found `something` but expected `;`", + }, + // ---------------------------------------------------------------------- + { + sql: `DEFINE LOGIN`, + err: "Found `` but expected `name`", + }, + { + sql: `DEFINE LOGIN 111`, + err: "Found `111` but expected `name`", + }, + { + sql: `DEFINE LOGIN 111.111`, + err: "Found `111.111` but expected `name`", + }, + { + sql: `DEFINE LOGIN test`, + err: "Found `` but expected `ON`", + }, + { + sql: `DEFINE LOGIN test ON`, + err: "Found `` but expected `NAMESPACE, DATABASE`", + }, + { + sql: `DEFINE LOGIN test ON something`, + err: "Found `something` but expected `NAMESPACE, DATABASE`", + }, + { + sql: `DEFINE LOGIN test ON NAMESPACE`, + err: "Found `` but expected `PASSWORD`", + }, + { + sql: `DEFINE LOGIN test ON NAMESPACE PASSWORD`, + err: "Found `` but expected `string`", + }, + { + sql: `DEFINE LOGIN test ON NAMESPACE PASSWORD "123456"`, + str: `DEFINE LOGIN test ON NAMESPACE PASSWORD ********`, + res: &Query{Statements: []Statement{&DefineLoginStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Kind: NAMESPACE, + User: &Ident{"test"}, + Pass: []byte("123456"), + }}}, + }, + { + sql: `DEFINE LOGIN test ON DATABASE PASSWORD "123456"`, + str: `DEFINE LOGIN test ON DATABASE PASSWORD ********`, + res: &Query{Statements: []Statement{&DefineLoginStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Kind: DATABASE, + User: &Ident{"test"}, + Pass: []byte("123456"), + }}}, + }, + { + sql: `DEFINE LOGIN test ON NAMESPACE PASSWORD "123456" something`, + err: "Found `something` but expected `;`", + }, + // ---------------------------------------------------------------------- + { + sql: `DEFINE TOKEN`, + err: "Found `` but expected `name`", + }, + { + sql: `DEFINE TOKEN 111`, + err: "Found `111` but expected `name`", + }, + { + sql: `DEFINE TOKEN 111.111`, + err: "Found `111.111` but expected `name`", + }, + { + sql: `DEFINE TOKEN test`, + err: "Found `` but expected `ON`", + }, + { + sql: `DEFINE TOKEN test ON`, + err: "Found `` but expected `NAMESPACE, DATABASE, SCOPE`", + }, + { + sql: `DEFINE TOKEN test ON something`, + err: "Found `something` but expected `NAMESPACE, DATABASE, SCOPE`", + }, + { + sql: `DEFINE TOKEN test ON NAMESPACE`, + err: "Found `` but expected `TYPE`", + }, + { + sql: `DEFINE TOKEN test ON NAMESPACE TYPE 100`, + err: "Found `100` but expected `ES256, ES384, ES512, HS256, HS384, HS512, PS256, PS384, PS512, RS256, RS384, RS512`", + }, + { + sql: `DEFINE TOKEN test ON NAMESPACE TYPE XX512`, + err: "Found `XX512` but expected `ES256, ES384, ES512, HS256, HS384, HS512, PS256, PS384, PS512, RS256, RS384, RS512`", + }, + { + sql: `DEFINE TOKEN test ON NAMESPACE TYPE HS512`, + err: "Found `` but expected `VALUE`", + }, + { + sql: `DEFINE TOKEN test ON NAMESPACE TYPE HS512`, + err: "Found `` but expected `VALUE`", + }, + { + sql: `DEFINE TOKEN test ON NAMESPACE TYPE HS512 VALUE`, + err: "Found `` but expected `string`", + }, + { + sql: `DEFINE TOKEN test ON NAMESPACE TYPE HS512 VALUE "secret"`, + str: `DEFINE TOKEN test ON NAMESPACE TYPE HS512 VALUE ********`, + res: &Query{Statements: []Statement{&DefineTokenStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Kind: NAMESPACE, + Name: &Ident{"test"}, + Type: "HS512", + Code: []byte("secret"), + }}}, + }, + { + sql: `DEFINE TOKEN test ON DATABASE TYPE HS512 VALUE "secret"`, + str: `DEFINE TOKEN test ON DATABASE TYPE HS512 VALUE ********`, + res: &Query{Statements: []Statement{&DefineTokenStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Kind: DATABASE, + Name: &Ident{"test"}, + Type: "HS512", + Code: []byte("secret"), + }}}, + }, + { + sql: `DEFINE TOKEN test ON SCOPE TYPE HS512 VALUE "secret"`, + str: `DEFINE TOKEN test ON SCOPE TYPE HS512 VALUE ********`, + res: &Query{Statements: []Statement{&DefineTokenStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Kind: SCOPE, + Name: &Ident{"test"}, + Type: "HS512", + Code: []byte("secret"), + }}}, + }, + { + sql: `DEFINE TOKEN test ON SCOPE TYPE HS512 VALUE "secret" something`, + err: "Found `something` but expected `;`", + }, + // ---------------------------------------------------------------------- + { + sql: `DEFINE SCOPE`, + err: "Found `` but expected `name`", + }, + { + sql: `DEFINE SCOPE 111`, + err: "Found `111` but expected `name`", + }, + { + sql: `DEFINE SCOPE 111.111`, + err: "Found `111.111` but expected `name`", + }, + { + sql: `DEFINE SCOPE test`, + res: &Query{Statements: []Statement{&DefineScopeStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"test"}, + }}}, + }, + { + sql: `DEFINE SCOPE test SESSION null`, + err: "Found `null` but expected `duration`", + }, + { + sql: `DEFINE SCOPE test SESSION 1h`, + str: `DEFINE SCOPE test SESSION 1h0m0s`, + res: &Query{Statements: []Statement{&DefineScopeStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"test"}, + Time: 1 * time.Hour, + }}}, + }, + { + sql: `DEFINE SCOPE test SESSION 1d`, + str: `DEFINE SCOPE test SESSION 24h0m0s`, + res: &Query{Statements: []Statement{&DefineScopeStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"test"}, + Time: 24 * time.Hour, + }}}, + }, + { + sql: `DEFINE SCOPE test SESSION 1w`, + str: `DEFINE SCOPE test SESSION 168h0m0s`, + res: &Query{Statements: []Statement{&DefineScopeStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"test"}, + Time: 168 * time.Hour, + }}}, + }, + { + sql: `DEFINE SCOPE test SIGNUP AS NONE`, + err: "Found `NONE` but expected `expression`", + }, + { + sql: `DEFINE SCOPE test SIGNUP AS (CREATE person)`, + res: &Query{Statements: []Statement{&DefineScopeStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"test"}, + Signup: &SubExpression{ + Expr: &CreateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Exprs{&Ident{ID: "person"}}, + Echo: AFTER, + }, + }, + }}}, + }, + { + sql: `DEFINE SCOPE test SIGNIN AS NONE`, + err: "Found `NONE` but expected `expression`", + }, + { + sql: `DEFINE SCOPE test SIGNIN AS (SELECT * FROM person)`, + res: &Query{Statements: []Statement{&DefineScopeStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"test"}, + Signin: &SubExpression{ + Expr: &SelectStatement{ + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Ident{"person"}}, + }, + }, + }}}, + }, + { + sql: `DEFINE SCOPE test CONNECT AS NONE`, + err: "Found `NONE` but expected `expression`", + }, + { + sql: `DEFINE SCOPE test CONNECT AS (SELECT * FROM $id)`, + res: &Query{Statements: []Statement{&DefineScopeStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"test"}, + Connect: &SubExpression{ + Expr: &SelectStatement{ + RW: false, KV: "*", NS: "*", DB: "*", + Expr: []*Field{{Expr: &All{}, Field: "*"}}, + What: []Expr{&Param{"id"}}, + }, + }, + }}}, + }, + { + sql: `DEFINE SCOPE test something`, + err: "Found `something` but expected `;`", }, // ---------------------------------------------------------------------- { @@ -1640,18 +2418,28 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE TABLE person`, res: &Query{Statements: []Statement{&DefineTableStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", What: Tables{&Table{"person"}}, }}}, }, { sql: `DEFINE TABLE person something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", + }, + { + sql: `DEFINE TABLE person DROP`, + str: `DEFINE TABLE person DROP`, + res: &Query{Statements: []Statement{&DefineTableStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Tables{&Table{"person"}}, + Drop: true, + }}}, }, { sql: `DEFINE TABLE person SCHEMALESS`, + str: `DEFINE TABLE person`, res: &Query{Statements: []Statement{&DefineTableStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", What: Tables{&Table{"person"}}, Full: false, }}}, @@ -1659,23 +2447,200 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE TABLE person SCHEMAFULL`, res: &Query{Statements: []Statement{&DefineTableStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", What: Tables{&Table{"person"}}, Full: true, }}}, }, + { + sql: `DEFINE TABLE person PERMISSIONS SOME`, + err: "Found `SOME` but expected `FOR, NONE, FULL, WHERE`", + }, + { + sql: `DEFINE TABLE person PERMISSIONS NONE`, + res: &Query{Statements: []Statement{&DefineTableStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Tables{&Table{"person"}}, + Perms: &PermExpression{ + Select: false, + Create: false, + Update: false, + Delete: false, + }, + }}}, + }, + { + sql: `DEFINE TABLE person PERMISSIONS FULL`, + res: &Query{Statements: []Statement{&DefineTableStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Tables{&Table{"person"}}, + Perms: &PermExpression{ + Select: true, + Create: true, + Update: true, + Delete: true, + }, + }}}, + }, + { + sql: `DEFINE TABLE person PERMISSIONS WHERE public = true`, + res: &Query{Statements: []Statement{&DefineTableStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Tables{&Table{"person"}}, + Perms: &PermExpression{ + Select: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Create: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Update: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Delete: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + }, + }}}, + }, + { + sql: `DEFINE TABLE person PERMISSIONS FOR select FULL FOR insert, upsert NONE`, + err: "Found `insert` but expected `SELECT, CREATE, UPDATE, DELETE`", + }, + { + sql: `DEFINE TABLE person PERMISSIONS FOR select FULL FOR create, update, delete SOME`, + err: "Found `SOME` but expected `FULL, NONE, WHERE`", + }, + { + sql: `DEFINE TABLE person PERMISSIONS FOR select FULL FOR create, update, delete NONE`, + res: &Query{Statements: []Statement{&DefineTableStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Tables{&Table{"person"}}, + Perms: &PermExpression{ + Select: true, + Create: false, + Update: false, + Delete: false, + }, + }}}, + }, + { + sql: `DEFINE TABLE person PERMISSIONS FOR select, create, update WHERE public = true FOR delete NONE`, + res: &Query{Statements: []Statement{&DefineTableStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Tables{&Table{"person"}}, + Perms: &PermExpression{ + Select: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Create: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Update: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Delete: false, + }, + }}}, + }, + { + sql: `DEFINE TABLE person AS SELECT nationality, midhinge(age) AS mid FROM users GROUP BY nationality`, + err: "Found 'mid' but field is not an aggregate function, and is not present in GROUP expression", + }, + { + sql: `DEFINE TABLE person AS SELECT nationality, count(*) AS total FROM users WHERE public = true GROUP BY nationality`, + res: &Query{Statements: []Statement{&DefineTableStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Tables{&Table{"person"}}, + Lock: true, + Expr: Fields{ + &Field{ + Expr: &Ident{ID: "nationality"}, + Field: "nationality", + }, + &Field{ + Expr: &FuncExpression{ + Name: "count", + Args: Exprs{&All{}}, + Aggr: true, + }, + Field: "total", + Alias: "total", + }, + }, + From: Tables{ + &Table{TB: "users"}, + }, + Cond: &BinaryExpression{ + LHS: &Ident{ID: "public"}, + Op: EQ, + RHS: true, + }, + Group: Groups{ + &Group{ + Expr: &Ident{ID: "nationality"}, + }, + }, + }}}, + }, { sql: `DEFINE TABLE person SCHEMALESS something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, { sql: `DEFINE TABLE person SCHEMAFULL something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", + }, + // ---------------------------------------------------------------------- + { + sql: `DEFINE EVENT`, + err: "Found `` but expected `name`", + }, + { + sql: `DEFINE EVENT temp`, + err: "Found `` but expected `ON`", + }, + { + sql: `DEFINE EVENT temp ON`, + err: "Found `` but expected `table`", + }, + { + sql: `DEFINE EVENT temp ON person`, + err: "Found `` but expected `WHEN`", + }, + { + sql: `DEFINE EVENT temp ON person WHEN`, + err: "Found `` but expected `expression`", + }, + { + sql: `DEFINE EVENT temp ON person WHEN $before.price < $after.price`, + err: "Found `` but expected `THEN`", + }, + { + sql: `DEFINE EVENT temp ON person WHEN $before.price < $after.price THEN`, + err: "Found `` but expected `expression`", + }, + { + sql: `DEFINE EVENT temp ON person WHEN $before.price < $after.price THEN (UPDATE $this SET increased = true)`, + res: &Query{Statements: []Statement{&DefineEventStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"temp"}, + What: Tables{&Table{"person"}}, + When: &BinaryExpression{ + LHS: &Param{"before.price"}, + Op: LT, + RHS: &Param{"after.price"}, + }, + Then: &SubExpression{ + Expr: &UpdateStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + What: Exprs{&Param{"this"}}, + Data: &DataExpression{[]*ItemExpression{ + { + LHS: &Ident{"increased"}, + Op: EQ, + RHS: true, + }, + }}, + Echo: AFTER, + }, + }, + }}}, + }, + { + sql: `DEFINE EVENT temp ON person WHEN $before.price < $after.price THEN (UPDATE $this SET increased = true) something`, + err: "Found `something` but expected `;`", }, // ---------------------------------------------------------------------- { sql: `DEFINE FIELD`, - err: "Found `` but expected `name`", + err: "Found `` but expected `name, or expression`", }, { sql: `DEFINE FIELD temp`, @@ -1688,32 +2653,23 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE FIELD temp ON person`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, }}}, }, { sql: `DEFINE FIELD temp ON person TYPE`, - err: "Found `` but expected `any, url, uuid, color, email, phone, array, object, domain, record, string, number, double, custom, boolean, password, datetime, latitude, longitude`", + err: "Found `` but expected `array, boolean, circle, color, datetime, domain, double, email, latitude, longitude, number, object, password, phone, point, polygon, record, string, url, uuid`", }, { sql: `DEFINE FIELD temp ON person TYPE something`, - err: "Found `something` but expected `any, url, uuid, color, email, phone, array, object, domain, record, string, number, double, custom, boolean, password, datetime, latitude, longitude`", - }, - { - sql: `DEFINE FIELD temp ON person TYPE any`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - }}}, + err: "Found `something` but expected `array, boolean, circle, color, datetime, domain, double, email, latitude, longitude, number, object, password, phone, point, polygon, record, string, url, uuid`", }, { sql: `DEFINE FIELD temp ON person TYPE url`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, Type: "url", @@ -1722,7 +2678,7 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE FIELD temp ON person TYPE email`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, Type: "email", @@ -1731,7 +2687,7 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE FIELD temp ON person TYPE phone`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, Type: "phone", @@ -1740,7 +2696,7 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE FIELD temp ON person TYPE array`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, Type: "array", @@ -1749,7 +2705,7 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE FIELD temp ON person TYPE object`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, Type: "object", @@ -1758,7 +2714,7 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE FIELD temp ON person TYPE string`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, Type: "string", @@ -1767,7 +2723,7 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE FIELD temp ON person TYPE number`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, Type: "number", @@ -1776,346 +2732,154 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE FIELD temp ON person TYPE double`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, Type: "double", }}}, }, { - sql: `DEFINE FIELD temp ON person TYPE custom`, + sql: `DEFINE FIELD temp ON person TYPE record`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, - Type: "custom", + Type: "record", }}}, }, { - sql: `DEFINE FIELD temp ON person TYPE custom ENUM ["default","notdefault"]`, + sql: `DEFINE FIELD temp ON person TYPE record (item)`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, - Type: "custom", - Enum: Array{"default", "notdefault"}, + Type: "record", + Kind: "item", }}}, }, { - sql: `DEFINE FIELD temp ON person TYPE custom ENUM ["default" "notdefault"]`, + sql: `DEFINE FIELD temp ON person VALUE`, + err: "Found `` but expected `expression`", + }, + { + sql: `DEFINE FIELD temp ON person VALUE string.uppercase($value)`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "custom", - Enum: Array{"default", "notdefault"}, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any DEFAULT true`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Default: true, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any DEFAULT false`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Default: false, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any DEFAULT 100`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Default: int64(100), - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any DEFAULT "default"`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Default: &Value{"default"}, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any DEFAULT "this\nis\nsome\ntext"`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Default: &Value{"this\nis\nsome\ntext"}, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any DEFAULT {"default":true}`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Default: Object{"default": true}, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any DEFAULT something`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Default: &Ident{"something"}, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MIN`, - err: "Found `` but expected `number`", - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MIN 1`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Min: 1, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MIN 1.0`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Min: 1, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MIN 1.0001`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Min: 1.0001, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MIN something`, - err: "Found `something` but expected `number`", - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MAX`, - err: "Found `` but expected `number`", - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MAX 100`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Max: 100, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MAX 100.0`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Max: 100, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MAX 100.0001`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Max: 100.0001, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MAX something`, - err: "Found `something` but expected `number`", - }, - { - sql: `DEFINE FIELD temp ON person TYPE any CODE`, - err: "Found `` but expected `script`", - }, - { - sql: `DEFINE FIELD temp ON person TYPE any CODE "return doc.data.id"`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Code: "return doc.data.id", - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any CODE something`, - err: "Found `something` but expected `script`", - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MATCH`, - err: "Found `` but expected `regular expression`", - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MATCH /.*/`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, - Type: "any", - Match: ".*", + Value: &FuncExpression{Name: "string.uppercase", Args: Exprs{&Param{"value"}}}, }}}, }, { - sql: `DEFINE FIELD temp ON person TYPE any MATCH something`, - err: "Found `something` but expected `regular expression`", + sql: `DEFINE FIELD temp ON person ASSERT`, + err: "Found `` but expected `expression`", }, { - sql: `DEFINE FIELD temp ON person TYPE any NOTNULL`, + sql: `DEFINE FIELD temp ON person ASSERT $value > 0 AND $value < 100`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Notnull: true, + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"temp"}, + What: Tables{&Table{"person"}}, + Assert: &BinaryExpression{ + LHS: &Param{"value"}, + Op: GT, + RHS: &BinaryExpression{ + LHS: 0.0, + Op: AND, + RHS: &BinaryExpression{ + LHS: &Param{"value"}, + Op: LT, + RHS: 100.0, + }, + }, + }, }}}, }, { - sql: `DEFINE FIELD temp ON person TYPE any NOTNULL true`, + sql: `DEFINE FIELD temp ON person PERMISSIONS SOME`, + err: "Found `SOME` but expected `FOR, NONE, FULL, WHERE`", + }, + { + sql: `DEFINE FIELD temp ON person PERMISSIONS NONE`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Notnull: true, + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"temp"}, + What: Tables{&Table{"person"}}, + Perms: &PermExpression{ + Select: false, + Create: false, + Update: false, + Delete: false, + }, }}}, }, { - sql: `DEFINE FIELD temp ON person TYPE any NOTNULL false`, + sql: `DEFINE FIELD temp ON person PERMISSIONS FULL`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Notnull: false, + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"temp"}, + What: Tables{&Table{"person"}}, + Perms: &PermExpression{ + Select: true, + Create: true, + Update: true, + Delete: true, + }, }}}, }, { - sql: `DEFINE FIELD temp ON person TYPE any READONLY`, + sql: `DEFINE FIELD temp ON person PERMISSIONS WHERE public = true`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Readonly: true, + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"temp"}, + What: Tables{&Table{"person"}}, + Perms: &PermExpression{ + Select: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Create: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Update: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Delete: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + }, }}}, }, { - sql: `DEFINE FIELD temp ON person TYPE any READONLY true`, + sql: `DEFINE FIELD temp ON person PERMISSIONS FOR select FULL FOR insert, upsert NONE`, + err: "Found `insert` but expected `SELECT, CREATE, UPDATE, DELETE`", + }, + { + sql: `DEFINE FIELD temp ON person PERMISSIONS FOR select FULL FOR create, update, delete SOME`, + err: "Found `SOME` but expected `FULL, NONE, WHERE`", + }, + { + sql: `DEFINE FIELD temp ON person PERMISSIONS FOR select FULL FOR create, update, delete NONE`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Readonly: true, + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"temp"}, + What: Tables{&Table{"person"}}, + Perms: &PermExpression{ + Select: true, + Create: false, + Update: false, + Delete: false, + }, }}}, }, { - sql: `DEFINE FIELD temp ON person TYPE any READONLY false`, + sql: `DEFINE FIELD temp ON person PERMISSIONS FOR select, create, update WHERE public = true FOR delete NONE`, res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Readonly: false, + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"temp"}, + What: Tables{&Table{"person"}}, + Perms: &PermExpression{ + Select: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Create: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Update: &BinaryExpression{LHS: &Ident{"public"}, Op: EQ, RHS: true}, + Delete: false, + }, }}}, }, { - sql: `DEFINE FIELD temp ON person TYPE any MANDATORY`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Mandatory: true, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MANDATORY true`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Mandatory: true, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any MANDATORY false`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Mandatory: false, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any VALIDATE`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Validate: true, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any VALIDATE true`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Validate: true, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any VALIDATE false`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "any", - Validate: false, - }}}, - }, - { - sql: `DEFINE FIELD temp ON person TYPE any something`, - err: "Found `something` but expected `EOF, ;`", + sql: `DEFINE FIELD temp ON person something`, + err: "Found `something` but expected `;`", }, // ---------------------------------------------------------------------- { @@ -2141,7 +2905,7 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE INDEX temp ON person COLUMNS firstname, lastname`, res: &Query{Statements: []Statement{&DefineIndexStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, Cols: Idents{&Ident{"firstname"}, &Ident{"lastname"}}, @@ -2151,7 +2915,7 @@ func Test_Parse_Queries_Define(t *testing.T) { { sql: `DEFINE INDEX temp ON person COLUMNS firstname, lastname UNIQUE`, res: &Query{Statements: []Statement{&DefineIndexStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, Cols: Idents{&Ident{"firstname"}, &Ident{"lastname"}}, @@ -2160,49 +2924,11 @@ func Test_Parse_Queries_Define(t *testing.T) { }, { sql: `DEFINE INDEX temp ON person COLUMNS firstname, lastname something UNIQUE`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, { sql: `DEFINE INDEX temp ON person COLUMNS firstname, lastname UNIQUE something`, - err: "Found `something` but expected `EOF, ;`", - }, - // ---------------------------------------------------------------------- - { - sql: `DEFINE VIEW`, - err: "Found `` but expected `name`", - }, - { - sql: `DEFINE VIEW temp`, - err: "Found `` but expected `AS`", - }, - { - sql: `DEFINE VIEW temp AS`, - err: "Found `` but expected `SELECT`", - }, - { - sql: `DEFINE VIEW temp AS SELECT`, - err: "Found `` but expected `expression`", - }, - { - sql: `DEFINE VIEW temp AS SELECT *`, - err: "Found `` but expected `FROM`", - }, - { - sql: `DEFINE VIEW temp AS SELECT * FROM`, - err: "Found `` but expected `table`", - }, - { - sql: `DEFINE VIEW temp AS SELECT * FROM person`, - res: &Query{Statements: []Statement{&DefineViewStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - Expr: []*Field{{Expr: &All{}}}, - What: Tables{&Table{"person"}}, - }}}, - }, - { - sql: `DEFINE VIEW temp AS SELECT * FROM person something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, } @@ -2217,7 +2943,174 @@ func Test_Parse_Queries_Remove(t *testing.T) { var tests = []tester{ { sql: `REMOVE`, - err: "Found `` but expected `NAMESPACE, DATABASE, LOGIN, TOKEN, SCOPE, TABLE, FIELD, INDEX, VIEW`", + err: "Found `` but expected `NAMESPACE, DATABASE, LOGIN, TOKEN, SCOPE, TABLE, EVENT, FIELD, INDEX`", + }, + // ---------------------------------------------------------------------- + { + sql: `REMOVE NAMESPACE`, + err: "Found `` but expected `name`", + }, + { + sql: `REMOVE NAMESPACE 111`, + err: "Found `111` but expected `name`", + }, + { + sql: `REMOVE NAMESPACE 111.111`, + err: "Found `111.111` but expected `name`", + }, + { + sql: `REMOVE NAMESPACE test`, + res: &Query{Statements: []Statement{&RemoveNamespaceStatement{ + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"test"}, + }}}, + }, + { + sql: `REMOVE NAMESPACE test something`, + err: "Found `something` but expected `;`", + }, + // ---------------------------------------------------------------------- + { + sql: `REMOVE DATABASE`, + err: "Found `` but expected `name`", + }, + { + sql: `REMOVE DATABASE 111`, + err: "Found `111` but expected `name`", + }, + { + sql: `REMOVE DATABASE 111.111`, + err: "Found `111.111` but expected `name`", + }, + { + sql: `REMOVE DATABASE test`, + res: &Query{Statements: []Statement{&RemoveDatabaseStatement{ + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"test"}, + }}}, + }, + { + sql: `REMOVE DATABASE test something`, + err: "Found `something` but expected `;`", + }, + // ---------------------------------------------------------------------- + { + sql: `REMOVE LOGIN`, + err: "Found `` but expected `name`", + }, + { + sql: `REMOVE LOGIN 111`, + err: "Found `111` but expected `name`", + }, + { + sql: `REMOVE LOGIN 111.111`, + err: "Found `111.111` but expected `name`", + }, + { + sql: `REMOVE LOGIN test`, + err: "Found `` but expected `ON`", + }, + { + sql: `REMOVE LOGIN test ON`, + err: "Found `` but expected `NAMESPACE, DATABASE`", + }, + { + sql: `REMOVE LOGIN test ON something`, + err: "Found `something` but expected `NAMESPACE, DATABASE`", + }, + { + sql: `REMOVE LOGIN test ON NAMESPACE`, + res: &Query{Statements: []Statement{&RemoveLoginStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Kind: NAMESPACE, + User: &Ident{"test"}, + }}}, + }, + { + sql: `REMOVE LOGIN test ON DATABASE`, + res: &Query{Statements: []Statement{&RemoveLoginStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Kind: DATABASE, + User: &Ident{"test"}, + }}}, + }, + { + sql: `REMOVE LOGIN test ON DATABASE something`, + err: "Found `something` but expected `;`", + }, + // ---------------------------------------------------------------------- + { + sql: `REMOVE TOKEN`, + err: "Found `` but expected `name`", + }, + { + sql: `REMOVE TOKEN 111`, + err: "Found `111` but expected `name`", + }, + { + sql: `REMOVE TOKEN 111.111`, + err: "Found `111.111` but expected `name`", + }, + { + sql: `REMOVE TOKEN test`, + err: "Found `` but expected `ON`", + }, + { + sql: `REMOVE TOKEN test ON`, + err: "Found `` but expected `NAMESPACE, DATABASE, SCOPE`", + }, + { + sql: `REMOVE TOKEN test ON something`, + err: "Found `something` but expected `NAMESPACE, DATABASE, SCOPE`", + }, + { + sql: `REMOVE TOKEN test ON NAMESPACE`, + res: &Query{Statements: []Statement{&RemoveTokenStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Kind: NAMESPACE, + Name: &Ident{"test"}, + }}}, + }, + { + sql: `REMOVE TOKEN test ON DATABASE`, + res: &Query{Statements: []Statement{&RemoveTokenStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Kind: DATABASE, + Name: &Ident{"test"}, + }}}, + }, + { + sql: `REMOVE TOKEN test ON SCOPE`, + res: &Query{Statements: []Statement{&RemoveTokenStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Kind: SCOPE, + Name: &Ident{"test"}, + }}}, + }, + { + sql: `REMOVE TOKEN test ON DATABASE something`, + err: "Found `something` but expected `;`", + }, + // ---------------------------------------------------------------------- + { + sql: `REMOVE SCOPE`, + err: "Found `` but expected `name`", + }, + { + sql: `REMOVE SCOPE 111`, + err: "Found `111` but expected `name`", + }, + { + sql: `REMOVE SCOPE 111.111`, + err: "Found `111.111` but expected `name`", + }, + { + sql: `REMOVE SCOPE test`, + res: &Query{Statements: []Statement{&RemoveScopeStatement{ + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"test"}, + }}}, + }, + { + sql: `REMOVE SCOPE test something`, + err: "Found `something` but expected `;`", }, // ---------------------------------------------------------------------- { @@ -2235,13 +3128,38 @@ func Test_Parse_Queries_Remove(t *testing.T) { { sql: `REMOVE TABLE person`, res: &Query{Statements: []Statement{&RemoveTableStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", What: Tables{&Table{"person"}}, }}}, }, { sql: `REMOVE TABLE person something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", + }, + // ---------------------------------------------------------------------- + { + sql: `REMOVE EVENT`, + err: "Found `` but expected `name`", + }, + { + sql: `REMOVE EVENT temp`, + err: "Found `` but expected `ON`", + }, + { + sql: `REMOVE EVENT temp ON`, + err: "Found `` but expected `table`", + }, + { + sql: `REMOVE EVENT temp ON person`, + res: &Query{Statements: []Statement{&RemoveEventStatement{ + RW: true, KV: "*", NS: "*", DB: "*", + Name: &Ident{"temp"}, + What: Tables{&Table{"person"}}, + }}}, + }, + { + sql: `REMOVE EVENT temp ON person something`, + err: "Found `something` but expected `;`", }, // ---------------------------------------------------------------------- { @@ -2259,14 +3177,14 @@ func Test_Parse_Queries_Remove(t *testing.T) { { sql: `REMOVE FIELD temp ON person`, res: &Query{Statements: []Statement{&RemoveFieldStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, }}}, }, { sql: `REMOVE FIELD temp ON person something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, // ---------------------------------------------------------------------- { @@ -2284,30 +3202,14 @@ func Test_Parse_Queries_Remove(t *testing.T) { { sql: `REMOVE INDEX temp ON person`, res: &Query{Statements: []Statement{&RemoveIndexStatement{ - KV: "*", NS: "*", DB: "*", + RW: true, KV: "*", NS: "*", DB: "*", Name: &Ident{"temp"}, What: Tables{&Table{"person"}}, }}}, }, { sql: `REMOVE INDEX temp ON person something`, - err: "Found `something` but expected `EOF, ;`", - }, - // ---------------------------------------------------------------------- - { - sql: `REMOVE VIEW`, - err: "Found `` but expected `name`", - }, - { - sql: `REMOVE VIEW temp`, - res: &Query{Statements: []Statement{&RemoveViewStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - }}}, - }, - { - sql: `REMOVE VIEW temp something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, } @@ -2322,11 +3224,12 @@ func Test_Parse_Queries_Begin(t *testing.T) { var tests = []tester{ { sql: `BEGIN`, + str: `BEGIN TRANSACTION`, res: &Query{Statements: []Statement{&BeginStatement{}}}, }, { sql: `BEGIN something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, { sql: `BEGIN TRANSACTION`, @@ -2334,7 +3237,7 @@ func Test_Parse_Queries_Begin(t *testing.T) { }, { sql: `BEGIN TRANSACTION something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, } @@ -2349,11 +3252,12 @@ func Test_Parse_Queries_Cancel(t *testing.T) { var tests = []tester{ { sql: `CANCEL`, + str: `CANCEL TRANSACTION`, res: &Query{Statements: []Statement{&CancelStatement{}}}, }, { sql: `CANCEL something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, { sql: `CANCEL TRANSACTION`, @@ -2361,7 +3265,7 @@ func Test_Parse_Queries_Cancel(t *testing.T) { }, { sql: `CANCEL TRANSACTION something`, - err: "Found `something` but expected `EOF, ;`", + err: "Found `something` but expected `;`", }, } @@ -2375,20 +3279,21 @@ func Test_Parse_Queries_Commit(t *testing.T) { var tests = []tester{ { - sql: `Commit`, + sql: `COMMIT`, + str: `COMMIT TRANSACTION`, res: &Query{Statements: []Statement{&CommitStatement{}}}, }, { - sql: `Commit something`, - err: "Found `something` but expected `EOF, ;`", + sql: `COMMIT something`, + err: "Found `something` but expected `;`", }, { - sql: `Commit TRANSACTION`, + sql: `COMMIT TRANSACTION`, res: &Query{Statements: []Statement{&CommitStatement{}}}, }, { - sql: `Commit TRANSACTION something`, - err: "Found `something` but expected `EOF, ;`", + sql: `COMMIT TRANSACTION something`, + err: "Found `something` but expected `;`", }, } diff --git a/sql/string.go b/sql/string.go index 76bca71f..bc4fe4ff 100644 --- a/sql/string.go +++ b/sql/string.go @@ -17,40 +17,96 @@ package sql import ( "encoding/json" "fmt" + "sort" + "strconv" "strings" "time" ) -func orNil(v interface{}) string { - switch v.(type) { - case nil: - return "" - default: - return fmt.Sprint(v) +const ( + _select method = iota + _create + _update + _delete +) + +type method int + +type methods []method + +func (this method) String() string { + switch this { + case _select: + return "select" + case _create: + return "create" + case _update: + return "update" + case _delete: + return "delete" } + return "" } -func stringIf(b bool, v interface{}) string { +func (this methods) String() string { + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() + } + return strings.Join(m, ", ") +} + +// --------------------------------------------- +// Helpers +// --------------------------------------------- + +func print(s string, a ...interface{}) string { + for k, v := range a { + switch v.(type) { + default: + case nil: + a[k] = "NULL" + case []interface{}: + out, _ := json.Marshal(v) + a[k] = string(out) + case map[string]interface{}: + out, _ := json.Marshal(v) + a[k] = string(out) + } + } + return fmt.Sprintf(s, a...) +} + +func maybe(b bool, v ...interface{}) string { switch b { case false: - return "" - default: - return fmt.Sprint(v) + if len(v) >= 2 { + return fmt.Sprint(v[1]) + } + case true: + if len(v) >= 1 { + return fmt.Sprint(v[0]) + } } + return "" } -func padToken(t Token) string { +func quote(s string) string { + t := newToken(s) switch t { - case OR, AND: - fallthrough - case IN, IS, CONTAINS: - fallthrough - case CONTAINSALL, CONTAINSNONE, CONTAINSSOME: - fallthrough - case ALLCONTAINEDIN, NONECONTAINEDIN, SOMECONTAINEDIN: - return fmt.Sprintf(" %v ", t) + case ILLEGAL: + if toQuote(s) { + return "`" + s + "`" + } + return s default: - return fmt.Sprintf("%v", t) + switch { + case t.isKeyword(): + return "`" + s + "`" + case t.isOperator(): + return "`" + s + "`" + } + return s } } @@ -65,9 +121,7 @@ func toQuote(s string) bool { continue case c == '[', c == ']': continue - case c == '-', c == '.': - continue - case c == '*': + case c == '.', c == '*': continue default: return true @@ -76,87 +130,6 @@ func toQuote(s string) bool { return false } -func stringFromBool(v bool, y, n string) string { - switch v { - case false: - return n - default: - return y - } -} - -func stringFromString(v string, y, n string) string { - switch v { - case "": - return n - default: - return y - } -} - -func stringFromInt(v int64, y, n string) string { - switch v { - case 0: - return n - default: - return y - } -} - -func stringFromFloat(v float64, y, n string) string { - switch v { - case 0: - return n - default: - return y - } -} - -func stringFromArray(v Array, y, n string) string { - switch len(v) { - case 0: - return n - default: - return y - } -} - -func stringFromSlice(v []interface{}, y, n string) string { - switch len(v) { - case 0: - return n - default: - return y - } -} - -func stringFromIdent(v *Ident, y, n string) string { - switch v { - case nil: - return n - default: - return y - } -} - -func stringFromInterface(v interface{}, y, n string) string { - switch v { - case nil: - return n - default: - return y - } -} - -func stringFromDuration(v time.Duration, y, n string) string { - switch v { - case 0: - return n - default: - return y - } -} - // --------------------------------------------- // Statements // --------------------------------------------- @@ -176,133 +149,166 @@ func (this CommitStatement) String() string { func (this UseStatement) String() string { switch { case len(this.NS) == 0: - return fmt.Sprintf("USE DB %v", this.DB) + return print("USE DATABASE %v", quote(this.DB)) case len(this.DB) == 0: - return fmt.Sprintf("USE NS %v", this.NS) + return print("USE NAMESPACE %v", quote(this.NS)) default: - return fmt.Sprintf("USE NS %v DB %v", this.NS, this.DB) + return print("USE NAMESPACE %v DATABASE %v", quote(this.NS), quote(this.DB)) } } func (this InfoStatement) String() string { switch this.Kind { case NAMESPACE: - return fmt.Sprintf("INFO FOR NAMESPACE") + return "INFO FOR NAMESPACE" case DATABASE: - return fmt.Sprintf("INFO FOR DATABASE") + return "INFO FOR DATABASE" default: - return fmt.Sprintf("INFO FOR TABLE %v", this.What) + return print("INFO FOR TABLE %s", this.What) } } func (this LetStatement) String() string { - return fmt.Sprintf("LET %v = %v", + return print("LET %v = %v", this.Name, this.What, ) } func (this ReturnStatement) String() string { - return fmt.Sprintf("RETURN %v", + return print("RETURN %v", this.What, ) } +func (this LiveStatement) String() string { + return print("LIVE SELECT %v%v FROM %v%v", + maybe(this.Diff, "DIFF"), + this.Expr, + this.What, + maybe(this.Cond != nil, print(" WHERE %v", this.Cond)), + ) +} + +func (this KillStatement) String() string { + return print("KILL %v", + this.Name, + ) +} + func (this SelectStatement) String() string { - return fmt.Sprintf("SELECT %v FROM %v%v%v%v%v%v%v%v", + return print("SELECT %v FROM %v%v%v%v%v%v%v%v", this.Expr, this.What, - stringFromInterface(this.Cond, fmt.Sprintf(" WHERE %v", this.Cond), ""), + maybe(this.Cond != nil, print(" WHERE %v", this.Cond)), this.Group, this.Order, - stringFromInterface(this.Limit, fmt.Sprintf(" LIMIT %v", this.Limit), ""), - stringFromInterface(this.Start, fmt.Sprintf(" START %v", this.Start), ""), - stringFromInterface(this.Version, fmt.Sprintf(" VERSION %v", this.Version), ""), - stringFromDuration(this.Timeout, fmt.Sprintf(" TIMEOUT %v", this.Timeout.String()), ""), + maybe(this.Limit != nil, print(" LIMIT %v", this.Limit)), + maybe(this.Start != nil, print(" START %v", this.Start)), + maybe(this.Version != nil, print(" VERSION %v", this.Version)), + maybe(this.Timeout > 0, print(" TIMEOUT %v", this.Timeout.String())), ) } func (this CreateStatement) String() string { - return fmt.Sprintf("CREATE %v%v RETURN %v%v", + return print("CREATE %v%v%v%v", this.What, - this.Data, - this.Echo, - stringFromDuration(this.Timeout, fmt.Sprintf(" TIMEOUT %v", this.Timeout.String()), ""), + maybe(this.Data != nil, print("%v", this.Data)), + maybe(this.Echo != AFTER, print(" RETURN %v", this.Echo)), + maybe(this.Timeout > 0, print(" TIMEOUT %v", this.Timeout.String())), ) } func (this UpdateStatement) String() string { - return fmt.Sprintf("CREATE %v%v%v RETURN %v%v", + return print("UPDATE %v%v%v%v%v", this.What, - this.Data, - this.Cond, - this.Echo, - stringFromDuration(this.Timeout, fmt.Sprintf(" TIMEOUT %v", this.Timeout.String()), ""), + maybe(this.Data != nil, print("%v", this.Data)), + maybe(this.Cond != nil, print(" WHERE %v", this.Cond)), + maybe(this.Echo != AFTER, print(" RETURN %v", this.Echo)), + maybe(this.Timeout > 0, print(" TIMEOUT %v", this.Timeout.String())), ) } func (this DeleteStatement) String() string { - return fmt.Sprintf("DELETE %v%v%v RETURN %v%v", - stringFromBool(this.Hard, "AND EXPUNGE ", ""), + return print("DELETE %v%v%v%v%v", + maybe(this.Hard, "AND EXPUNGE "), this.What, - this.Cond, - this.Echo, - stringFromDuration(this.Timeout, fmt.Sprintf(" TIMEOUT %v", this.Timeout.String()), ""), + maybe(this.Cond != nil, print(" WHERE %v", this.Cond)), + maybe(this.Echo != NONE, print(" RETURN %v", this.Echo)), + maybe(this.Timeout > 0, print(" TIMEOUT %v", this.Timeout.String())), ) } func (this RelateStatement) String() string { - return fmt.Sprintf("RELATE %v FROM %v WITH %v%v%v RETURN %v%v", + return print("RELATE %v FROM %v WITH %v%v%v%v%v", this.Type, this.From, this.With, + maybe(this.Data != nil, print("%v", this.Data)), + maybe(this.Uniq, " UNIQUE"), + maybe(this.Echo != AFTER, print(" RETURN %v", this.Echo)), + maybe(this.Timeout > 0, print(" TIMEOUT %v", this.Timeout.String())), + ) +} + +func (this InsertStatement) String() string { + return print("INSERT %v INTO %v%v%v", this.Data, - stringFromBool(this.Uniq, " UNIQUE", ""), - this.Echo, - stringFromDuration(this.Timeout, fmt.Sprintf(" TIMEOUT %v", this.Timeout.String()), ""), + this.Into, + maybe(this.Echo != AFTER, print(" RETURN %v", this.Echo)), + maybe(this.Timeout > 0, print(" TIMEOUT %v", this.Timeout.String())), + ) +} + +func (this UpsertStatement) String() string { + return print("UPSERT %v INTO %v%v%v", + this.Data, + this.Into, + maybe(this.Echo != AFTER, print(" RETURN %v", this.Echo)), + maybe(this.Timeout > 0, print(" TIMEOUT %v", this.Timeout.String())), ) } func (this DefineNamespaceStatement) String() string { - return fmt.Sprintf("DEFINE NAMESPACE %v", + return print("DEFINE NAMESPACE %v", this.Name, ) } func (this RemoveNamespaceStatement) String() string { - return fmt.Sprintf("REMOVE NAMESPACE %v", + return print("REMOVE NAMESPACE %v", this.Name, ) } func (this DefineDatabaseStatement) String() string { - return fmt.Sprintf("DEFINE DATABASE %v", + return print("DEFINE DATABASE %v", this.Name, ) } func (this RemoveDatabaseStatement) String() string { - return fmt.Sprintf("REMOVE DATABASE %v", + return print("REMOVE DATABASE %v", this.Name, ) } func (this DefineLoginStatement) String() string { - return fmt.Sprintf("DEFINE LOGIN %v ON %v PASSWORD ********", + return print("DEFINE LOGIN %v ON %v PASSWORD ********", this.User, this.Kind, ) } func (this RemoveLoginStatement) String() string { - return fmt.Sprintf("REMOVE LOGIN %v ON %v", + return print("REMOVE LOGIN %v ON %v", this.User, this.Kind, ) } func (this DefineTokenStatement) String() string { - return fmt.Sprintf("DEFINE TOKEN %v ON %v TYPE %v VALUE ********", + return print("DEFINE TOKEN %v ON %v TYPE %v VALUE ********", this.Name, this.Kind, this.Type, @@ -310,91 +316,93 @@ func (this DefineTokenStatement) String() string { } func (this RemoveTokenStatement) String() string { - return fmt.Sprintf("REMOVE TOKEN %v ON %v", + return print("REMOVE TOKEN %v ON %v", this.Name, this.Kind, ) } func (this DefineScopeStatement) String() string { - return fmt.Sprintf("DEFINE SCOPE %v SESSION %v SIGNUP AS (%v) SIGNIN AS (%v)", + return print("DEFINE SCOPE %v%v%v%v%v", this.Name, - this.Time, - this.Signup, - this.Signin, + maybe(this.Time > 0, print(" SESSION %v", this.Time)), + maybe(this.Signup != nil, print(" SIGNUP AS %v", this.Signup)), + maybe(this.Signin != nil, print(" SIGNIN AS %v", this.Signin)), + maybe(this.Connect != nil, print(" CONNECT AS %v", this.Connect)), ) } func (this RemoveScopeStatement) String() string { - return fmt.Sprintf("REMOVE SCOPE %v", + return print("REMOVE SCOPE %v", this.Name, ) } -func (this DefineTableStatement) String() string { - return fmt.Sprintf("DEFINE TABLE %v%v%v", - this.What, - stringFromBool(this.Full, " SCHEMAFULL", " SCHEMALESS"), - stringIf(this.Perm != nil, this.Perm), +func (this DefineTableStatement) String() (s string) { + w := maybe(this.Cond != nil, print(" WHERE %v", this.Cond)) + return print("DEFINE TABLE %v%v%v%v%v", + maybe(this.Name != nil, print("%s", this.Name), print("%s", this.What)), + maybe(this.Full, " SCHEMAFULL"), + maybe(this.Drop, " DROP"), + maybe(this.Lock, print(" AS SELECT %v FROM %v%v%v", this.Expr, this.From, w, this.Group)), + maybe(this.Perms != nil, this.Perms), ) } func (this RemoveTableStatement) String() string { - return fmt.Sprintf("REMOVE TABLE %v", + return print("REMOVE TABLE %v", + this.What, + ) +} + +func (this DefineEventStatement) String() string { + return print("DEFINE EVENT %v ON %v WHEN %v THEN %v", + this.Name, + this.What, + this.When, + this.Then, + ) +} + +func (this RemoveEventStatement) String() string { + return print("REMOVE EVENT %v ON %v", + this.Name, this.What, ) } func (this DefineFieldStatement) String() string { - return fmt.Sprintf("DEFINE FIELD %v ON %v TYPE %v%v%v%v%v%v%v%v%v%v%v%v", + return print("DEFINE FIELD %v ON %v%v%v%v%v%v", this.Name, this.What, - this.Type, - stringFromFloat(this.Min, fmt.Sprintf(" MIN %v", this.Min), ""), - stringFromFloat(this.Max, fmt.Sprintf(" MAX %v", this.Max), ""), - stringFromArray(this.Enum, fmt.Sprintf(" ENUM %v", this.Enum), ""), - stringFromString(this.Code, fmt.Sprintf(" CODE \"%v\"", this.Code), ""), - stringFromString(this.Match, fmt.Sprintf(" MATCH /%v/", this.Match), ""), - stringFromInterface(this.Default, fmt.Sprintf(" DEFAULT %v", this.Default), ""), - stringFromBool(this.Notnull, " NOTNULL", ""), - stringFromBool(this.Readonly, " READONLY", ""), - stringFromBool(this.Validate, " VALIDATE", ""), - stringFromBool(this.Mandatory, " MANDATORY", ""), - stringIf(this.Perm != nil, this.Perm), + maybe(this.Type != "", print(" TYPE %v", this.Type)), + maybe(this.Kind != "", print(" (%v)", this.Kind)), + maybe(this.Value != nil, print(" VALUE %v", this.Value)), + maybe(this.Assert != nil, print(" ASSERT %v", this.Assert)), + maybe(this.Perms != nil, this.Perms), ) } func (this RemoveFieldStatement) String() string { - return fmt.Sprintf("REMOVE FIELD %v ON %v", + return print("REMOVE FIELD %v ON %v", this.Name, this.What, ) } func (this DefineIndexStatement) String() string { - return fmt.Sprintf("DEFINE INDEX %v ON %v COLUMNS %v%v", + return print("DEFINE INDEX %v ON %v COLUMNS %v%v", this.Name, this.What, this.Cols, - stringFromBool(this.Uniq, " UNIQUE", ""), + maybe(this.Uniq, " UNIQUE"), ) } func (this RemoveIndexStatement) String() string { - return fmt.Sprintf("REMOVE INDEX %v", - this.Name, - ) -} - -func (this DefineViewStatement) String() string { - return fmt.Sprintf("DEFINE VIEW %v", - this.Name, - ) -} - -func (this RemoveViewStatement) String() string { - return fmt.Sprintf("REMOVE VIEW %v", + return print("REMOVE INDEX %v ON %v", this.Name, + this.What, ) } @@ -403,9 +411,9 @@ func (this RemoveViewStatement) String() string { // --------------------------------------------- func (this Exprs) String() string { - var m []string - for _, v := range this { - m = append(m, fmt.Sprintf("%v", v)) + m := make([]string, len(this)) + for k, v := range this { + m[k] = print("%v", v) } return strings.Join(m, ", ") } @@ -418,18 +426,6 @@ func (this Any) String() string { return "?" } -func (this Asc) String() string { - return "ASC" -} - -func (this Desc) String() string { - return "DESC" -} - -func (this Null) String() string { - return "NULL" -} - func (this Void) String() string { return "VOID" } @@ -438,34 +434,24 @@ func (this Empty) String() string { return "EMPTY" } -func (this Array) String() string { - out, _ := json.Marshal(this) - return string(out) -} - -func (this Object) String() string { - out, _ := json.Marshal(this) - return string(out) -} - // --------------------------------------------- // Field // --------------------------------------------- func (this Fields) String() string { - var m []string - for _, v := range this { - m = append(m, v.String()) + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() } - return fmt.Sprintf("%v", + return print("%v", strings.Join(m, ", "), ) } func (this Field) String() string { - return fmt.Sprintf("%v%v", + return print("%v%v", this.Expr, - stringFromIdent(this.Alias, fmt.Sprintf(" AS %v", this.Alias), ""), + maybe(this.Alias != "", print(" AS %s", quote(this.Alias))), ) } @@ -477,17 +463,17 @@ func (this Groups) String() string { if len(this) == 0 { return "" } - var m []string - for _, v := range this { - m = append(m, v.String()) + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() } - return fmt.Sprintf(" GROUP BY %v", + return print(" GROUP BY %v", strings.Join(m, ", "), ) } func (this Group) String() string { - return fmt.Sprintf("%v", + return print("%v", this.Expr, ) } @@ -500,36 +486,57 @@ func (this Orders) String() string { if len(this) == 0 { return "" } - var m []string - for _, v := range this { - m = append(m, v.String()) + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() } - return fmt.Sprintf(" ORDER BY %v", + return print(" ORDER BY %v", strings.Join(m, ", "), ) } func (this Order) String() string { - return fmt.Sprintf("%v %v", + return print("%v %v", this.Expr, this.Dir, ) } +// --------------------------------------------- +// Model +// --------------------------------------------- + +func (this Model) String() string { + switch { + case this.INC == 0: + max := strconv.FormatFloat(this.MAX, 'f', -1, 64) + return print("|%s:%s|", quote(this.TB), max) + case this.INC == 1: + min := strconv.FormatFloat(this.MIN, 'f', -1, 64) + max := strconv.FormatFloat(this.MAX, 'f', -1, 64) + return print("|%s:%s..%s|", quote(this.TB), min, max) + default: + inc := strconv.FormatFloat(this.INC, 'f', -1, 64) + min := strconv.FormatFloat(this.MIN, 'f', -1, 64) + max := strconv.FormatFloat(this.MAX, 'f', -1, 64) + return print("|%s:%s,%s..%s|", quote(this.TB), min, inc, max) + } +} + // --------------------------------------------- // Param // --------------------------------------------- func (this Params) String() string { - var m []string - for _, v := range this { - m = append(m, v.String()) + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() } return strings.Join(m, ", ") } func (this Param) String() string { - return fmt.Sprintf("$%v", this.ID) + return print("$%v", this.ID) } // --------------------------------------------- @@ -537,15 +544,15 @@ func (this Param) String() string { // --------------------------------------------- func (this Values) String() string { - var m []string - for _, v := range this { - m = append(m, v.String()) + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() } return strings.Join(m, ", ") } func (this Value) String() string { - return fmt.Sprintf("\"%v\"", this.ID) + return print("\"%v\"", this.ID) } // --------------------------------------------- @@ -553,23 +560,15 @@ func (this Value) String() string { // --------------------------------------------- func (this Idents) String() string { - var m []string - for _, v := range this { - m = append(m, v.String()) + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() } return strings.Join(m, ", ") } func (this Ident) String() string { - switch newToken(this.ID) { - case ILLEGAL: - if toQuote(this.ID) { - return fmt.Sprintf("`%v`", this.ID) - } - return fmt.Sprintf("%v", this.ID) - default: - return fmt.Sprintf("`%v`", this.ID) - } + return quote(this.ID) } // --------------------------------------------- @@ -577,23 +576,31 @@ func (this Ident) String() string { // --------------------------------------------- func (this Tables) String() string { - var m []string - for _, v := range this { - m = append(m, v.String()) + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() } return strings.Join(m, ", ") } func (this Table) String() string { - switch newToken(this.TB) { - case ILLEGAL: - if toQuote(this.TB) { - return fmt.Sprintf("`%v`", this.TB) - } - return fmt.Sprintf("%v", this.TB) - default: - return fmt.Sprintf("`%v`", this.TB) + return quote(this.TB) +} + +// --------------------------------------------- +// Batch +// --------------------------------------------- + +func (this Batchs) String() string { + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() } + return strings.Join(m, ", ") +} + +func (this Batch) String() string { + return print("batch(%v, [%v]", this.TB, this.BA) } // --------------------------------------------- @@ -601,23 +608,106 @@ func (this Table) String() string { // --------------------------------------------- func (this Things) String() string { - var m []string - for _, v := range this { - m = append(m, v.String()) + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() } return strings.Join(m, ", ") } func (this Thing) String() string { tb := this.TB - if toQuote(fmt.Sprint(this.TB)) { - tb = fmt.Sprintf("{%v}", this.TB) + if toQuote(this.TB) { + tb = print("⟨%v⟩", this.TB) } id := this.ID - if toQuote(fmt.Sprint(this.ID)) { - id = fmt.Sprintf("{%v}", this.ID) + switch v := this.ID.(type) { + case int64: + id = strconv.FormatInt(v, 10) + case float64: + id = strconv.FormatFloat(v, 'f', -1, 64) + case time.Time: + id = print("⟨%v⟩", v.Format(RFCNano)) + case string: + if toQuote(v) { + id = print("⟨%v⟩", v) + } + default: + if toQuote(fmt.Sprint(v)) { + id = print("⟨%v⟩", v) + } } - return fmt.Sprintf("@%v:%v", tb, id) + return print("%v:%v", tb, id) +} + +// --------------------------------------------- +// Point +// --------------------------------------------- + +func (this Points) String() string { + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() + } + return strings.Join(m, ", ") +} + +func (this Point) String() string { + return print("geo.point(%v,%v)", this.LA, this.LO) +} + +func (this Point) JSON() string { + return fmt.Sprintf(`[%v,%v]`, this.LA, this.LO) +} + +// --------------------------------------------- +// Circle +// --------------------------------------------- + +func (this Circles) String() string { + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() + } + return strings.Join(m, ", ") +} + +func (this Circle) String() string { + return print("geo.circle(%v,%v)", this.CE, this.RA) +} + +func (this Circle) JSON() string { + return fmt.Sprintf(`{"type":"circle","center":%v,"radius":%v}`, this.CE.JSON(), this.RA) +} + +// --------------------------------------------- +// Polygon +// --------------------------------------------- + +func (this Polygons) String() string { + m := make([]string, len(this)) + for k, v := range this { + m[k] = v.String() + } + return strings.Join(m, ", ") +} + +func (this Polygon) String() string { + var m []string + for _, v := range this.PS { + m = append(m, v.String()) + } + return print("geo.polygon(%v)", + strings.Join(m, ", "), + ) +} + +func (this Polygon) JSON() string { + var m []string + for _, p := range this.PS { + m = append(m, p.JSON()) + } + return fmt.Sprintf(`{"type":"polygon","points":[%v]}`, strings.Join(m, ",")) } // --------------------------------------------- @@ -625,19 +715,28 @@ func (this Thing) String() string { // --------------------------------------------- func (this SubExpression) String() string { - return fmt.Sprintf("(%v)", + return print("(%v)", this.Expr, ) } +func (this IfelExpression) String() string { + return print("IF %v THEN %v%v", + this.Cond, + this.Then, + maybe(this.Else != nil, print("ELSE %v END", this.Else)), + ) +} + func (this FuncExpression) String() string { - return fmt.Sprintf("%v()", + return print("%v(%v)", this.Name, + this.Args, ) } func (this ItemExpression) String() string { - return fmt.Sprintf("%v %v %v", + return print("%v %v %v", this.LHS, this.Op, this.RHS, @@ -645,9 +744,9 @@ func (this ItemExpression) String() string { } func (this BinaryExpression) String() string { - return fmt.Sprintf("%v%v%v", + return print("%v %v %v", this.LHS, - padToken(this.Op), + this.Op, this.RHS, ) } @@ -655,28 +754,28 @@ func (this BinaryExpression) String() string { func (this PathExpression) String() string { var m []string for _, v := range this.Expr { - m = append(m, fmt.Sprintf("%v", v)) + m = append(m, print("%v", v)) } return strings.Join(m, "") } func (this PartExpression) String() string { - return fmt.Sprintf("%v", + return print("%v", this.Part, ) } func (this JoinExpression) String() string { - return fmt.Sprintf("%v", + return print("%v", this.Join, ) } func (this SubpExpression) String() string { - return fmt.Sprintf("(%v%v%v)", + return print("(%v%v%v)", this.What, - stringFromIdent(this.Name, fmt.Sprintf(" AS %v", this.Name), ""), - stringFromInterface(this.Cond, fmt.Sprintf(" WHERE %v", this.Cond), ""), + maybe(this.Name != nil, print(" AS %v", this.Name)), + maybe(this.Cond != nil, print(" WHERE %v", this.Cond)), ) } @@ -685,91 +784,86 @@ func (this DataExpression) String() string { for _, v := range this.Data { m = append(m, v.String()) } - return fmt.Sprintf(" SET %v", + return print(" SET %v", strings.Join(m, ", "), ) } func (this DiffExpression) String() string { - return fmt.Sprintf(" DIFF %v", + return print(" DIFF %v", this.Data, ) } func (this MergeExpression) String() string { - return fmt.Sprintf(" MERGE %v", + return print(" MERGE %v", this.Data, ) } func (this ContentExpression) String() string { - return fmt.Sprintf(" CONTENT %v", + return print(" CONTENT %v", this.Data, ) } func (this PermExpression) String() string { - var s, c, u, d, r string + var k, o string - p := map[bool][]string{} + a := []string{} + m := map[string]methods{} if v, ok := this.Select.(bool); ok { - s = stringFromBool(v, "FULL", "NONE") - p[v] = append(p[v], fmt.Sprintf("select")) + k = maybe(v, "FULL", "NONE") + m[k] = append(m[k], _select) } else { - s = fmt.Sprintf("WHERE %v", this.Select) + k = print("WHERE %v", this.Select) + m[k] = append(m[k], _select) } if v, ok := this.Create.(bool); ok { - c = stringFromBool(v, "FULL", "NONE") - p[v] = append(p[v], fmt.Sprintf("create")) + k = maybe(v, "FULL", "NONE") + m[k] = append(m[k], _create) } else { - c = fmt.Sprintf("WHERE %v", this.Create) + k = print("WHERE %v", this.Create) + m[k] = append(m[k], _create) } if v, ok := this.Update.(bool); ok { - u = stringFromBool(v, "FULL", "NONE") - p[v] = append(p[v], fmt.Sprintf("update")) + k = maybe(v, "FULL", "NONE") + m[k] = append(m[k], _update) } else { - u = fmt.Sprintf("WHERE %v", this.Update) + k = print("WHERE %v", this.Update) + m[k] = append(m[k], _update) } if v, ok := this.Delete.(bool); ok { - d = stringFromBool(v, "FULL", "NONE") - p[v] = append(p[v], fmt.Sprintf("delete")) + k = maybe(v, "FULL", "NONE") + m[k] = append(m[k], _delete) } else { - d = fmt.Sprintf("WHERE %v", this.Delete) + k = print("WHERE %v", this.Delete) + m[k] = append(m[k], _delete) } - if v, ok := this.Relate.(bool); ok { - r = stringFromBool(v, "FULL", "NONE") - p[v] = append(p[v], fmt.Sprintf("relate")) - } else { - r = fmt.Sprintf("WHERE %v", this.Relate) + if len(m) == 1 { + for k := range m { + return print(" PERMISSIONS %v", k) + } } - if len(p[true]) == 5 { - return fmt.Sprintf(" PERMISSIONS FULL") + for k := range m { + a = append(a, k) } - if len(p[false]) == 5 { - return fmt.Sprintf(" PERMISSIONS NONE") + sort.Slice(a, func(i, j int) bool { + return m[a[i]][0] < m[a[j]][0] + }) + + for _, v := range a { + o += print(" FOR %v %v", m[v], v) } - if len(p[true])+len(p[false]) == 5 { - return fmt.Sprintf(" PERMISSIONS FOR %v FULL FOR %v NONE", - strings.Join(p[true], ", "), - strings.Join(p[false], ", "), - ) - } - - return fmt.Sprintf(" PERMISSIONS%v%v%v%v%v", - fmt.Sprintf(" FOR select %v", s), - fmt.Sprintf(" FOR create %v", c), - fmt.Sprintf(" FOR update %v", u), - fmt.Sprintf(" FOR delete %v", d), - fmt.Sprintf(" FOR relate %v", r), - ) + return print(" PERMISSIONS%v", o) } diff --git a/sql/table.go b/sql/table.go index 6e293540..87449f93 100644 --- a/sql/table.go +++ b/sql/table.go @@ -16,7 +16,7 @@ package sql func (p *parser) parseDefineTableStatement() (stmt *DefineTableStatement, err error) { - stmt = &DefineTableStatement{} + stmt = &DefineTableStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { return nil, err @@ -28,11 +28,15 @@ func (p *parser) parseDefineTableStatement() (stmt *DefineTableStatement, err er for { - tok, _, exi := p.mightBe(SCHEMAFULL, SCHEMALESS, PERMISSIONS) + tok, _, exi := p.mightBe(DROP, SCHEMAFULL, SCHEMALESS, PERMISSIONS, AS) if !exi { break } + if p.is(tok, DROP) { + stmt.Drop = true + } + if p.is(tok, SCHEMAFULL) { stmt.Full = true } @@ -42,15 +46,51 @@ func (p *parser) parseDefineTableStatement() (stmt *DefineTableStatement, err er } if p.is(tok, PERMISSIONS) { - if stmt.Perm, err = p.parsePerms(); err != nil { + if stmt.Perms, err = p.parsePerms(); err != nil { return nil, err } } - } + if p.is(tok, AS) { + + stmt.Lock = true + + _, _, _ = p.mightBe(LPAREN) + + _, _, err = p.shouldBe(SELECT) + if err != nil { + return nil, err + } + + if stmt.Expr, err = p.parseFields(); err != nil { + return nil, err + } + + _, _, err = p.shouldBe(FROM) + if err != nil { + return nil, err + } + + if stmt.From, err = p.parseTables(); err != nil { + return nil, err + } + + if stmt.Cond, err = p.parseCond(); err != nil { + return nil, err + } + + if stmt.Group, err = p.parseGroup(); err != nil { + return nil, err + } + + _, _, _ = p.mightBe(RPAREN) + + if err = checkExpression(rolls, stmt.Expr, stmt.Group); err != nil { + return nil, err + } + + } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err } return @@ -59,7 +99,7 @@ func (p *parser) parseDefineTableStatement() (stmt *DefineTableStatement, err er func (p *parser) parseRemoveTableStatement() (stmt *RemoveTableStatement, err error) { - stmt = &RemoveTableStatement{} + stmt = &RemoveTableStatement{RW: true} if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil { return nil, err @@ -69,10 +109,6 @@ func (p *parser) parseRemoveTableStatement() (stmt *RemoveTableStatement, err er return nil, err } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/token.go b/sql/token.go index 6998db91..1c6cb80b 100644 --- a/sql/token.go +++ b/sql/token.go @@ -16,7 +16,7 @@ package sql func (p *parser) parseDefineTokenStatement() (stmt *DefineTokenStatement, err error) { - stmt = &DefineTokenStatement{} + stmt = &DefineTokenStatement{RW: true} if stmt.Name, err = p.parseIdent(); err != nil { return nil, err @@ -70,15 +70,11 @@ func (p *parser) parseDefineTokenStatement() (stmt *DefineTokenStatement, err er } if stmt.Type == "" { - return nil, &ParseError{Found: ";", Expected: []string{"TYPE"}} + return nil, &ParseError{Found: "", Expected: []string{"TYPE"}} } - if stmt.Code == nil { - return nil, &ParseError{Found: ";", Expected: []string{"VALUE"}} - } - - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err + if len(stmt.Code) == 0 { + return nil, &ParseError{Found: "", Expected: []string{"VALUE"}} } return @@ -87,7 +83,7 @@ func (p *parser) parseDefineTokenStatement() (stmt *DefineTokenStatement, err er func (p *parser) parseRemoveTokenStatement() (stmt *RemoveTokenStatement, err error) { - stmt = &RemoveTokenStatement{} + stmt = &RemoveTokenStatement{RW: true} if stmt.Name, err = p.parseIdent(); err != nil { return nil, err @@ -119,10 +115,6 @@ func (p *parser) parseRemoveTokenStatement() (stmt *RemoveTokenStatement, err er } } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/tokens.go b/sql/tokens.go index e8deec32..c8c96f70 100644 --- a/sql/tokens.go +++ b/sql/tokens.go @@ -91,26 +91,26 @@ const ( operatorEnd - // literals + // keywords keywordsBeg - ACCEPT AFTER - ALL ALLCONTAINEDIN AND AS ASC + ASSERT AT BEFORE BEGIN BOTH BY CANCEL - CODE + COLLATE COLUMNS COMMIT + CONNECT CONTAINS CONTAINSALL CONTAINSNONE @@ -119,15 +119,15 @@ const ( CREATE DATABASE DB - DEFAULT DEFINE DELETE DESC DIFF - DISTINCT + DROP + ELSE EMPTY - ENUM - EXISTS + END + EVENT EXPUNGE FALSE FIELD @@ -135,38 +135,34 @@ const ( FROM FULL GROUP - ID IF IN INDEX INFO + INSERT + INTO IS + KILL LET LIMIT LIVE LOGIN - MANDATORY - MATCH - MAX MERGE - MIN MISSING NAMESPACE NONE NONECONTAINEDIN NOT NOTNULL - NOW NS NULL - OFFSET + NUMERIC ON OR ORDER PASSWORD PERMISSIONS - READONLY - REJECT + RAND RELATE REMOVE RETURN @@ -181,6 +177,7 @@ const ( SOMECONTAINEDIN START TABLE + THEN TIMEOUT TO TOKEN @@ -191,11 +188,10 @@ const ( UPDATE UPSERT USE - VALIDATE VALUE VERSION - VIEW VOID + WHEN WHERE WITH @@ -266,22 +262,22 @@ var tokens = [...]string{ // keywords - ACCEPT: "ACCEPT", AFTER: "AFTER", - ALL: "ALL", ALLCONTAINEDIN: "ALLCONTAINEDIN", AND: "AND", AS: "AS", ASC: "ASC", + ASSERT: "ASSERT", AT: "AT", BEFORE: "BEFORE", BEGIN: "BEGIN", BOTH: "BOTH", BY: "BY", CANCEL: "CANCEL", - CODE: "CODE", + COLLATE: "COLLATE", COLUMNS: "COLUMNS", COMMIT: "COMMIT", + CONNECT: "CONNECT", CONTAINS: "CONTAINS", CONTAINSALL: "CONTAINSALL", CONTAINSNONE: "CONTAINSNONE", @@ -290,15 +286,15 @@ var tokens = [...]string{ CREATE: "CREATE", DATABASE: "DATABASE", DB: "DB", - DEFAULT: "DEFAULT", DEFINE: "DEFINE", DELETE: "DELETE", DESC: "DESC", DIFF: "DIFF", - DISTINCT: "DISTINCT", + DROP: "DROP", + ELSE: "ELSE", EMPTY: "EMPTY", - ENUM: "ENUM", - EXISTS: "EXISTS", + END: "END", + EVENT: "EVENT", EXPUNGE: "EXPUNGE", FALSE: "FALSE", FIELD: "FIELD", @@ -306,37 +302,34 @@ var tokens = [...]string{ FROM: "FROM", FULL: "FULL", GROUP: "GROUP", - ID: "ID", IF: "IF", IN: "IN", INDEX: "INDEX", INFO: "INFO", + INSERT: "INSERT", + INTO: "INTO", IS: "IS", + KILL: "KILL", LET: "LET", LIMIT: "LIMIT", LIVE: "LIVE", LOGIN: "LOGIN", - MANDATORY: "MANDATORY", - MATCH: "MATCH", - MAX: "MAX", MERGE: "MERGE", - MIN: "MIN", MISSING: "MISSING", NAMESPACE: "NAMESPACE", NONE: "NONE", NONECONTAINEDIN: "NONECONTAINEDIN", NOT: "NOT", NOTNULL: "NOTNULL", - NOW: "NOW", NS: "NS", NULL: "NULL", + NUMERIC: "NUMERIC", ON: "ON", OR: "OR", ORDER: "ORDER", PASSWORD: "PASSWORD", PERMISSIONS: "PERMISSIONS", - READONLY: "READONLY", - REJECT: "REJECT", + RAND: "RAND", RELATE: "RELATE", REMOVE: "REMOVE", RETURN: "RETURN", @@ -351,6 +344,7 @@ var tokens = [...]string{ SOMECONTAINEDIN: "SOMECONTAINEDIN", START: "START", TABLE: "TABLE", + THEN: "THEN", TIMEOUT: "TIMEOUT", TO: "TO", TOKEN: "TOKEN", @@ -361,11 +355,10 @@ var tokens = [...]string{ UPDATE: "UPDATE", UPSERT: "UPSERT", USE: "USE", - VALIDATE: "VALIDATE", VALUE: "VALUE", VERSION: "VERSION", - VIEW: "VIEW", VOID: "VOID", + WHEN: "WHEN", WHERE: "WHERE", WITH: "WITH", } @@ -430,10 +423,12 @@ func (tok Token) String() string { return "" } -func newToken(str string) Token { +func newToken(s string) Token { for k, v := range tokens { - if v == strings.ToUpper(str) { - return Token(k) + if len(v) == len(s) { + if strings.EqualFold(v, s) { + return Token(k) + } } } return ILLEGAL diff --git a/sql/trans.go b/sql/trans.go index 48f587eb..3548c78d 100644 --- a/sql/trans.go +++ b/sql/trans.go @@ -20,10 +20,6 @@ func (p *parser) parseBeginStatement() (stmt *BeginStatement, err error) { _, _, _ = p.mightBe(TRANSACTION) - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - p.buf.txn = true return @@ -36,10 +32,6 @@ func (p *parser) parseCancelStatement() (stmt *CancelStatement, err error) { _, _, _ = p.mightBe(TRANSACTION) - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - p.buf.txn = false return @@ -52,10 +44,6 @@ func (p *parser) parseCommitStatement() (stmt *CommitStatement, err error) { _, _, _ = p.mightBe(TRANSACTION) - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - p.buf.txn = false return diff --git a/sql/update.go b/sql/update.go index 8cefdf21..e2ba45e5 100644 --- a/sql/update.go +++ b/sql/update.go @@ -16,19 +16,12 @@ package sql func (p *parser) parseUpdateStatement() (stmt *UpdateStatement, err error) { - stmt = &UpdateStatement{} + stmt = &UpdateStatement{RW: true} - if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthSC); err != nil { + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil { return nil, err } - if _, _, exi := p.mightBe(AND); exi { - if _, _, err = p.shouldBe(UPSERT); err != nil { - return nil, err - } - stmt.Hard = true - } - if stmt.What, err = p.parseWhat(); err != nil { return nil, err } @@ -49,10 +42,6 @@ func (p *parser) parseUpdateStatement() (stmt *UpdateStatement, err error) { return nil, err } - if _, _, err = p.shouldBe(EOF, RPAREN, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/upsert.go b/sql/upsert.go new file mode 100644 index 00000000..7e33fffb --- /dev/null +++ b/sql/upsert.go @@ -0,0 +1,49 @@ +// Copyright © 2016 Abcum Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sql + +func (p *parser) parseUpsertStatement() (stmt *UpsertStatement, err error) { + + stmt = &UpsertStatement{RW: true} + + if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil { + return nil, err + } + + if stmt.Data, err = p.parseExpr(); err != nil { + return nil, err + } + + if _, _, err = p.shouldBe(INTO); err != nil { + return nil, err + } + + _, _, _ = p.mightBe(TABLE) + + if stmt.Into, err = p.parseTable(); err != nil { + return nil, err + } + + if stmt.Echo, err = p.parseEcho(AFTER); err != nil { + return nil, err + } + + if stmt.Timeout, err = p.parseTimeout(); err != nil { + return nil, err + } + + return + +} diff --git a/sql/use.go b/sql/use.go index b21a2065..b6eea78d 100644 --- a/sql/use.go +++ b/sql/use.go @@ -21,22 +21,27 @@ func (p *parser) parseUseStatement() (stmt *UseStatement, err error) { var tok Token var exi bool - tok, _, err = p.shouldBe(NAMESPACE, NS, DATABASE, DB) + if p.buf.txn { + return nil, &TransError{} + } + + tok, _, err = p.shouldBe(NAMESPACE, DATABASE, NS, DB) if err != nil { return nil, err } for { - var val *Ident - if p.is(tok, NAMESPACE, NS) { - if val, err = p.parseIdent(); err != nil { - return nil, err + _, stmt.NS, err = p.shouldBe(IDENT, STRING, NUMBER, DOUBLE, DATE, TIME) + if err != nil { + return } - stmt.NS = val.ID + if len(stmt.NS) == 0 { + return nil, &ParseError{Expected: []string{"namespace name"}, Found: stmt.NS} + } if err = p.o.ns(stmt.NS); err != nil { return nil, err @@ -46,11 +51,14 @@ func (p *parser) parseUseStatement() (stmt *UseStatement, err error) { if p.is(tok, DATABASE, DB) { - if val, err = p.parseIdent(); err != nil { - return nil, err + _, stmt.DB, err = p.shouldBe(IDENT, STRING, NUMBER, DOUBLE, DATE, TIME) + if err != nil { + return } - stmt.DB = val.ID + if len(stmt.DB) == 0 { + return nil, &ParseError{Expected: []string{"database name"}, Found: stmt.DB} + } if err = p.o.db(stmt.DB); err != nil { return nil, err @@ -65,10 +73,6 @@ func (p *parser) parseUseStatement() (stmt *UseStatement, err error) { } - if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil { - return nil, err - } - return } diff --git a/sql/util.go b/sql/util.go index a437c536..05da7c02 100644 --- a/sql/util.go +++ b/sql/util.go @@ -18,6 +18,7 @@ import ( "fmt" "regexp" "strconv" + "strings" "time" json "github.com/hjson/hjson-go" @@ -67,15 +68,15 @@ func (p *parser) declare(tok Token, lit string) (interface{}, error) { switch tok { + case NULL: + return nil, nil + case TRUE: return true, nil case FALSE: return false, nil - case NULL: - return &Null{}, nil - case VOID: return &Void{}, nil @@ -91,19 +92,13 @@ func (p *parser) declare(tok Token, lit string) (interface{}, error) { case QMARK: return &Any{}, nil - case ASC: - return &Asc{}, nil - - case DESC: - return &Desc{}, nil - case STRING: return &Value{lit}, nil case REGION: return &Value{lit}, nil - case ID: + case EXPR: return &Ident{lit}, nil case IDENT: @@ -112,35 +107,50 @@ func (p *parser) declare(tok Token, lit string) (interface{}, error) { case TABLE: return &Table{lit}, nil - case NOW: - return time.Now().UTC(), nil + case PARAM: + return &Param{lit}, nil case DATE: - return time.Parse("2006-01-02", lit) + return time.Parse(RFCDate, lit) case TIME: - return time.Parse(time.RFC3339, lit) + return time.Parse(RFCTime, lit) case REGEX: return regexp.Compile(lit) case NUMBER: - return strconv.ParseInt(lit, 10, 64) + val, err := strconv.ParseFloat(lit, 64) + if err != nil { + return val, fmt.Errorf("Invalid number: %s", lit) + } + return val, nil case DOUBLE: - return strconv.ParseFloat(lit, 64) + val, err := strconv.ParseFloat(lit, 64) + if err != nil { + return val, fmt.Errorf("Invalid number: %s", lit) + } + return val, nil case DURATION: - return time.ParseDuration(lit) - - case PARAM: - if p, ok := p.v[lit]; ok { - return p, nil + var mul time.Duration + switch { + default: + mul = 1 + case strings.HasSuffix(lit, "d"): + mul, lit = 24, strings.Replace(lit, "d", "h", -1) + case strings.HasSuffix(lit, "w"): + mul, lit = 168, strings.Replace(lit, "w", "h", -1) } - return &Param{lit}, nil + val, err := time.ParseDuration(lit) + if err != nil { + return val, fmt.Errorf("Invalid duration: %s", lit) + } + return val * mul, nil case ARRAY: - var j Array + var j []interface{} json.Unmarshal([]byte(lit), &j) if j == nil { return j, fmt.Errorf("Invalid JSON: %s", lit) @@ -148,7 +158,7 @@ func (p *parser) declare(tok Token, lit string) (interface{}, error) { return j, nil case JSON: - var j Object + var j map[string]interface{} json.Unmarshal([]byte(lit), &j) if j == nil { return j, fmt.Errorf("Invalid JSON: %s", lit)