good morning!!!!

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

Support for raw select statementes.

parent cbbdb6e9
Branches
Tags
No related merge requests found
package sqlgen
import (
"fmt"
"strings"
)
......@@ -10,11 +11,14 @@ type column_t struct {
}
type Column struct {
Value string
Value interface{}
}
func (self Column) Compile(layout *Template) string {
input := strings.TrimSpace(self.Value)
switch value := self.Value.(type) {
case string:
input := strings.TrimSpace(value)
chunks := reAliasSeparator.Split(input, 2)
......@@ -37,4 +41,9 @@ func (self Column) Compile(layout *Template) string {
}
return mustParse(layout.ColumnAliasLayout, column_t{name, alias})
case Raw:
return value.String()
}
return fmt.Sprintf("%v", self.Value)
}
......@@ -29,3 +29,16 @@ func TestColumnAs(t *testing.T) {
t.Fatalf("Got: %s, Expecting: %s", s, e)
}
}
func TestColumnRaw(t *testing.T) {
var s, e string
column := Column{Raw{"role.name As foo"}}
s = column.Compile(defaultTemplate)
e = `role.name As foo`
if s != e {
t.Fatalf("Got: %s, Expecting: %s", s, e)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment