Skip to content
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

x/cqlbuilder: Add implementation of a query builder #2

Merged
merged 6 commits into from
Feb 1, 2021

Conversation

AlexisMontagne
Copy link
Member

What does this PR do?

C* is the second most used database at Upfluence, from the experience learnt of using upfluence/sql/x/sqlbuilder the idea is to provide similar DSL to create easy to build / composable request to a cassandra cluster.

What are the observable changes?

Too much to mention here.

Good PR checklist

  • Title makes sense
  • Is against the correct branch
  • Only addresses one issue
  • Properly assigned
  • Added/updated tests
  • Added/updated documentation
  • Properly labeled

Additional Notes

return nil
}

func clonePredicateClause(pc PredicateClause) PredicateClause {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
func clonePredicateClause is unused (unused)

x/cqlbuilder/dml.go Show resolved Hide resolved
}

func (pcl PredicateLWTClause) keys() []string {
var ks []string

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
Consider preallocating ks (prealloc)

})
}

func queryRow(sq *SelectQueryer, foo string) (string, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
queryRow - foo always receives "foo" (unparam)

)
}

func execCAS(e Execer, foo, bar string) (bool, string, string, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
execCAS - foo always receives "foo" (unparam)

fmt.Fprintf(w, " TTL %d", int(do.TTL.Seconds()))

if !do.Timestamp.IsZero() {
io.WriteString(w, " AND")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
Error return value of io.WriteString is not checked (errcheck)

}

if v.Len() == 0 {
io.WriteString(qw, "1=0")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
Error return value of io.WriteString is not checked (errcheck)

@@ -32,6 +32,8 @@ var defaultOptions = options{

type Option func(*options)

func MigrationTable(t string) Option { return func(o *options) { o.table = t } }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
func name will be used as migration.MigrationTable by other packages, and that stutters; consider calling this Table (golint)

return plc.Predicate.WriteTo(qw, vs)
}

func (pcl PredicateLWTClause) keys() []string {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
receiver name pcl should be consistent with previous receiver name plc for PredicateLWTClause (golint)

}

func (PredicateLWTClause) isUpdateClause() {}
func (PredicateLWTClause) isDeleteClause() {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
ST1016: methods on the same type should have the same receiver name (seen 1x "pcl", 1x "plc") (stylecheck)


import (
"github.com/upfluence/cql"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
)
import "github.com/upfluence/cql"

:p

@tgallice
Copy link
Member

Otherwise, my very small comments, LGTM

Copy link
Contributor

@jlevesy jlevesy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only read it partially.

I would be happy to get a pair review session with you, that would be more efficient IMO. I'm not familliar enough with cassandra to be relevant here.

ExecCAS(context.Context, map[string]interface{}) CASScanner
}

type execer struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cassandra noob here,

What's the difference between Exec and ExecCAS ? Expecting a scanner to deal with some output ? If so what does CAS stands for ?

casScanKeys() []string
}

type InsertExecer struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand the point of those Insert|Update|Delete execers ? Why not returning an execer directly ?

})
}

func TestEC(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does EC stands for ? What does this test tests ?

}

func wrapMultiClause(wcs []PredicateClause, op string) PredicateClause {
var cs []PredicateClause

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
Consider preallocating cs (prealloc)

}

func (mc multiClause) Markers() []Marker {
var ms []Marker

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-linter] reported by reviewdog 🐶
Consider preallocating ms (prealloc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants