Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
5114b1f7
Commit
5114b1f7
authored
Dec 06, 2017
by
linux chips
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing a few fromattings
parent
1c1675af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
pkg/tsdb/mssql/mssql.go
+6
-6
pkg/tsdb/mssql/mssql_test.go
+7
-6
No files found.
pkg/tsdb/mssql/mssql.go
View file @
5114b1f7
...
@@ -38,7 +38,7 @@ func NewMssqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin
...
@@ -38,7 +38,7 @@ func NewMssqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin
serport
:=
datasource
.
Url
serport
:=
datasource
.
Url
// fix me: need to have a default port if user did not provide. i.e. 1433
// fix me: need to have a default port if user did not provide. i.e. 1433
words
:=
strings
.
Split
(
serport
,
":"
)
words
:=
strings
.
Split
(
serport
,
":"
)
server
,
port
:=
words
[
0
],
words
[
1
]
server
,
port
:=
words
[
0
],
words
[
1
]
cnnstr
:=
fmt
.
Sprintf
(
"server=%s;port=%s;database=%s;user id=%s;password=%s;"
,
cnnstr
:=
fmt
.
Sprintf
(
"server=%s;port=%s;database=%s;user id=%s;password=%s;"
,
server
,
server
,
...
@@ -106,16 +106,16 @@ func (e MssqlQueryEndpoint) transformToTable(query *tsdb.Query, rows *core.Rows,
...
@@ -106,16 +106,16 @@ func (e MssqlQueryEndpoint) transformToTable(query *tsdb.Query, rows *core.Rows,
func
(
e
MssqlQueryEndpoint
)
getTypedRowData
(
types
[]
*
sql
.
ColumnType
,
rows
*
core
.
Rows
)
(
tsdb
.
RowValues
,
error
)
{
func
(
e
MssqlQueryEndpoint
)
getTypedRowData
(
types
[]
*
sql
.
ColumnType
,
rows
*
core
.
Rows
)
(
tsdb
.
RowValues
,
error
)
{
values
:=
make
([]
interface
{},
len
(
types
))
values
:=
make
([]
interface
{},
len
(
types
))
valuePtrs
:=
make
([]
interface
{},
len
(
types
))
valuePtrs
:=
make
([]
interface
{},
len
(
types
))
for
i
,
stype
:=
range
types
{
for
i
,
stype
:=
range
types
{
e
.
log
.
Debug
(
"type"
,
"type"
,
stype
)
e
.
log
.
Debug
(
"type"
,
"type"
,
stype
)
valuePtrs
[
i
]
=
&
values
[
i
]
valuePtrs
[
i
]
=
&
values
[
i
]
}
}
if
err
:=
rows
.
Scan
(
valuePtrs
...
);
err
!=
nil
{
if
err
:=
rows
.
Scan
(
valuePtrs
...
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
values
,
nil
return
values
,
nil
}
}
...
...
pkg/tsdb/mssql/mssql_test.go
View file @
5114b1f7
package
mssql
package
mssql
import
(
import
(
"strings"
"testing"
"testing"
"time"
"time"
"strings"
_
"github.com/denisenkom/go-mssqldb"
_
"github.com/denisenkom/go-mssqldb"
"github.com/go-xorm/xorm"
"github.com/go-xorm/xorm"
...
@@ -18,6 +18,7 @@ import (
...
@@ -18,6 +18,7 @@ import (
// and set up a MSSQL db named grafana_tests and a user/password grafana/password
// and set up a MSSQL db named grafana_tests and a user/password grafana/password
// and set the variable below to the IP address of the database
// and set the variable below to the IP address of the database
var
serverIP
string
=
"10.20.30.40"
var
serverIP
string
=
"10.20.30.40"
func
TestMSSQL
(
t
*
testing
.
T
)
{
func
TestMSSQL
(
t
*
testing
.
T
)
{
//SkipConvey("MSSQL", t, func() {
//SkipConvey("MSSQL", t, func() {
SkipConvey
(
"MSSQL"
,
t
,
func
()
{
SkipConvey
(
"MSSQL"
,
t
,
func
()
{
...
@@ -96,19 +97,19 @@ func TestMSSQL(t *testing.T) {
...
@@ -96,19 +97,19 @@ func TestMSSQL(t *testing.T) {
So
(
column
[
7
]
.
(
string
),
ShouldEqual
,
"hi varchar"
)
So
(
column
[
7
]
.
(
string
),
ShouldEqual
,
"hi varchar"
)
So
(
column
[
8
]
.
(
string
),
ShouldEqual
,
"I am only char"
)
So
(
column
[
8
]
.
(
string
),
ShouldEqual
,
"I am only char"
)
So
(
column
[
9
]
.
(
float64
),
ShouldEqual
,
1.1100000143051147
)
// MSSQL dose not have precision for "real" datatype
So
(
column
[
9
]
.
(
float64
),
ShouldEqual
,
1.1100000143051147
)
// MSSQL dose not have precision for "real" datatype
// fiix me: MSSQL driver puts the decimal inside an array of chars. and the test fails despite the values are correct.
// fiix me: MSSQL driver puts the decimal inside an array of chars. and the test fails despite the values are correct.
//So(column[10].([]uint8), ShouldEqual, []uint8{'2', '.', '2', '2'})
//So(column[10].([]uint8), ShouldEqual, []uint8{'2', '.', '2', '2'})
So
(
column
[
11
]
.
(
float64
),
ShouldEqual
,
3.33
)
So
(
column
[
11
]
.
(
float64
),
ShouldEqual
,
3.33
)
So
(
column
[
12
]
.
(
time
.
Time
),
ShouldHappenWithin
,
time
.
Duration
(
15
*
time
.
Second
),
time
.
Now
()
.
UTC
()
)
So
(
column
[
12
]
.
(
time
.
Time
),
ShouldHappenWithin
,
time
.
Duration
(
15
*
time
.
Second
),
time
.
Now
()
.
UTC
())
So
(
column
[
13
]
.
(
time
.
Time
),
ShouldHappenWithin
,
time
.
Duration
(
15
*
time
.
Second
),
time
.
Now
()
.
UTC
()
.
Truncate
(
24
*
time
.
Hour
)
)
So
(
column
[
13
]
.
(
time
.
Time
),
ShouldHappenWithin
,
time
.
Duration
(
15
*
time
.
Second
),
time
.
Now
()
.
UTC
()
.
Truncate
(
24
*
time
.
Hour
))
So
(
column
[
14
]
.
(
time
.
Time
),
ShouldHappenWithin
,
time
.
Duration
(
15
*
time
.
Second
),
time
.
Date
(
1
,
time
.
January
,
1
,
time
.
Now
()
.
UTC
()
.
Hour
(),
time
.
Now
()
.
UTC
()
.
Minute
(),
time
.
Now
()
.
UTC
()
.
Second
(),
0
,
time
.
UTC
)
)
So
(
column
[
14
]
.
(
time
.
Time
),
ShouldHappenWithin
,
time
.
Duration
(
15
*
time
.
Second
),
time
.
Date
(
1
,
time
.
January
,
1
,
time
.
Now
()
.
UTC
()
.
Hour
(),
time
.
Now
()
.
UTC
()
.
Minute
(),
time
.
Now
()
.
UTC
()
.
Second
(),
0
,
time
.
UTC
)
)
})
})
})
})
}
}
func
InitMSSQLTestDB
(
t
*
testing
.
T
)
*
xorm
.
Engine
{
func
InitMSSQLTestDB
(
t
*
testing
.
T
)
*
xorm
.
Engine
{
x
,
err
:=
xorm
.
NewEngine
(
sqlutil
.
TestDB_Mssql
.
DriverName
,
strings
.
Replace
(
sqlutil
.
TestDB_Mssql
.
ConnStr
,
"localhost"
,
serverIP
,
1
)
)
x
,
err
:=
xorm
.
NewEngine
(
sqlutil
.
TestDB_Mssql
.
DriverName
,
strings
.
Replace
(
sqlutil
.
TestDB_Mssql
.
ConnStr
,
"localhost"
,
serverIP
,
1
))
// x.ShowSQL()
// x.ShowSQL()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment