MCPcopy Index your code
hub / github.com/Masterminds/structable / insertPg

Method insertPg

structable.go:431–445  ·  view source on GitHub ↗

insertPg runs a postgres-specific INSERT. Unlike the default (MySQL) driver, this actually refreshes ALL of the fields on the Record object. We do this because it is trivially easy in Postgres.

()

Source from the content-addressed store, hash-verified

429// this actually refreshes ALL of the fields on the Record object. We do this
430// because it is trivially easy in Postgres.
431func (s *DbRecorder) insertPg() error {
432
433 cols, vals := s.colValLists(true, false)
434 dest := s.fieldReferences(true)
435
436 q := s.builder.Insert(s.table).Columns(cols...).Values(vals...).
437 Suffix("RETURNING " + strings.Join(s.colList(true, false), ","))
438
439 sql, vals, err := q.ToSql()
440 if err != nil {
441 return err
442 }
443
444 return s.db.QueryRow(sql, vals...).Scan(dest...)
445}
446
447// Update updates the values on an existing entry.
448//

Callers 1

InsertMethod · 0.95

Calls 6

colValListsMethod · 0.95
fieldReferencesMethod · 0.95
colListMethod · 0.95
ScanMethod · 0.80
QueryRowMethod · 0.80
InsertMethod · 0.65

Tested by

no test coverage detected