TINKERPOP-3248: Added Character support in gremlin-go - #3673
Iryna-Kahamlyk wants to merge 8 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3673 +/- ##
============================================
+ Coverage 76.35% 76.70% +0.34%
- Complexity 13424 14336 +912
============================================
Files 1012 1037 +25
Lines 60341 64797 +4456
Branches 7075 7695 +620
============================================
+ Hits 46076 49704 +3628
- Misses 11548 11999 +451
- Partials 2717 3094 +377 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
GumpacG
left a comment
There was a problem hiding this comment.
Can you update gremlin-variants.asciidoc as it still states character is a limitation of Go.
Can you also add or enable feature tests for char in cucumberSteps_test.go?
| } | ||
|
|
||
| // Rune represents the GraphBinary/Gremlin Character type. | ||
| type Rune rune No newline at end of file |
There was a problem hiding this comment.
I think we should consider naming this type Char rune. This way users would call g.Inject(gremlingo.Char('a')) instead of g.Inject(gremlingo.Rune('a')). The package already names this Gremlin type GType.Char and the internals here are already char-based (charType, charWriter, readChar), so Char would keep the naming consistent.
There was a problem hiding this comment.
Thanks for pointing that out. All done!
Co-authored-by: Guian Gumpac <guian.gumpac@improving.com>
| return g.Inject(Char('"')) | ||
| }, | ||
| equals: `g.inject("\""c)`, | ||
| }, |
There was a problem hiding this comment.
I think we should probably add some more cases here like we did with gremlin-python:
Char('\\') // g.inject("\\"c)
Char('\'') // g.inject("'"c)
Char('\n') // g.inject("\n"c)
rune('a') // g.inject(97), confirming rune remains Int
| // Binary literal | ||
| ['g.inject(Binary("AQID"))', 'g.Inject(gremlingo.ByteBuffer{Data: []byte{1,2,3}})'], | ||
| // Character literal | ||
| ['g.inject("a"c)', "g.Inject(gremlingo.Char('a'))"], |
There was a problem hiding this comment.
I think we should have more tests here too. same as the ones I said with gremlinlang
"a"c
"\""c
"\\"c
"'"c
'\''c
that last one is particularly important because I think it might be a bug.
// Current, invalid Go
gremlingo.Char(''')
// Required
gremlingo.Char('\'')
also, Gremlin supports one- and two-digit octal escapes
"\7"c
"\07"c
| [[gremlin-go-limitations]] | ||
| === Limitations | ||
|
|
||
| * The Gremlin `Character` type is not supported by Gremlin-Go. |
There was a problem hiding this comment.
You might want to write here how the new Char type behaves. That is, users of gremlin-go that try something like g.inject('a') will lead to it being intepreted as an Integer. They have to use the new Char type that wraps a Rune to get the GremlinLang to actually generate a Char type.
JIRA: https://issues.apache.org/jira/browse/TINKERPOP-3248
Summary
Adds support for the Gremlin Character type to gremlin-go, in both GremlinLang text generation and GraphBinary serialization.
Go's rune is only an alias for int32, so it can't be distinguished from an int in a type switch. This introduces a new exported type, Char, that callers use to explicitly mark a value as a Character (e.g. g.Inject(gremlingo.Char('a'))).