Skip to content

Commit

Permalink
fix for stable (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxwebdev authored Jul 15, 2023
1 parent 1cee51c commit 2762c36
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 4 additions & 1 deletion stable.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ func (s *sTableBuilder) Build() (string, error) {

// add tags
if len(s.tags) > 0 {
tagsKeys := make([]string, 0, len(s.tags))
tagsValues := make([]any, 0, len(s.tags))
for _, value := range s.tags {
for key, value := range s.tags {
tagsKeys = append(tagsKeys, key)
tagsValues = append(tagsValues, value)
}

Expand All @@ -75,6 +77,7 @@ func (s *sTableBuilder) Build() (string, error) {
if err != nil {
return "", err
}
b.WriteString(tagsKeys[index] + " ")
b.WriteString(v)

if index != len(tagsValues)-1 {
Expand Down
4 changes: 2 additions & 2 deletions tsdbbuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func Test_Create(t *testing.T) {
TableName("test_table").
STable("s_table_name").
Tags(map[string]any{
"test": 1,
"test2": 2,
"test": tsfuncs.Binary("16"),
"test2": tsfuncs.Binary("24"),
"test3": 3,
})

Expand Down
13 changes: 13 additions & 0 deletions tsfuncs/binary.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package tsfuncs

type binary struct {
expr string
}

func Binary(expr string) TDEngineFunc {
return &binary{expr}
}

func (s binary) String() string {
return "BINARY(" + s.expr + ")"
}

0 comments on commit 2762c36

Please sign in to comment.