Skip to content

String

The string type is used to store a sequence of characters (text). The literal constant is a sequence of characters of any length surrounded by double or single quotes. For example "Shaquille O'Neal" or '"This is a double-quoted literal string"'. Line breaks are not allowed in a string. Embedded escape sequences are supported within strings, for example:

  • "\n\t\r\b\f"
  • "\110ello world"

Nebula Graph supports two kind of strings: fixed length string and variable length string. For example:

nebula> CREATE TAG t1 (p1 FIXED_STRING(10)); -- Fixed length string type

nebula> CREATE TAG t2 (p2 string); -- Variable length string type

OpenCypher Compatibility

Here is a tiny difference between openCypher and Cypher, as well as nGQL.

The following is what openCypher requires. Single-quotes can't be converted to double-quotes.

 #File: Literals.feature
Feature: Literals

Background:
    Given any graph
 Scenario: Return a single-quoted string
    When executing query:
      """
      RETURN '' AS literal
      """
    Then the result should be, in any order:
      | literal |
      | ''      |    # Note: it should return single-quotes as openCypher required.
    And no side effects

While Cypher accepts both single-quotes and double quotes as the return results. nGQL follows the Cypher way.

nebula > YIELD '' AS quote1, "" AS quote2, "'" AS quote3, '"' AS quote4
+--------+--------+--------+--------+
| quote1 | quote2 | quote3 | quote4 |
+--------+--------+--------+--------+
| ""     | ""     | "'"    | """    |
+--------+--------+--------+--------+

Last update: February 5, 2021