-
Notifications
You must be signed in to change notification settings - Fork 209
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
Add clickhouse support #264
base: master
Are you sure you want to change the base?
Add clickhouse support #264
Conversation
dbr_test.go
Outdated
@@ -100,73 +131,78 @@ func reset(t *testing.T, sess *Session) { | |||
|
|||
func TestBasicCRUD(t *testing.T) { | |||
for _, sess := range testSession { | |||
reset(t, sess) |
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's no big change here, I just changed the test name to include the dialect, otherwise it's difficult to see which one was failing.
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.
Changed all tests to be this way in https://github.com/gocraft/dbr/pull/268/files
.circleci/config.yml
Outdated
@@ -2,11 +2,12 @@ version: 2 | |||
jobs: | |||
build: | |||
docker: | |||
- image: circleci/golang:1.17 | |||
- image: cimg/go:1.21 |
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.
As per https://hub.docker.com/r/cimg/go circleci/golang
was deprecated in favor of cimg/go
@cypriss @taylorchu if you feel the PR ended up being too big, I'm happy to split it in a few, to make it easier to review, let me know |
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.
Some improvements to be more go idiomatic.
Also, I would use clickHouse / ClickHouse
instead of clickhouse / Clickhouse
mysql | ||
} | ||
|
||
func (d clickhouse) EncodeTime(t time.Time) string { |
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.
should the receiver be c
?
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.
All the dialects have a received named d
. I wanted to preserve the same naming
join.go
Outdated
@@ -4,15 +4,21 @@ type joinType uint8 | |||
|
|||
const ( | |||
inner joinType = iota | |||
allFull |
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.
is this going to affect something? because the iota for left, right and full will change.
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.
These are only used internally and are kind of enums to know which string to write, so shouldn't affect
@@ -13,4 +13,11 @@ type Dialect interface { | |||
EncodeBytes(b []byte) string | |||
|
|||
Placeholder(n int) string | |||
|
|||
UpdateStmts() (string, string) |
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.
could you comment on why each is added?
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.
UpdateStmts
was added to know what is the staement that has to be used to run UPDATEs. Unfortunatelly clickhosue is different in this part, it's in the shape ofALTER TABLE ... UPDATE key = value
compared to others where it'sUPDATE ... SET key = value
OnConflict
adds support to add actions for constraint violation, e.g UPSERT. This works in postgres, mysql, etc. I can maybe add this change in a separate PR if you think it would be better to review, let me know if you want me to split this into smaller PRs, happy to do.Proposed
is used with OnConflict as reference to proposed value in on conflict clause. You can see the TestOnConflict to see how it works.SupportsOn
was added for clickhouse explicitly, but I removed it for now, I can maybe add it later if we really need to use it, and I think it should be done in a different way.
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.
Created a separate PR for the CI updates #265 I can then split this into more pieces if that's ok.
@taylorchu I removed things that were not specific to clickhouse from this PR and created: which are ready to be reviewed. Let me know your thoughts! 🙌 |
cc @cypriss / @taylorchu