good morning!!!!

Skip to content
Snippets Groups Projects
Commit 2d738f55 authored by José Carlos Nieto's avatar José Carlos Nieto
Browse files

Let Table now accepts Raw as value.

parent de60a5bc
No related branches found
No related tags found
No related merge requests found
package sqlgen
import (
"fmt"
"strings"
)
......@@ -10,7 +11,7 @@ type table_t struct {
}
type Table struct {
Name string
Name interface{}
}
func quotedTableName(layout *Template, input string) string {
......@@ -48,21 +49,29 @@ func quotedTableName(layout *Template, input string) string {
}
func (self Table) Hash() string {
return `Table(` + self.Name + `)`
switch t := self.Name.(type) {
case cc:
return `Table(` + t.Hash() + `)`
case string:
return `Table(` + t + `)`
}
return fmt.Sprintf(`Table(%v)`, self.Name)
}
func (self Table) Compile(layout *Template) (compiled string) {
if self.Name == "" {
return
}
if c, ok := layout.Read(self); ok {
return c
}
switch value := self.Name.(type) {
case string:
if self.Name == "" {
return
}
// Splitting tables by a comma
parts := separateByComma(self.Name)
parts := separateByComma(value)
l := len(parts)
......@@ -71,6 +80,9 @@ func (self Table) Compile(layout *Template) (compiled string) {
}
compiled = strings.Join(parts, layout.IdentifierSeparator)
case Raw:
compiled = value.String()
}
layout.Write(self, compiled)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment