當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Formalizer.SetIdentifiers方法代碼示例

本文整理匯總了Golang中github.com/couchbase/query/expression.Formalizer.SetIdentifiers方法的典型用法代碼示例。如果您正苦於以下問題:Golang Formalizer.SetIdentifiers方法的具體用法?Golang Formalizer.SetIdentifiers怎麽用?Golang Formalizer.SetIdentifiers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/couchbase/query/expression.Formalizer的用法示例。


在下文中一共展示了Formalizer.SetIdentifiers方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: FormalizeSubquery

/*
This method qualifies identifiers for all the constituent clauses,
namely the subresult, order, limit and offset within a subquery.
For the subresult of the subquery, call Formalize, for the order
by clause call MapExpressions, for limit and offset call Accept.
*/
func (this *Select) FormalizeSubquery(parent *expression.Formalizer) error {
	f, err := this.subresult.Formalize(parent)
	if err != nil {
		return err
	}

	this.correlated = this.subresult.IsCorrelated()

	if this.order != nil {
		err = this.order.MapExpressions(f)
		if err != nil {
			return err
		}

		if !this.correlated {
			// Determine if this is a correlated subquery
			immediate := f.Allowed.GetValue().Fields()
			for ident, _ := range f.Identifiers {
				if _, ok := immediate[ident]; !ok {
					this.correlated = true
					break
				}
			}
		}
	}

	if this.limit == nil && this.offset == nil {
		return err
	}

	if !this.correlated {
		prevIdentifiers := parent.Identifiers
		defer parent.SetIdentifiers(prevIdentifiers)
		parent.SetIdentifiers(make(map[string]bool))
	}

	if this.limit != nil {
		_, err = this.limit.Accept(parent)
		if err != nil {
			return err
		}
	}

	if this.offset != nil {
		_, err = this.offset.Accept(parent)
		if err != nil {
			return err
		}
	}

	if !this.correlated {
		this.correlated = len(parent.Identifiers) > 0
	}

	return err
}
開發者ID:jmptrader,項目名稱:query,代碼行數:62,代碼來源:select.go


注:本文中的github.com/couchbase/query/expression.Formalizer.SetIdentifiers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。