Skip to content

Commit

Permalink
More docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Apr 29, 2018
1 parent b9ee951 commit cdabf24
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions db.go
Expand Up @@ -47,13 +47,15 @@ func (db *DB) Options() *Options {
return db.opt
}

// Context returns DB context.
func (db *DB) Context() context.Context {
if db.ctx != nil {
return db.ctx
}
return context.Background()
}

// WithContext copies the DB, sets context and returns copied DB.
func (db *DB) WithContext(ctx context.Context) *DB {
return &DB{
opt: db.opt,
Expand Down
5 changes: 5 additions & 0 deletions error.go
Expand Up @@ -7,7 +7,12 @@ import (
"github.com/go-pg/pg/internal"
)

// ErrNoRows is returned by QueryOne and ExecOne when query returned zero rows
// but at least one row is expected.
var ErrNoRows = internal.ErrNoRows

// ErrMultiRows is returned by QueryOne and ExecOne when query returned
// multiple rows but exactly one row is expected.
var ErrMultiRows = internal.ErrMultiRows

// Error represents an error returned by PostgreSQL server
Expand Down
10 changes: 8 additions & 2 deletions orm/query.go
Expand Up @@ -158,8 +158,14 @@ func (q *Query) TableExpr(expr string, params ...interface{}) *Query {
return q
}

// Column adds column to the Query quoting it according to PostgreSQL rules.
// ColumnExpr can be used to bypass quoting restriction.
// Column adds a column to the Query quoting it according to PostgreSQL rules.
// ColumnExpr can be used to bypass quoting restriction. Column name can be:
// - column_name,
// - table_alias.column_name,
// - table_alias.*,
// - RelationName,
// - RelationName.column_name,
// - RelationName._ to join relation without selecting relation data.
func (q *Query) Column(columns ...string) *Query {
for _, column := range columns {
if column == "_" {
Expand Down

0 comments on commit cdabf24

Please sign in to comment.