Repository: edgedb/edgedb

Issue:
Consider renaming std::datetime_trunc to std::datetime_truncate
We generally don't use abbreviations in our functions naming and this looks like an oversight.


Discussion:
![Screen Shot 2019-12-09 at 12 24 28 PM](https://user-images.githubusercontent.com/239003/70457835-dd58b080-1a7e-11ea-850c-b4511a63d627.png)


Resolving patch:
diff --git a/edb/edgeql/pygments/meta.py b/edb/edgeql/pygments/meta.py
--- a/edb/edgeql/pygments/meta.py
+++ b/edb/edgeql/pygments/meta.py
@@ -240,8 +240,8 @@ class EdgeQL:
         "datetime_get",
         "datetime_of_statement",
         "datetime_of_transaction",
-        "datetime_trunc",
-        "duration_trunc",
+        "datetime_truncate",
+        "duration_truncate",
         "enumerate",
         "find",
         "floor",
diff --git a/edb/server/defines.py b/edb/server/defines.py
--- a/edb/server/defines.py
+++ b/edb/server/defines.py
@@ -27,7 +27,7 @@
 EDGEDB_VISIBLE_METADATA_PREFIX = r'EdgeDB metadata follows, do not modify.\n'
 
 # Increment this whenever the database layout or stdlib changes.
-EDGEDB_CATALOG_VERSION = 20191219_00_00
+EDGEDB_CATALOG_VERSION = 20191220_00_00
 
 # Resource limit on open FDs for the server process.
 # By default, at least on macOS, the max number of open FDs


Test patch:
diff --git a/tests/schemas/issues.esdl b/tests/schemas/issues.esdl
--- a/tests/schemas/issues.esdl
+++ b/tests/schemas/issues.esdl
@@ -117,3 +117,7 @@ type Publication {
 abstract constraint my_one_of(one_of: array<anytype>) {
     using (contains(one_of, __subject__));
 }
+
+scalar type EmulatedEnum extending str {
+    constraint one_of('v1', 'v2');
+}
diff --git a/tests/test_edgeql_functions.py b/tests/test_edgeql_functions.py
--- a/tests/test_edgeql_functions.py
+++ b/tests/test_edgeql_functions.py
@@ -1177,7 +1177,7 @@ async def test_edgeql_functions_time_get_01(self):
     async def test_edgeql_functions_datetime_trunc_01(self):
         await self.assert_query_result(
             r'''
-                SELECT <str>datetime_trunc(
+                SELECT <str>datetime_truncate(
                     <datetime>'2018-05-07T15:01:22.306916-05', 'year');
             ''',
             {'2018-01-01T00:00:00+00:00'},
@@ -1185,7 +1185,7 @@ async def test_edgeql_functions_datetime_trunc_01(self):
 
         await self.assert_query_result(
             r'''
-                SELECT <str>datetime_trunc(
+                SELECT <str>datetime_truncate(
                     <datetime>'2018-05-07T15:01:22.306916-05', 'quarter');
             ''',
             {'2018-04-01T00:00:00+00:00'},
@@ -1193,7 +1193,7 @@ async def test_edgeql_functions_datetime_trunc_01(self):
 
         await self.assert_query_result(
             r'''
-                SELECT <str>datetime_trunc(
+                SELECT <str>datetime_truncate(
                     <datetime>'2018-05-07T15:01:22.306916-05', 'month');
             ''',
             {'2018-05-01T00:00:00+00:00'},
@@ -1201,7 +1201,7 @@ async def test_edgeql_functions_datetime_trunc_01(self):
 
         await self.assert_query_result(
             r'''
-                SELECT <str>datetime_trunc(
+                SELECT <str>datetime_truncate(
                     <datetime>'2018-05-07T15:01:22.306916-05', 'day');
             ''',
             {'2018-05-07T00:00:00+00:00'},
@@ -1209,7 +1209,7 @@ async def test_edgeql_functions_datetime_trunc_01(self):
 
         await self.assert_query_result(
             r'''
-                SELECT <str>datetime_trunc(
+                SELECT <str>datetime_truncate(
                     <datetime>'2018-05-07T15:01:22.306916-05', 'hour');
             ''',
             {'2018-05-07T20:00:00+00:00'},
@@ -1217,7 +1217,7 @@ async def test_edgeql_functions_datetime_trunc_01(self):
 
         await self.assert_query_result(
             r'''
-                SELECT <str>datetime_trunc(
+                SELECT <str>datetime_truncate(
                     <datetime>'2018-05-07T15:01:22.306916-05', 'minute');
             ''',
             {'2018-05-07T20:01:00+00:00'},
@@ -1225,7 +1225,7 @@ async def test_edgeql_functions_datetime_trunc_01(self):
 
         await self.assert_query_result(
             r'''
-                SELECT <str>datetime_trunc(
+                SELECT <str>datetime_truncate(
                     <datetime>'2018-05-07T15:01:22.306916-05', 'second');
             ''',
             {'2018-05-07T20:01:22+00:00'},
@@ -1234,7 +1234,7 @@ async def test_edgeql_functions_datetime_trunc_01(self):
     async def test_edgeql_functions_duration_trunc_01(self):
         await self.assert_query_result(
             r'''
-            SELECT <str>duration_trunc(
+            SELECT <str>duration_truncate(
                 <duration>'15:01:22.306916', 'hours');
             ''',
             {'15:00:00'},
@@ -1242,7 +1242,7 @@ async def test_edgeql_functions_duration_trunc_01(self):
 
         await self.assert_query_result(
             r'''
-            SELECT <str>duration_trunc(
+            SELECT <str>duration_truncate(
                 <duration>'15:01:22.306916', 'minutes');
             ''',
             {'15:01:00'},
@@ -1250,7 +1250,7 @@ async def test_edgeql_functions_duration_trunc_01(self):
 
         await self.assert_query_result(
             r'''
-            SELECT <str>duration_trunc(
+            SELECT <str>duration_truncate(
                 <duration>'15:01:22.306916', 'seconds');
             ''',
             {'15:01:22'},
@@ -1258,7 +1258,7 @@ async def test_edgeql_functions_duration_trunc_01(self):
 
         await self.assert_query_result(
             r'''
-            SELECT <str>duration_trunc(
+            SELECT <str>duration_truncate(
                 <duration>'15:01:22.306916', 'milliseconds');
             ''',
             {'15:01:22.306'},
@@ -1267,7 +1267,7 @@ async def test_edgeql_functions_duration_trunc_01(self):
         # Currently no-op but may be useful if precision is improved
         await self.assert_query_result(
             r'''
-            SELECT <str>duration_trunc(
+            SELECT <str>duration_truncate(
                 <duration>'15:01:22.306916', 'microseconds');
             ''',
             {'15:01:22.306916'},
@@ -1276,10 +1276,10 @@ async def test_edgeql_functions_duration_trunc_01(self):
     async def test_edgeql_functions_duration_trunc_02(self):
         with self.assertRaisesRegex(
                 edgedb.InvalidValueError,
-                'invalid input syntax for type std::duration_trunc'):
+                'invalid input syntax for type std::duration_truncate'):
             await self.con.execute(
                 r'''
-                SELECT <str>duration_trunc(
+                SELECT <str>duration_truncate(
                     <duration>'73 hours', 'day');
                 ''')
 
diff --git a/tests/test_edgeql_introspection.py b/tests/test_edgeql_introspection.py
--- a/tests/test_edgeql_introspection.py
+++ b/tests/test_edgeql_introspection.py
@@ -218,7 +218,7 @@ async def test_edgeql_introspection_objtype_07(self):
                 FILTER
                     ObjectType.name LIKE 'test::%'
                     AND
-                    ObjectType.links.cardinality = 'MANY'
+                    ObjectType.links.cardinality = <Cardinality>'MANY'
                 ORDER BY ObjectType.name;
             """,
             [
@@ -243,7 +243,7 @@ async def test_edgeql_introspection_objtype_08(self):
                 FILTER
                     `ObjectType`.name LIKE 'test::%'
                     AND
-                    `ObjectType`.links.cardinality = 'MANY'
+                    ObjectType.links.cardinality = <Cardinality>'MANY'
                 ORDER BY `ObjectType`.name;
             """,
             [
@@ -613,22 +613,22 @@ async def test_edgeql_introspection_constraint_06(self):
                         errmessage,
                     },
                 }
-                FILTER .name = 'schema::cardinality_t';
+                FILTER .name = 'test::EmulatedEnum';
             """,
             [{
 
-                'name': 'schema::cardinality_t',
+                'name': 'test::EmulatedEnum',
                 'constraints': [
                     {
                         'name': 'std::one_of',
                         'expr': 'contains(vals, __subject__)',
                         'annotations': {},
-                        'subject': {'name': 'schema::cardinality_t'},
+                        'subject': {'name': 'test::EmulatedEnum'},
                         'args': [
                             {
                                 'name': 'vals',
                                 'type': {'name': 'array'},
-                                '@value': "['ONE', 'MANY']"
+                                '@value': "['v1', 'v2']"
                             }
                         ],
                         'return_typemod': 'SINGLETON',