MCPcopy Create free account
hub / github.com/go-pg/pg / Select

Method Select

orm/query.go:841–869  ·  view source on GitHub ↗

Select selects the model.

(values ...interface{})

Source from the content-addressed store, hash-verified

839
840// Select selects the model.
841func (q *Query) Select(values ...interface{}) error {
842 if q.stickyErr != nil {
843 return q.stickyErr
844 }
845
846 model, err := q.newModel(values)
847 if err != nil {
848 return err
849 }
850
851 res, err := q.query(q.ctx, model, NewSelectQuery(q))
852 if err != nil {
853 return err
854 }
855
856 if res.RowsReturned() > 0 {
857 if q.tableModel != nil {
858 if err := q.selectJoins(q.tableModel.GetJoins()); err != nil {
859 return err
860 }
861 }
862 }
863
864 if err := model.AfterSelect(q.ctx); err != nil {
865 return err
866 }
867
868 return nil
869}
870
871func (q *Query) newModel(values []interface{}) (Model, error) {
872 if len(values) > 0 {

Callers 7

SelectAndCountMethod · 0.95
ForEachMethod · 0.95
SelectOrInsertMethod · 0.95
FirstMethod · 0.45
LastMethod · 0.45
selectJoinsMethod · 0.45

Calls 7

newModelMethod · 0.95
queryMethod · 0.95
selectJoinsMethod · 0.95
NewSelectQueryFunction · 0.85
RowsReturnedMethod · 0.65
GetJoinsMethod · 0.65
AfterSelectMethod · 0.65

Tested by

no test coverage detected