Skip to content

Commit

Permalink
Remove fields double quote
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin658 committed Nov 12, 2018
1 parent 0a5011a commit e5af363
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ query := builder.
Output:
```sql
SELECT "temperature","humidity" FROM "measurement"
SELECT temperature,humidity FROM "measurement"
```
### Function query
Expand Down Expand Up @@ -60,7 +60,7 @@ query := builder.
Output:
```sql
SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z' OR "tag" = 't'
SELECT temperature,humidity FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z' OR "tag" = 't'
```
### Brackets criteria
Expand All @@ -87,7 +87,7 @@ query := builder.
Output:
```sql
SELECT "temperature","humidity" FROM "measurement" WHERE ("time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z') OR "tag" = 't'
SELECT temperature,humidity FROM "measurement" WHERE ("time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z') OR "tag" = 't'
```
#### And Brackets
Expand All @@ -110,7 +110,7 @@ query := builder.
Output:
```sql
SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND ("time" < '2018-11-02T09:35:25Z' OR "tag" = 't')
SELECT temperature,humidity FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND ("time" < '2018-11-02T09:35:25Z' OR "tag" = 't')
```
#### Or Brackets
Expand All @@ -133,7 +133,7 @@ query := builder.
Output:
```sql
SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' OR ("time" < '2018-11-02T09:35:25Z' OR "tag" = 't')
SELECT temperature,humidity FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' OR ("time" < '2018-11-02T09:35:25Z' OR "tag" = 't')
```
### Group By time
Expand All @@ -150,7 +150,7 @@ query := builder.
Output:
```sql
SELECT "temperature","humidity" FROM "measurement" GROUP BY time(10m)
SELECT temperature,humidity FROM "measurement" GROUP BY time(10m)
```
### Order By time
Expand All @@ -167,7 +167,7 @@ query := builder.
Output:
```sql
SELECT "temperature","humidity" FROM "measurement" ORDER BY time DESC
SELECT temperature,humidity FROM "measurement" ORDER BY time DESC
```
### Limit and Offset
Expand All @@ -185,7 +185,7 @@ query := builder.
Output:
```sql
SELECT "temperature","humidity" FROM "measurement" LIMIT 10 OFFSET 5
SELECT temperature,humidity FROM "measurement" LIMIT 10 OFFSET 5
```
### Reset builder and get a new one
Expand Down
2 changes: 1 addition & 1 deletion query_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (q *Query) buildFields() string {
return ""
}

tmpl := `"%s"`
tmpl := `%s`
fields := make([]string, len(q.fields))

for i := range fields {
Expand Down
30 changes: 15 additions & 15 deletions query_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestClean(t *testing.T) {

func TestSelect(t *testing.T) {
builder := New()
expected := `SELECT "temperature","humidity" FROM "measurement"`
expected := `SELECT temperature,humidity FROM "measurement"`
q := builder.
Select("temperature", "humidity").
From("measurement").
Expand All @@ -47,7 +47,7 @@ func TestSelectFunction(t *testing.T) {
}

func TestWhere(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" WHERE "time" < '2018-11-02T09:35:25Z'`
expected := `SELECT temperature,humidity FROM "measurement" WHERE "time" < '2018-11-02T09:35:25Z'`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -58,7 +58,7 @@ func TestWhere(t *testing.T) {
}

func TestAnd(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z'`
expected := `SELECT temperature,humidity FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z'`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -71,7 +71,7 @@ func TestAnd(t *testing.T) {
}

func TestOr(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' OR "time" < '2018-11-02T09:35:25Z'`
expected := `SELECT temperature,humidity FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' OR "time" < '2018-11-02T09:35:25Z'`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -84,7 +84,7 @@ func TestOr(t *testing.T) {
}

func TestWhereAndOr(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z' OR "tag" = 't'`
expected := `SELECT temperature,humidity FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z' OR "tag" = 't'`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -98,7 +98,7 @@ func TestWhereAndOr(t *testing.T) {
}

func TestGroupBy(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" GROUP BY time(10m)`
expected := `SELECT temperature,humidity FROM "measurement" GROUP BY time(10m)`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -110,7 +110,7 @@ func TestGroupBy(t *testing.T) {
}

func TestFill(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" FILL(1)`
expected := `SELECT temperature,humidity FROM "measurement" FILL(1)`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -122,7 +122,7 @@ func TestFill(t *testing.T) {
}

func TestAscOrder(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" ORDER BY time ASC`
expected := `SELECT temperature,humidity FROM "measurement" ORDER BY time ASC`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -134,7 +134,7 @@ func TestAscOrder(t *testing.T) {
}

func TestDescOrder(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" ORDER BY time DESC`
expected := `SELECT temperature,humidity FROM "measurement" ORDER BY time DESC`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -146,7 +146,7 @@ func TestDescOrder(t *testing.T) {
}

func TestLimitOffset(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" LIMIT 10 OFFSET 5`
expected := `SELECT temperature,humidity FROM "measurement" LIMIT 10 OFFSET 5`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -159,7 +159,7 @@ func TestLimitOffset(t *testing.T) {
}

func TestBracketsWhere(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" WHERE ("time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z') OR "tag" = 't'`
expected := `SELECT temperature,humidity FROM "measurement" WHERE ("time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z') OR "tag" = 't'`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -176,7 +176,7 @@ func TestBracketsWhere(t *testing.T) {
}

func TestBracketsAndCriteria(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND ("time" < '2018-11-02T09:35:25Z' OR "tag" = 't')`
expected := `SELECT temperature,humidity FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND ("time" < '2018-11-02T09:35:25Z' OR "tag" = 't')`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -193,7 +193,7 @@ func TestBracketsAndCriteria(t *testing.T) {
}

func TestBracketsOrCriteria(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' OR ("time" < '2018-11-02T09:35:25Z' OR "tag" = 't')`
expected := `SELECT temperature,humidity FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' OR ("time" < '2018-11-02T09:35:25Z' OR "tag" = 't')`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -210,7 +210,7 @@ func TestBracketsOrCriteria(t *testing.T) {
}

func TestWhereTypeSqlQuote(t *testing.T) {
expected := `SELECT "temperature","humidity" FROM "measurement" WHERE "temperature" > 20 OR "humidity" < 10.101`
expected := `SELECT temperature,humidity FROM "measurement" WHERE "temperature" > 20 OR "humidity" < 10.101`
builder := New()
q := builder.
Select("temperature", "humidity").
Expand All @@ -220,7 +220,7 @@ func TestWhereTypeSqlQuote(t *testing.T) {
Build()
assert(t, q, expected)

expected = `SELECT "temperature" FROM "measurement" WHERE "hot" = true`
expected = `SELECT temperature FROM "measurement" WHERE "hot" = true`
q = builder.
Clean().
Select("temperature").
Expand Down

0 comments on commit e5af363

Please sign in to comment.