Enable SQL ASTs to self-encode and self-decode

This commit is contained in:
Tobie Morgan Hitchcock 2017-02-09 20:44:54 +00:00
parent 1fd450890b
commit dd230dca56

View file

@ -19,6 +19,7 @@ import (
"fmt" "fmt"
"github.com/abcum/cork" "github.com/abcum/cork"
"github.com/abcum/surreal/util/pack"
) )
// ################################################## // ##################################################
@ -762,6 +763,14 @@ func init() {
cork.Register(&LiveStatement{}) cork.Register(&LiveStatement{})
} }
func (this *LiveStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *LiveStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *LiveStatement) ExtendCORK() byte { func (this *LiveStatement) ExtendCORK() byte {
return 0x71 return 0x71
} }
@ -794,6 +803,14 @@ func init() {
cork.Register(&SelectStatement{}) cork.Register(&SelectStatement{})
} }
func (this *SelectStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *SelectStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *SelectStatement) ExtendCORK() byte { func (this *SelectStatement) ExtendCORK() byte {
return 0x72 return 0x72
} }
@ -836,6 +853,14 @@ func init() {
cork.Register(&CreateStatement{}) cork.Register(&CreateStatement{})
} }
func (this *CreateStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *CreateStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *CreateStatement) ExtendCORK() byte { func (this *CreateStatement) ExtendCORK() byte {
return 0x73 return 0x73
} }
@ -866,6 +891,14 @@ func init() {
cork.Register(&UpdateStatement{}) cork.Register(&UpdateStatement{})
} }
func (this *UpdateStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *UpdateStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *UpdateStatement) ExtendCORK() byte { func (this *UpdateStatement) ExtendCORK() byte {
return 0x74 return 0x74
} }
@ -900,6 +933,14 @@ func init() {
cork.Register(&DeleteStatement{}) cork.Register(&DeleteStatement{})
} }
func (this *DeleteStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *DeleteStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *DeleteStatement) ExtendCORK() byte { func (this *DeleteStatement) ExtendCORK() byte {
return 0x75 return 0x75
} }
@ -932,6 +973,14 @@ func init() {
cork.Register(&RelateStatement{}) cork.Register(&RelateStatement{})
} }
func (this *RelateStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *RelateStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *RelateStatement) ExtendCORK() byte { func (this *RelateStatement) ExtendCORK() byte {
return 0x76 return 0x76
} }
@ -968,6 +1017,14 @@ func init() {
cork.Register(&DefineNamespaceStatement{}) cork.Register(&DefineNamespaceStatement{})
} }
func (this *DefineNamespaceStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *DefineNamespaceStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *DefineNamespaceStatement) ExtendCORK() byte { func (this *DefineNamespaceStatement) ExtendCORK() byte {
return 0x77 return 0x77
} }
@ -994,6 +1051,14 @@ func init() {
cork.Register(&RemoveNamespaceStatement{}) cork.Register(&RemoveNamespaceStatement{})
} }
func (this *RemoveNamespaceStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *RemoveNamespaceStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *RemoveNamespaceStatement) ExtendCORK() byte { func (this *RemoveNamespaceStatement) ExtendCORK() byte {
return 0x78 return 0x78
} }
@ -1020,6 +1085,14 @@ func init() {
cork.Register(&DefineDatabaseStatement{}) cork.Register(&DefineDatabaseStatement{})
} }
func (this *DefineDatabaseStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *DefineDatabaseStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *DefineDatabaseStatement) ExtendCORK() byte { func (this *DefineDatabaseStatement) ExtendCORK() byte {
return 0x79 return 0x79
} }
@ -1046,6 +1119,14 @@ func init() {
cork.Register(&RemoveDatabaseStatement{}) cork.Register(&RemoveDatabaseStatement{})
} }
func (this *RemoveDatabaseStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *RemoveDatabaseStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *RemoveDatabaseStatement) ExtendCORK() byte { func (this *RemoveDatabaseStatement) ExtendCORK() byte {
return 0x80 return 0x80
} }
@ -1072,6 +1153,14 @@ func init() {
cork.Register(&DefineLoginStatement{}) cork.Register(&DefineLoginStatement{})
} }
func (this *DefineLoginStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *DefineLoginStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *DefineLoginStatement) ExtendCORK() byte { func (this *DefineLoginStatement) ExtendCORK() byte {
return 0x81 return 0x81
} }
@ -1104,6 +1193,14 @@ func init() {
cork.Register(&RemoveLoginStatement{}) cork.Register(&RemoveLoginStatement{})
} }
func (this *RemoveLoginStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *RemoveLoginStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *RemoveLoginStatement) ExtendCORK() byte { func (this *RemoveLoginStatement) ExtendCORK() byte {
return 0x82 return 0x82
} }
@ -1132,6 +1229,14 @@ func init() {
cork.Register(&DefineTokenStatement{}) cork.Register(&DefineTokenStatement{})
} }
func (this *DefineTokenStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *DefineTokenStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *DefineTokenStatement) ExtendCORK() byte { func (this *DefineTokenStatement) ExtendCORK() byte {
return 0x81 return 0x81
} }
@ -1164,6 +1269,14 @@ func init() {
cork.Register(&RemoveTokenStatement{}) cork.Register(&RemoveTokenStatement{})
} }
func (this *RemoveTokenStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *RemoveTokenStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *RemoveTokenStatement) ExtendCORK() byte { func (this *RemoveTokenStatement) ExtendCORK() byte {
return 0x82 return 0x82
} }
@ -1192,6 +1305,14 @@ func init() {
cork.Register(&DefineScopeStatement{}) cork.Register(&DefineScopeStatement{})
} }
func (this *DefineScopeStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *DefineScopeStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *DefineScopeStatement) ExtendCORK() byte { func (this *DefineScopeStatement) ExtendCORK() byte {
return 0x81 return 0x81
} }
@ -1226,6 +1347,14 @@ func init() {
cork.Register(&RemoveScopeStatement{}) cork.Register(&RemoveScopeStatement{})
} }
func (this *RemoveScopeStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *RemoveScopeStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *RemoveScopeStatement) ExtendCORK() byte { func (this *RemoveScopeStatement) ExtendCORK() byte {
return 0x82 return 0x82
} }
@ -1252,6 +1381,14 @@ func init() {
cork.Register(&DefineTableStatement{}) cork.Register(&DefineTableStatement{})
} }
func (this *DefineTableStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *DefineTableStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *DefineTableStatement) ExtendCORK() byte { func (this *DefineTableStatement) ExtendCORK() byte {
return 0x83 return 0x83
} }
@ -1280,6 +1417,14 @@ func init() {
cork.Register(&RemoveTableStatement{}) cork.Register(&RemoveTableStatement{})
} }
func (this *RemoveTableStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *RemoveTableStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *RemoveTableStatement) ExtendCORK() byte { func (this *RemoveTableStatement) ExtendCORK() byte {
return 0x84 return 0x84
} }
@ -1306,6 +1451,14 @@ func init() {
cork.Register(&DefineFieldStatement{}) cork.Register(&DefineFieldStatement{})
} }
func (this *DefineFieldStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *DefineFieldStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *DefineFieldStatement) ExtendCORK() byte { func (this *DefineFieldStatement) ExtendCORK() byte {
return 0x85 return 0x85
} }
@ -1356,6 +1509,14 @@ func init() {
cork.Register(&RemoveFieldStatement{}) cork.Register(&RemoveFieldStatement{})
} }
func (this *RemoveFieldStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *RemoveFieldStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *RemoveFieldStatement) ExtendCORK() byte { func (this *RemoveFieldStatement) ExtendCORK() byte {
return 0x86 return 0x86
} }
@ -1384,6 +1545,14 @@ func init() {
cork.Register(&DefineIndexStatement{}) cork.Register(&DefineIndexStatement{})
} }
func (this *DefineIndexStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *DefineIndexStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *DefineIndexStatement) ExtendCORK() byte { func (this *DefineIndexStatement) ExtendCORK() byte {
return 0x87 return 0x87
} }
@ -1416,6 +1585,14 @@ func init() {
cork.Register(&RemoveIndexStatement{}) cork.Register(&RemoveIndexStatement{})
} }
func (this *RemoveIndexStatement) Decode(src []byte) {
pack.Decode(src, &this)
}
func (this *RemoveIndexStatement) Encode() (dst []byte) {
return pack.Encode(this)
}
func (this *RemoveIndexStatement) ExtendCORK() byte { func (this *RemoveIndexStatement) ExtendCORK() byte {
return 0x88 return 0x88
} }
@ -1444,6 +1621,14 @@ func init() {
cork.Register(&DefineViewStatement{}) 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 { func (this *DefineViewStatement) ExtendCORK() byte {
return 0x89 return 0x89
} }
@ -1478,6 +1663,14 @@ func init() {
cork.Register(&RemoveViewStatement{}) 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 { func (this *RemoveViewStatement) ExtendCORK() byte {
return 0x90 return 0x90
} }