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 a 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 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:
db>
SELECT r'a raw \\\ string';
{'a raw \\\ string'}
db>
SELECT $$something$$;
{'something'}
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:
db> ...
SELECT 'Hello, \
world';
{'"Hello, world"'}
Scalar type SDL, DDL, introspection, string functions and operators, and string literal lexical structure.