Repository: edgedb/edgedb

Issue:
Consider renaming `to_str(array)` and `to_array(str)` to `str_split` and `array_join` respectively.
`to_str(array, delimiter)` and `to_array(str, delimiter)` are, at a glance, consistent with other conversion/constructor functions, but `to_array(str, delimiter)` is an odd and undisoverable way of naming a string-splitting function, and `str_split()` would be a better name.  On the other hand, `to_str(array, delimiter)` has a better claim at being similar to other "formatting" functions, but is also distinct in that it converts a collection type into a scalar type, so naming it `array_join` would not be too bad.


Discussion:
Also, People coming with a Python or JavaScript experience would expect `join` and `split`.
 
Victor, please work on this tomorrow.
Can I work on this issue?
> Can I work on this issue?

Sure, go ahead!
@vpetrovykh Please handle this today.
Hi,

Can you share some pointer on where to look for these functions: to_str(array) and to_array(str, delimiter)
https://github.com/edgedb/edgedb/tree/master/edb/lib

Basically you need to update signatures there and then fix all tests & docs. If this isn't done today somebody will pick this up tomorrow as we have a release on Wednesday. 
Sure, I will do it today.

Resolving patch:
diff --git a/edb/repl/__init__.py b/edb/repl/__init__.py
--- a/edb/repl/__init__.py
+++ b/edb/repl/__init__.py
@@ -686,7 +686,7 @@ def _command_list_scalar_types(
             WITH MODULE schema
             SELECT ScalarType {
                 name,
-                `extending` := to_str(array_agg(.bases.name), ', '),
+                `extending` := array_join(array_agg(.bases.name), ', '),
                 kind := (
                     'enum' IF 'std::anyenum' IN .ancestors.name ELSE
                     'sequence' IF 'std::sequence' IN .ancestors.name ELSE
@@ -757,7 +757,7 @@ def _command_list_object_types(
             WITH MODULE schema
             SELECT ObjectType {
                 name,
-                `extending` := to_str(array_agg(.ancestors.name), ', '),
+                `extending` := array_join(array_agg(.ancestors.name), ', '),
             }
         '''
 


Test patch:
diff --git a/tests/schemas/dump01_default.esdl b/tests/schemas/dump01_default.esdl
--- a/tests/schemas/dump01_default.esdl
+++ b/tests/schemas/dump01_default.esdl
@@ -30,7 +30,7 @@ function user_func_0(x: int64) -> str {
 
 function user_func_1(x: array<int64>, y: str) -> str {
     using (
-        SELECT to_str(<array<str>>x, y)
+        SELECT array_join(<array<str>>x, y)
     );
     volatility := 'IMMUTABLE';
 };
@@ -172,7 +172,7 @@ type I {
     };
     required link i2 -> C {
         default := (
-            SELECT C FILTER .val = to_str(['D', '0', '2'], '') LIMIT 1
+            SELECT C FILTER .val = array_join(['D', '0', '2'], '') LIMIT 1
         );
     };
 }
@@ -184,7 +184,7 @@ type J {
         SELECT C FILTER .val = 'D0' ++ user_func_0(1)[-1] LIMIT 1
     );
     link j2 := (
-        SELECT C FILTER .val = to_str(['D', '0', '2'], '') LIMIT 1
+        SELECT C FILTER .val = array_join(['D', '0', '2'], '') LIMIT 1
     );
 }
 
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
@@ -2083,40 +2083,40 @@ async def test_edgeql_functions_to_str_07(self):
                 await self.con.fetchall(
                     r'''SELECT to_str(<cal::local_time>'15:01:22', '');''',)
 
-    async def test_edgeql_functions_to_str_08(self):
+    async def test_edgeql_functions_array_join_01(self):
         await self.assert_query_result(
-            r'''SELECT to_str(['one', 'two', 'three'], ', ');''',
+            r'''SELECT array_join(['one', 'two', 'three'], ', ');''',
             ['one, two, three'],
         )
 
         await self.assert_query_result(
-            r'''SELECT to_str(['one', 'two', 'three'], '');''',
+            r'''SELECT array_join(['one', 'two', 'three'], '');''',
             ['onetwothree'],
         )
 
         await self.assert_query_result(
-            r'''SELECT to_str(<array<str>>[], ', ');''',
+            r'''SELECT array_join(<array<str>>[], ', ');''',
             [''],
         )
 
-    async def test_edgeql_functions_to_array_01(self):
+    async def test_edgeql_functions_str_split_01(self):
         await self.assert_query_result(
-            r'''SELECT to_array('one, two, three', ', ');''',
+            r'''SELECT str_split('one, two, three', ', ');''',
             [['one', 'two', 'three']],
         )
 
         await self.assert_query_result(
-            r'''SELECT to_array('', ', ');''',
+            r'''SELECT str_split('', ', ');''',
             [[]],
         )
 
         await self.assert_query_result(
-            r'''SELECT to_array('foo', ', ');''',
+            r'''SELECT str_split('foo', ', ');''',
             [['foo']],
         )
 
         await self.assert_query_result(
-            r'''SELECT to_array('foo', '');''',
+            r'''SELECT str_split('foo', '');''',
             [['f', 'o', 'o']],
         )
 
diff --git a/tests/test_edgeql_tree.py b/tests/test_edgeql_tree.py
--- a/tests/test_edgeql_tree.py
+++ b/tests/test_edgeql_tree.py
@@ -590,7 +590,7 @@ async def test_edgeql_tree_update_01(self):
                 WITH MODULE test
                 UPDATE Tree
                 SET {
-                    val := to_str(
+                    val := array_join(
                         [.val, 'c'] ++ array_agg((
                             SELECT _ := .children.val
                             ORDER BY _
@@ -657,7 +657,7 @@ async def test_edgeql_tree_update_02(self):
                 WITH MODULE test
                 UPDATE Eert
                 SET {
-                    val := to_str(
+                    val := array_join(
                         [.val, 'c'] ++ array_agg((
                             SELECT _ := .children.val
                             ORDER BY _