Repository: edgedb/edgedb

Issue:
array parameters don't work in HTTP mode
<!-- Please search existing issues to avoid creating duplicates. -->

<!--
For the EdgeDB Version: run `edgedb query 'select sys::get_version_as_str()'` from your project directory (or run `select sys::get_version_as_str();` in the EdgeDB interactive shell).
For the EdgeDB CLI Version: Run `edgedb --version` from anywhere
-->


- Used Java & Springboot
- EdgeDB Version: 2.9+a3d80ef
- EdgeDB CLI Version: EdgeDB CLI 2.2.6+7eabbf9
- OS Version: macOS Monterey 12.5

Steps to Reproduce:

1. Use EdgeQL over HTTP
2.  POST request with array property in variables.
3.  unsupported array dimensions error occurred

<!-- If the issue is about a query error, please also provide your schema -->

Schema:
```sh
using extension edgeql_http;
module default {

    type Menu {
        property name -> str;
        property price -> int32;
        property description -> str;
        property is_displayed -> bool;
        property is_soldout -> bool;
        property sequence_number -> int32;

        property category_id -> uuid;
        property option_ids -> array<uuid>;

        property is_deleted -> bool;
        property created_at -> cal::local_datetime;
        property updated_at -> cal::local_datetime;
    }
}
```

Request Payload:
```json
{
  "variables": {
    "id": null,
    "isDeleted": false,
    "createdAt": null,
    "updatedAt": null,
    "name": "test_2144f046f408",
    "price": 47,
    "description": "test_754e65b0cfca",
    "isDisplayed": true,
    "isSoldout": true,
    "sequenceNumber": 95,
    "categoryId": "84b49941-a894-43fc-bf24-4f9d76d0b4d8",
    "optionIds": [
      "0fb88d5a-cfd6-4f61-839c-6a84a799f162",
      "4ab6b33e-b1a6-4b98-9299-3ad0ec7d49f4"
    ]
  },
  "query": "insert Menu {\nis_deleted := false,\ncreated_at := cal::to_local_datetime(std::datetime_current(), 'Asia/Seoul'),\nupdated_at := cal::to_local_datetime(std::datetime_current(), 'Asia/Seoul'),\nname := <str>$name,\nprice := <int32>$price,\ndescription := <str>$description,\nis_displayed := <bool>$isDisplayed,\nis_soldout := <bool>$isSoldout,\nsequence_number := <int32>$sequenceNumber,\ncategory_id := <uuid>$categoryId,\noption_ids := <array<uuid>>$optionIds\n};"
}
```

Error
```sh
error={message=unsupported array dimensions, type=InputDataError, code=50462720}
```


### Opinion
- Exclude the array element or enter a value directly into query and call it, it will perform normally.
  - For exmaple
    ```
    {"variables":{"id":null,"isDeleted":false,"createdAt":null,"updatedAt":null,"name":"test_2144f046f408","price":47,"description":"test_754e65b0cfca","isDisplayed":true,"isSoldout":true,"sequenceNumber":95,"categoryId":"84b49941-a894-43fc-bf24-4f9d76d0b4d8","optionIds":["0fb88d5a-cfd6-4f61-839c-6a84a799f162","4ab6b33e-b1a6-4b98-9299-3ad0ec7d49f4"],"labelIds":["581f3b5b-a82f-4228-8829-337381ad275f","29775e52-8280-420d-b9a5-2bc6adef10b3"]},"query":"insert Menu {\n\tis_deleted := false,\n\tcreated_at := cal::to_local_datetime(std::datetime_current(), 'Asia/Seoul'),\n\tupdated_at := cal::to_local_datetime(std::datetime_current(), 'Asia/Seoul'),\n\tname := <str>$name,\n\tprice := <int32>$price,\n\tdescription := <str>$description,\n\tis_displayed := <bool>$isDisplayed,\n\tis_soldout := <bool>$isSoldout,\n\tsequence_number := <int32>$sequenceNumber,\n\tcategory_id := <uuid>$categoryId,\n\toption_ids := <array<uuid>>[\"0fb88d5a-cfd6-4f61-839c-6a84a799f162\",\"4ab6b33e-b1a6-4b98-9299-3ad0ec7d49f4\"]\n}"}
    ```
- Is the request payload the problem?  



Discussion:

Resolving patch:
diff --git a/edb/server/compiler/compiler.py b/edb/server/compiler/compiler.py
--- a/edb/server/compiler/compiler.py
+++ b/edb/server/compiler/compiler.py
@@ -2082,9 +2082,14 @@ def _extract_params(
         if idx >= user_params:
             continue
 
+        if ctx.json_parameters:
+            schema_type = schema.get('std::json')
+        else:
+            schema_type = param.schema_type
+
         array_tid = None
-        if param.schema_type.is_array():
-            el_type = param.schema_type.get_element_type(schema)
+        if schema_type.is_array():
+            el_type = schema_type.get_element_type(schema)
             array_tid = el_type.id
 
         # NB: We'll need to turn this off for script args
@@ -2099,11 +2104,12 @@ def _extract_params(
 
         oparams[idx] = (
             param.name,
-            param.schema_type,
+            schema_type,
             param.required,
         )
 
         if param.sub_params:
+            assert not ctx.json_parameters
             array_tids = []
             for p in param.sub_params.params:
                 if p.schema_type.is_array():


Test patch:
diff --git a/tests/test_http_edgeql.py b/tests/test_http_edgeql.py
--- a/tests/test_http_edgeql.py
+++ b/tests/test_http_edgeql.py
@@ -258,6 +258,16 @@ def test_http_edgeql_query_12(self):
                 variables={'x': None},
             )
 
+    def test_http_edgeql_query_13(self):
+        self.assert_edgeql_query_result(
+            r'''select (<array<int64>>$foo, <tuple<int64, str>>$bar)''',
+            [[[1, 2, 3], [1, 'test']]],
+            variables=dict(
+                foo=[1, 2, 3],
+                bar=(1, 'test'),
+            )
+        )
+
     def test_http_edgeql_query_globals_01(self):
         Q = r'''select GlobalTest { gstr, garray, gid, gdef, gdef2 }'''