From 381c780e7abcba96df3a0b59ef89085706b7ba7c Mon Sep 17 00:00:00 2001 From: Paddy Carver Date: Wed, 2 Aug 2023 05:44:31 -0700 Subject: [PATCH] Rename to ComplexExpression. SubQuery means something specific in SQL and we don't want to confuse people by reusing an existing term and giving it a new meaning. Instead, let's call it a complex expression, which is more evocative of what it's used for. --- query.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/query.go b/query.go index 014f7c6..b979ac3 100644 --- a/query.go +++ b/query.go @@ -175,13 +175,13 @@ func (q *Query) PostgreSQLString() (string, error) { return res + ";", nil } -// SubQuery starts a Query with a new buffer, so it can be flushed without -// affecting the outer Query's buffer of expressions. +// ComplexExpression starts a Query with a new buffer, so it can be flushed +// without affecting the outer Query's buffer of expressions. // -// Once a SubQuery has been flushed, it should have its AppendToParent method -// called, which sets the entire SubQuery as a single expression on its parent -// Query. -func (q *Query) SubQuery(query string) *Query { +// Once a ComplexExpression has been flushed, it should have its AppendToParent +// method called, which sets the entire ComplexExpression as a single +// expression on its parent Query. +func (q *Query) ComplexExpression(query string) *Query { return &Query{ sql: query, args: []any{}, @@ -190,13 +190,14 @@ func (q *Query) SubQuery(query string) *Query { } // AppendToParent sets the entire Query as a single expression on its parent -// Query. It should only be called on Querys created by calling SubQuery; -// calling it on a Query that isn't a SubQuery will panic. +// Query. It should only be called on Querys created by calling +// ComplexExpression; calling it on a Query that isn't a ComplexExpression will +// panic. // // It returns the parent of the Query. func (q *Query) AppendToParent() *Query { if q.parent == nil { - panic("can't call AppendToParent on a Query that wasn't created using Query.SubQuery") + panic("can't call AppendToParent on a Query that wasn't created using Query.ComplexExpression") } if len(q.expressions) > 0 { panic(ErrNeedsFlush)