diff --git a/edb/api/types.txt b/edb/api/types.txt index 1197b178bb4d..3825a01dd6de 100644 --- a/edb/api/types.txt +++ b/edb/api/types.txt @@ -49,3 +49,9 @@ 00000000-0000-0000-0000-000000000112 std::cal::date_duration 00000000-0000-0000-0000-000000000130 cfg::memory + +00000000-0000-0000-0000-000001000001 std::pg::json +00000000-0000-0000-0000-000001000002 std::pg::timestamptz +00000000-0000-0000-0000-000001000003 std::pg::timestamp +00000000-0000-0000-0000-000001000004 std::pg::date +00000000-0000-0000-0000-000001000005 std::pg::interval diff --git a/edb/lib/pg.edgeql b/edb/lib/pg.edgeql index d7ca8cdaf5cb..a6359f62f93b 100644 --- a/edb/lib/pg.edgeql +++ b/edb/lib/pg.edgeql @@ -84,3 +84,9 @@ create index match for std::cal::local_date using std::pg::brin; create index match for std::cal::local_time using std::pg::brin; create index match for std::cal::relative_duration using std::pg::brin; create index match for std::cal::date_duration using std::pg::brin; + +create scalar type std::pg::json extending std::anyscalar; +create scalar type std::pg::timestamptz extending std::anycontiguous; +create scalar type std::pg::timestamp extending std::anycontiguous; +create scalar type std::pg::date extending std::anydiscrete; +create scalar type std::pg::interval extending std::anycontiguous; diff --git a/edb/pgsql/types.py b/edb/pgsql/types.py index 9a2319c2e1a1..f49033cf67c5 100644 --- a/edb/pgsql/types.py +++ b/edb/pgsql/types.py @@ -68,6 +68,12 @@ ('edgedbt', 'date_duration_t'), s_obj.get_known_type_id('cfg::memory'): ('edgedbt', 'memory_t'), + + s_obj.get_known_type_id('std::pg::json'): ('json',), + s_obj.get_known_type_id('std::pg::timestamptz'): ('timestamptz',), + s_obj.get_known_type_id('std::pg::timestamp'): ('timestamp',), + s_obj.get_known_type_id('std::pg::date'): ('date',), + s_obj.get_known_type_id('std::pg::interval'): ('interval',), } type_to_range_name_map = { @@ -85,6 +91,9 @@ # custom range is a big hassle, and daterange already has the # correct canonicalization function ('edgedbt', 'date_t'): ('daterange',), + ('timestamptz',): ('tstzrange',), + ('timestamp',): ('tsrange',), + ('date',): ('daterange',), } # Construct a multirange map based on type_to_range_name_map by replacing @@ -143,6 +152,8 @@ 'edgedbt.memory_t': sn.QualName('cfg', 'memory'), 'memory_t': sn.QualName('cfg', 'memory'), + + 'json': sn.QualName('std::pg', 'json'), } pg_tsvector_typeref = irast.TypeRef( diff --git a/edb/schema/_types.py b/edb/schema/_types.py index d96435e99bf3..bf4af5834752 100644 --- a/edb/schema/_types.py +++ b/edb/schema/_types.py @@ -66,4 +66,14 @@ UUID('00000000-0000-0000-0000-000000000112'), sn.name_from_string('cfg::memory'): UUID('00000000-0000-0000-0000-000000000130'), + sn.name_from_string('std::pg::json'): + UUID('00000000-0000-0000-0000-000001000001'), + sn.name_from_string('std::pg::timestamptz'): + UUID('00000000-0000-0000-0000-000001000002'), + sn.name_from_string('std::pg::timestamp'): + UUID('00000000-0000-0000-0000-000001000003'), + sn.name_from_string('std::pg::date'): + UUID('00000000-0000-0000-0000-000001000004'), + sn.name_from_string('std::pg::interval'): + UUID('00000000-0000-0000-0000-000001000005'), } diff --git a/edb/server/dbview/dbview.pyx b/edb/server/dbview/dbview.pyx index 150e0acd33cc..9fa49f9f6fa1 100644 --- a/edb/server/dbview/dbview.pyx +++ b/edb/server/dbview/dbview.pyx @@ -1442,7 +1442,7 @@ cdef class DatabaseConnectionView: edb_type_expr = self._db.backend_id_to_name.get(toid) if edb_type_expr is None: raise errors.UnsupportedFeatureError( - f"unsupported SQL type in column \"{col}\"" + f"unsupported SQL type in column \"{col}\" " f"with type OID {toid}" ) diff --git a/edb/tools/gen_types.py b/edb/tools/gen_types.py index f9bb0ae00586..b16713e39665 100644 --- a/edb/tools/gen_types.py +++ b/edb/tools/gen_types.py @@ -63,7 +63,7 @@ def main(*, stdout: bool): f'\n\n\n' f'from __future__ import annotations' f'\n' - f'from typing import * # NoQA' + f'from typing import Type' f'\n\n\n' f'import uuid' f'\n\n'