String Type

type str

A unicode string of text.

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

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

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

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

There are two kinds of string literals in EdgeQL: regular and raw. Raw strings 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:

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