-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added sql test code and modified some code of sql.go #80
Conversation
Hello @bourbonkk Thank you for your contribution :) If you wanna add a test for sql queries, maybe the best place is here https://github.com/grafadruid/go-druid/blob/master/query.go , actually, in a query_test.go file to add. If you're about examples, then see https://github.com/grafadruid/go-druid/tree/master/examples It started from go 1.14 but no issue to update that, still, it'll works with most recent golang versions AFAIK. The project is active and used; it doesn't move so much since it's quite complete and stable, so far so good :) There are still Druid (community) extensions to support and tests to add here and there probably. I've updated the slack invite link, here it is: https://join.slack.com/t/grafadruid/shared_invite/zt-1ohtquqg3-25ka1yV4Kkig0lt5XzfmeA Cheers, |
+1, we use go-druid actively in production |
Thank you for your explanation. |
Type string `json:"type,omitempty"` | ||
Value string `json:"value,omitempty"` | ||
Type string `json:"type,omitempty"` | ||
Value interface{} `json:"value,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were cases where the type of value was INTEGER or FLOAT, so I changed it to an interface.
@@ -25,8 +25,11 @@ func NewSQL() *SQL { | |||
return s | |||
} | |||
|
|||
func NewSQLParameter() *SQLParameter { | |||
p := &SQLParameter{} | |||
func NewSQLParameter(Type string, Value interface{}) SQLParameter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified to allow use of SQLParameter's constructor.
@@ -60,6 +63,11 @@ func (s *SQL) SetParameters(parameters []SQLParameter) *SQL { | |||
return s | |||
} | |||
|
|||
func (s *SQL) SetContext(context map[string]interface{}) *SQL { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the SetContext method of the SQL struct because it did not exist.
"testing" | ||
) | ||
|
||
func TestSelectSQL(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a comparison test of query builder and actual output.
assert.JSONEq(t, expected, string(expressionJSON)) | ||
} | ||
|
||
func TestAllSetterSQL(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a comparison test when all methods are changed to true
) | ||
|
||
func main() { | ||
d, err := druid.NewClient("http://localhost:8888") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of using SQL query
LGTM but I'll get @vigith approve this. |
LGTM thank you a lot @bourbonkk :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎆
Added sql test code. #31
I want to help with your project.
Is this project still going on? It doesn't seem to be active.
I want to make it easy for other users to use by writing a lot of test examples.
And the golang version is 1.14 right?
invite me to slack