From bae038ff5846f7c7f61fd2fbb111769f04e8aa84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Nieto?= <jose.carlos@menteslibres.net> Date: Sat, 23 May 2015 06:54:43 -0500 Subject: [PATCH] Renaming cc into Fragment. --- util/sqlgen/column.go | 2 +- util/sqlgen/column_value.go | 2 +- util/sqlgen/interfaces.go | 2 +- util/sqlgen/statement.go | 18 +++++++++--------- util/sqlgen/table.go | 2 +- util/sqlgen/value.go | 4 ++-- util/sqlgen/where.go | 10 +++++----- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/util/sqlgen/column.go b/util/sqlgen/column.go index 27f44f55..4eb395e1 100644 --- a/util/sqlgen/column.go +++ b/util/sqlgen/column.go @@ -27,7 +27,7 @@ func (c *Column) Hash() string { var s string switch t := c.Name.(type) { - case cc: + case Fragment: s = t.Hash() case fmt.Stringer: s = t.String() diff --git a/util/sqlgen/column_value.go b/util/sqlgen/column_value.go index a0d6fd47..18acdec9 100644 --- a/util/sqlgen/column_value.go +++ b/util/sqlgen/column_value.go @@ -9,7 +9,7 @@ import ( type ColumnValue struct { Column Operator string - Value cc + Value Fragment hash string } diff --git a/util/sqlgen/interfaces.go b/util/sqlgen/interfaces.go index 30746c43..8d6cb109 100644 --- a/util/sqlgen/interfaces.go +++ b/util/sqlgen/interfaces.go @@ -4,7 +4,7 @@ import ( "upper.io/cache" ) -type cc interface { +type Fragment interface { cache.Hashable compilable } diff --git a/util/sqlgen/statement.go b/util/sqlgen/statement.go index b0b458b5..16b8800d 100644 --- a/util/sqlgen/statement.go +++ b/util/sqlgen/statement.go @@ -10,17 +10,17 @@ import ( // Statement represents different kinds of SQL statements. type Statement struct { Type - Table cc - Database cc + Table Fragment + Database Fragment Limit Offset - Columns cc - Values cc - ColumnValues cc - OrderBy cc - GroupBy cc + Columns Fragment + Values Fragment + ColumnValues Fragment + OrderBy Fragment + GroupBy Fragment Extra - Where cc + Where Fragment hash string } @@ -38,7 +38,7 @@ type statementT struct { Where string } -func (layout *Template) doCompile(c cc) string { +func (layout *Template) doCompile(c Fragment) string { if c != nil { return c.Compile(layout) } diff --git a/util/sqlgen/table.go b/util/sqlgen/table.go index 1ab0a90e..43dcda62 100644 --- a/util/sqlgen/table.go +++ b/util/sqlgen/table.go @@ -61,7 +61,7 @@ func (t *Table) Hash() string { var s string switch v := t.Name.(type) { - case cc: + case Fragment: s = v.Hash() case fmt.Stringer: s = v.String() diff --git a/util/sqlgen/value.go b/util/sqlgen/value.go index f2f821ee..8c9ff920 100644 --- a/util/sqlgen/value.go +++ b/util/sqlgen/value.go @@ -25,7 +25,7 @@ func NewValue(v interface{}) *Value { func (v *Value) Hash() string { if v.hash == "" { switch t := v.V.(type) { - case cc: + case Fragment: v.hash = `Value(` + t.Hash() + `)` case string: v.hash = `Value(` + t + `)` @@ -45,7 +45,7 @@ func (v *Value) Compile(layout *Template) (compiled string) { if raw, ok := v.V.(Raw); ok { compiled = raw.Compile(layout) - } else if raw, ok := v.V.(cc); ok { + } else if raw, ok := v.V.(Fragment); ok { compiled = raw.Compile(layout) } else { compiled = mustParse(layout.ValueQuote, RawValue(fmt.Sprintf(`%v`, v.V))) diff --git a/util/sqlgen/where.go b/util/sqlgen/where.go index 60ea1546..64ea9f10 100644 --- a/util/sqlgen/where.go +++ b/util/sqlgen/where.go @@ -13,7 +13,7 @@ type And Where // Where represents an SQL WHERE clause. type Where struct { - Conditions []cc + Conditions []Fragment hash string } @@ -22,17 +22,17 @@ type conds struct { } // WhereConditions creates and retuens a new Where. -func WhereConditions(conditions ...cc) *Where { +func WhereConditions(conditions ...Fragment) *Where { return &Where{Conditions: conditions} } // JoinWithOr creates and returns a new Or. -func JoinWithOr(conditions ...cc) *Or { +func JoinWithOr(conditions ...Fragment) *Or { return &Or{Conditions: conditions} } // JoinWithAnd creates and returns a new And. -func JoinWithAnd(conditions ...cc) *And { +func JoinWithAnd(conditions ...Fragment) *And { return &And{Conditions: conditions} } @@ -104,7 +104,7 @@ func (w *Where) Compile(layout *Template) (compiled string) { return } -func groupCondition(layout *Template, terms []cc, joinKeyword string) string { +func groupCondition(layout *Template, terms []Fragment, joinKeyword string) string { l := len(terms) chunks := make([]string, 0, l) -- GitLab