Skip to content

Commit 2762c36

Browse files
authored
fix for stable (#1)
1 parent 1cee51c commit 2762c36

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

stable.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ func (s *sTableBuilder) Build() (string, error) {
6464

6565
// add tags
6666
if len(s.tags) > 0 {
67+
tagsKeys := make([]string, 0, len(s.tags))
6768
tagsValues := make([]any, 0, len(s.tags))
68-
for _, value := range s.tags {
69+
for key, value := range s.tags {
70+
tagsKeys = append(tagsKeys, key)
6971
tagsValues = append(tagsValues, value)
7072
}
7173

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

8083
if index != len(tagsValues)-1 {

tsdbbuilder_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ func Test_Create(t *testing.T) {
1313
TableName("test_table").
1414
STable("s_table_name").
1515
Tags(map[string]any{
16-
"test": 1,
17-
"test2": 2,
16+
"test": tsfuncs.Binary("16"),
17+
"test2": tsfuncs.Binary("24"),
1818
"test3": 3,
1919
})
2020

tsfuncs/binary.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package tsfuncs
2+
3+
type binary struct {
4+
expr string
5+
}
6+
7+
func Binary(expr string) TDEngineFunc {
8+
return &binary{expr}
9+
}
10+
11+
func (s binary) String() string {
12+
return "BINARY(" + s.expr + ")"
13+
}

0 commit comments

Comments
 (0)