File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed
Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,12 @@ func init() {
2121}
2222
2323func Parse (s string ) (* types.SoqlQuery , error ) {
24+ meta := & types.SoqlQueryMeta {
25+ Version : "0.9" ,
26+ Date : time .Now ().UTC (),
27+ Source : s ,
28+ }
29+
2430 out , err := queryParser (* NewStringParserContext (s ))
2531 if err != nil {
2632 pos := GetLineAndColPosition (s , out .SourcePosition , 4 )
@@ -42,15 +48,14 @@ func Parse(s string) (*types.SoqlQuery, error) {
4248
4349 q := out .AstStack [0 ].Value .(types.SoqlQuery )
4450
45- q .Meta = & types.SoqlQueryMeta {
46- Version : "0.9" ,
47- Date : time .Now ().UTC (),
48- Source : s ,
49- }
51+ q .Meta = meta
5052
5153 if err := postprocess .Normalize (& q ); err != nil {
5254 return nil , err
5355 }
5456
57+ endDate := time .Now ()
58+ q .Meta .ElapsedTime = endDate .Sub (q .Meta .Date )
59+
5560 return & q , nil
5661}
Original file line number Diff line number Diff line change @@ -239,6 +239,11 @@ func TestParse2(t *testing.T) {
239239 return
240240 }
241241
242+ {
243+ s := got .Meta .ElapsedTime .String ()
244+ t .Log (s )
245+ }
246+
242247 if ! reflect .DeepEqual (got , tt .want ) {
243248 // t.Errorf("Parse() = %v, want %v", got, tt.want)
244249 // return
Original file line number Diff line number Diff line change @@ -258,6 +258,7 @@ type SoqlQueryGraphLeaf struct {
258258type SoqlQueryMeta struct {
259259 Version string `json:"version,omitempty"` // format version
260260 Date time.Time `json:"date,omitempty"` // compiled datetime
261+ ElapsedTime time.Duration `json:"elapsedTime,omitempty"` // time taken to compile
261262 Source string `json:"source,omitempty"` // source
262263 MaxQueryDepth int `json:"maxQueryDepth,omitempty"` // max depth of query graph
263264 MaxViewDepth int `json:"maxViewDepth,omitempty"` // max depth of object graph
@@ -266,7 +267,7 @@ type SoqlQueryMeta struct {
266267 NextColumnId int `json:"nextColumnId,omitempty"` // next column id (a number of columns)
267268 QueryGraph map [int ]SoqlQueryGraphLeaf `json:"queryGraph,omitempty"` // query graph (child -> parent)
268269 ViewGraph map [int ]SoqlViewGraphLeaf `json:"viewGraph,omitempty"` // object graph (child -> parent)
269- // TODO: MaxQueryDepth, Parameters, DateTimeLiterals
270+ // TODO: Parameters, DateTimeLiterals
270271}
271272
272273type SoqlQuery struct {
You can’t perform that action at this time.
0 commit comments