String Type

type
str

A unicode string of text.

Any other type (except bytes) can be cast to and from a string:

Copy
db> 
SELECT <str>42;
{'42'}
Copy
db> 
SELECT <bool>'true';
{true}
Copy
db> 
SELECT "I ❤️ EdgeDB";
{'I ❤️ EdgeDB'}

Note that when a str is cast into a json, the result is a JSON string value. Same applies for casting back from json - only a JSON string value can be cast into a str:

Copy
db> 
SELECT <json>'Hello, world';
{'"Hello, world"'}

There are two kinds of string literals in EdgeQL: regular and raw. Raw string literals do not evaluate \, so \n in in a raw string is two characters \ and n.

The regular string literal syntax is 'a string' or a "a string". Two raw string syntaxes are illustrated below:

Copy
db> 
SELECT r'a raw \\\ string';
{'a raw \\\ string'}
Copy
db> 
SELECT $$something$$;
{'something'}
Copy
db> 
... 
SELECT $marker$something $$
nested \!$$$marker$;
{'something $$
nested \!$$'}

Regular strings use \ to indicate line continuation. When a line continuation symbol is encountered, the symbol itself as well as all the whitespace characters up to the next non-whitespace character are omitted from the string:

Copy
db> 
... 
SELECT 'Hello, \
        world';
{'"Hello, world"'}
Light
Dark
System