phonenumber
A phone number.
At a glance
- Stored as: the value itself, written inline wherever it is used.
- Search: as one identifier, so
ilikepatterns match any part of it and full-text search sees it as one word.
Writing
Write the number as text in any common format: (202) 555-0123, 202.555.0123,
+1 202-555-0123. It is stored in international E.164 form, +12025550123.
- A number without a country code is read as a US number. Start any other number with
+and its country code (+44 20 7946 0958). - Numbers in area code 555 are accepted, because
+1 555 555 01xxis the usual made-up number in examples and tests. A seven-digit number without an area code, such as555-0123, is refused. - Text that is not a valid phone number is refused (
Invalid phone number: …), and so is empty text.
A number can carry what to dial after it connects:
- An extension, written
x45,ext. 45,extension 45or;ext=45, is stored asext 45:+12025550123 ext 45. An extension is digits only. - Keys to press once the call is answered, to walk a phone menu, follow the first
,or;:+12025550123,,1#. They may be0-9,*,#andA-D, with pauses:wwaits half a second,Worpa second, and,or;two seconds (stored asWW). A sequence longer than 64 keys is refused, since a carrier sends no more. - Text after the comma that is not keys (
, call after 5pm) is dropped, and the number is kept.
The stored text is always the number, then ext and the extension, then , and the
keys: +12025550123 ext 45,WW1#.
Written as
A JSON string whose schema format is phonenumber.
Reading
You read back that stored text. It is the same however the number was first written, so one number always reads, and compares, the same.
Querying
A value compared with =, !=, in or a comparison is read as a phone number first, in any
format the field accepts, so 2025550123 finds +12025550123, for every value of an in
list too. A like, ilike or regex pattern is used as written.
Call | from_number = "2025550123" | select id, from_number, start_time | limit 20
Call | to_number in ("(202) 555-0123", "202.555.0199") | select id, to_number | limit 20
Phone numbers are not word-searchable. To match part of one, use ilike on the stored
E.164 text, such as an area code, which checks every row in scope:
Party | phone_numbers ilike "+1202%" | select id, phone_numbers | limit 20
A number stored with an extension or keys is not equal to the bare number.
Every operator is in the HQL reference.
Operations
Through the dtypes resource: