From cdabf24277853af632725a9f7d0f8bcb28e52928 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Sun, 29 Apr 2018 15:08:49 +0300 Subject: [PATCH] More docs --- db.go | 2 ++ error.go | 5 +++++ orm/query.go | 10 ++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/db.go b/db.go index c443d946..4ef11f93 100644 --- a/db.go +++ b/db.go @@ -47,6 +47,7 @@ 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 @@ -54,6 +55,7 @@ func (db *DB) Context() context.Context { 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, diff --git a/error.go b/error.go index b906ea2a..99520760 100644 --- a/error.go +++ b/error.go @@ -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 diff --git a/orm/query.go b/orm/query.go index 8a68b28a..d15b2d5d 100644 --- a/orm/query.go +++ b/orm/query.go @@ -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 == "_" {