[
https://issues.apache.org/jira/browse/TINKERPOP-3153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18077183#comment-18077183
]
ASF GitHub Bot commented on TINKERPOP-3153:
-------------------------------------------
Cole-Greer commented on code in PR #3401:
URL: https://github.com/apache/tinkerpop/pull/3401#discussion_r3164939472
##########
docs/src/upgrade/release-4.x.x.asciidoc:
##########
@@ -51,6 +51,65 @@ deserialization in GraphBinary is unchanged. Applications
that depend on the `uu
`gremlin-javascript` brought it in as a transitive dependency should add it
directly to their own `package.json`
if they still need it.
+==== New Gremlin-Lang Literals
+
+The canonical Gremlin grammar now includes literal syntax for `Character`,
`Duration`, and `Binary` types. These
+literals can be used directly in traversals without falling back to parameter
serialization.
+
+===== Character
+
+A character literal is a single-character string with a `c` suffix:
+
+[source,text]
+----
+g.V().has("initial","M"c)
+----
+
+NOTE: Character is not supported in gremlin-go or gremlin-javascript.
Review Comment:
Can we map Gremlin characters to the builtin `Rune` type in Go?
https://go.dev/blog/strings#code-points-characters-and-runes
##########
docs/src/dev/developer/for-committers.asciidoc:
##########
@@ -385,7 +385,12 @@ appropriate types expected by the tests.
The syntax of the type notation involves a prefix character to help denote the
type, a value between two square
brackets, optionally suffixed with some additional notation depending on the
primary type.
+* Binary - *bin[_xxx_]* - The "xxx" should be replaced with a base64-encoded
string.
+* Character - *char[_xxx_]* - The "xxx" should be replaced with a single UTF-8
character.
* Date - *dt[_xxx_]* - The "xxx" should be ISO 8601 string.
+* Duration - *dur[_xxx_,_yyy_,_zzz_]* - The "xxx" should be replaced a Long
representing seconds, the "yyy" should be
+replaced an Int representing nanoseconds, and the optional "zzz" should be
replaced by a boolean which is true if the
+value is positive and false if its negative.
* Edge - *e[_xxx_]* - The "xxx" should be replaced with a representation of an
edge in the form of the
Review Comment:
Can we also document the new `@DataChar`, `@DataDuration`, and `@DataBinary`
tags in the below `[[gherkin-tags]]` section?
##########
gremlin-language/src/main/antlr4/Gremlin.g4:
##########
@@ -2500,6 +2520,26 @@ SignedInfLiteral
// String Literals
+// Character literal is a single character string with a 'c' suffix, modeled
after printf's %c.
+// Must appear before NonEmptyStringLiteral for longest-match priority.
+CharacterLiteral
+ : '"' DoubleQuotedStringCharacter '"' 'c'
+ | '\'' SingleQuotedStringCharacter '\'' 'c'
Review Comment:
Should we also allow `C` as a suffix (and `s` and `S` for Strings). That
would be more consistent with `FloatTypeSuffix` and `IntegerTypeSuffix`
> Expand type syntax in grammar in 4.0
> ------------------------------------
>
> Key: TINKERPOP-3153
> URL: https://issues.apache.org/jira/browse/TINKERPOP-3153
> Project: TinkerPop
> Issue Type: Improvement
> Affects Versions: 4.0.0
> Reporter: Ken Hu
> Priority: Major
>
> Types to add to the grammar in 4.0:
> * Char
> ** Unfortunately '' is already used for strings to match Groovy. Will need
> to look into something nice for this.
> * Duration
> ** Should check to see if Duration can be used for date functions as well
> ** Duration(Long)
> * CompositePdt
> ** Pdt("name", [ : ] )
> * PrimitivePdt
> ** Pdt("name", "value")
> * Tree
> * Graph
> * Binary (ByteBuffer) - moved from 3.8.0
> ** {{Binary( '/9j/4AAQSkZJRgABAQEAAAAAAAD/==')}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)