Skip to content

TINKERPOP-3248: Added Character support in gremlin-go - #3673

Open
Iryna-Kahamlyk wants to merge 8 commits into
apache:masterfrom
Iryna-Kahamlyk:TINKERPOP-3248
Open

Iryna-Kahamlyk wants to merge 8 commits into
apache:masterfrom
Iryna-Kahamlyk:TINKERPOP-3248

Conversation

@Iryna-Kahamlyk

@Iryna-Kahamlyk Iryna-Kahamlyk commented Sep 21, 2026 •

Copy link
Copy Markdown

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'))).

@Iryna-Kahamlyk
Iryna-Kahamlyk marked this pull request as ready for review September 21, 2026 22:23
@codecov-commenter

codecov-commenter commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.70%. Comparing base (a28cd1f) to head (fd043c7).
⚠️ Report is 645 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@GumpacG GumpacG left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Comment thread gremlin-go/driver/traversal.go Outdated
}

// Rune represents the GraphBinary/Gremlin Character type.
type Rune rune No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for pointing that out. All done!

@GumpacG GumpacG left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

VOTE +1

Comment thread CHANGELOG.asciidoc Outdated
Co-authored-by: Guian Gumpac <guian.gumpac@improving.com>
return g.Inject(Char('"'))
},
equals: `g.inject("\""c)`,
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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'))"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

# Conflicts:
#	gremlin-js/gremlin-javascript/lib/language/translator/GoTranslateVisitor.ts
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.

5 participants