(e *core.RequestEvent)
| 25 | } |
| 26 | |
| 27 | func runSQL(e *core.RequestEvent) error { |
| 28 | // extra precaution in case manually invoked from somewhere else |
| 29 | if !e.HasSuperuserAuth() { |
| 30 | return e.ForbiddenError("", nil) |
| 31 | } |
| 32 | |
| 33 | form := runSQLForm{} |
| 34 | |
| 35 | err := e.BindBody(&form) |
| 36 | if err != nil { |
| 37 | return firstApiError(err, e.BadRequestError("An error occurred while loading the submitted data.", err)) |
| 38 | } |
| 39 | |
| 40 | err = form.validate() |
| 41 | if err != nil { |
| 42 | return firstApiError(err, e.BadRequestError("An error occurred while validating the submitted data.", err)) |
| 43 | } |
| 44 | |
| 45 | result, err := executeQuery(e.App, form.Query, runSQLMaxRows) |
| 46 | if err != nil { |
| 47 | return firstApiError(err, e.BadRequestError("Failed to execute query. Raw error:\n"+err.Error(), nil)) |
| 48 | } |
| 49 | |
| 50 | return e.JSON(http.StatusOK, result) |
| 51 | } |
| 52 | |
| 53 | type runSQLForm struct { |
| 54 | Query string `form:"query" json:"query"` |
nothing calls this directly
no test coverage detected
searching dependent graphs…