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

gemini: pretty print CQL queries #80

Merged
merged 1 commit into from
May 2, 2019

Conversation

dahankzter
Copy link
Contributor

The type information of a particular statement is recorded when
the statement is generated to allow for type specific rendering
of the different parts of the queries.

Fixes: #38

@@ -262,11 +263,15 @@ func mutationJob(schema *gemini.Schema, table gemini.Table, s *gemini.Session, p
mutateQuery := mutateStmt.Query
mutateValues := mutateStmt.Values()
if verbose {
fmt.Printf("%s (values=%v)\n", mutateQuery, mutateValues)
fmt.Printf("mutationJob: %s\n", mutateStmt.PrettyCQL())
Copy link
Contributor

@penberg penberg Apr 29, 2019

Choose a reason for hiding this comment

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

How about we print only the CQL statement without that mutationJob prefix? It's easier to copy-paste a full line to a bug report or cqlsh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely!

@dahankzter dahankzter force-pushed the executable_printed_statements branch from fb05962 to ab23aa8 Compare April 29, 2019 07:09
@penberg
Copy link
Contributor

penberg commented Apr 29, 2019

Is the Go version I have too old for this?

[penberg@nero gemini]$ ./scripts/gemini-launcher --drop-schema --duration=10s
# github.com/scylladb/gemini
./types.go:473:33: reflect.ValueOf(value[0]).MapRange undefined (type reflect.Value has no field or method MapRange)
Compilation failed
[penberg@nero gemini]$ go version
go version go1.11.5 linux/amd64

@dahankzter
Copy link
Contributor Author

Jupp it's since 1.12 https://go-review.googlesource.com/c/go/+/33572/ too bad the Go docs don't include a Since: 1.12 field or something. Pretty messy to find.

The type information of a particular statement is recorded when
the statement is generated to allow for type specific rendering
of the different parts of the queries.
@dahankzter dahankzter force-pushed the executable_printed_statements branch from ab23aa8 to dde7562 Compare May 2, 2019 07:18
@dahankzter dahankzter merged commit 68ddb47 into master May 2, 2019
@dahankzter dahankzter deleted the executable_printed_statements branch May 2, 2019 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make printed out CQL statements executable from cqlsh
2 participants