getReturning returns a pointer to the Returning slice for supported DML statements (INSERT, UPDATE, DELETE). Returns ErrUnsupportedStatement for SELECT or DDL statements.
(stmt ast.Statement)
| 22 | // statements (INSERT, UPDATE, DELETE). Returns ErrUnsupportedStatement for |
| 23 | // SELECT or DDL statements. |
| 24 | func getReturning(stmt ast.Statement) (*[]ast.Expression, error) { |
| 25 | switch s := stmt.(type) { |
| 26 | case *ast.InsertStatement: |
| 27 | return &s.Returning, nil |
| 28 | case *ast.UpdateStatement: |
| 29 | return &s.Returning, nil |
| 30 | case *ast.DeleteStatement: |
| 31 | return &s.Returning, nil |
| 32 | default: |
| 33 | return nil, &ErrUnsupportedStatement{Transform: "RETURNING", Got: stmtTypeName(stmt)} |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // AddReturning returns a Rule that appends one or more column names to the |
| 38 | // RETURNING clause of an INSERT, UPDATE, or DELETE statement. This is the |
no test coverage detected