Repository: edgedb/edgedb

Issue:
No method to generate code for TupleVar
<!-- 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
-->

- EdgeDB Version: 4.0+d568f08
- EdgeDB CLI Version: 4.0.2+be1da73
- OS Version: Linux 6.5.6-200.fc38.x86_64 (Fedora 38)

Steps to Reproduce:

1. Ran this query in the REPL:

```edgeql
INSERT default::Address {
  coordinates := (
      lat := <std::float32>40.07987,
      lng := <std::float32>20.56509
  ),
  text := "Some street address, 1, Test Country",
  external_place_id := "123456"
}
```

I initially thought that the syntax for the tuple might be wrong, but this runs fine:

```edgeql
select (
    
      lat := <std::float32>46.07987,
      lng := <std::float32>23.56509
    
  )
;
```

<!-- If the issue is about a query error, please also provide your schema -->

Schema:

```esdl
    type Address extending Timestamped {
        coordinates: tuple<lat: float32, lng: float32>;
        # some other optional string fields
        required text: str;
        required external_place_id: str {
            constraint exclusive;
        };

        index on (.external_place_id);
    }
    
    abstract type Timestamped {
        required created_at: datetime {
            readonly := true;
            default := datetime_of_statement();
        }
        updated_at: datetime {
            default := datetime_of_statement();
            rewrite insert, update using (datetime_of_statement())
        }
    }
```    


Discussion:
FWIW: Upgraded EdgeDB to `4.1+2194ddc` and I get the same.

Resolving patch:
diff --git a/edb/pgsql/compiler/dml.py b/edb/pgsql/compiler/dml.py
--- a/edb/pgsql/compiler/dml.py
+++ b/edb/pgsql/compiler/dml.py
@@ -964,6 +964,7 @@ def process_insert_rewrites(
             val = pathctx.get_path_var(
                 rew_stmt, e.path_id, aspect='value', env=ctx.env
             )
+            val = output.output_as_value(val, env=ctx.env)
             rew_stmt.target_list.append(pgast.ResTarget(
                 name=ptr_info.column_name, val=val))
 


Test patch:
diff --git a/tests/test_edgeql_rewrites.py b/tests/test_edgeql_rewrites.py
--- a/tests/test_edgeql_rewrites.py
+++ b/tests/test_edgeql_rewrites.py
@@ -1047,3 +1047,30 @@ async def test_edgeql_rewrites_27(self):
             'select Foo { will_be_true }',
             [{'will_be_true': True}]
         )
+
+    async def test_edgeql_rewrites_28(self):
+        await self.con.execute(
+            '''
+            create type Address {
+                create property coordinates: tuple<lat: float32, lng: float32>;
+                create property updated_at: str {
+                    create rewrite insert using ('now')
+                };
+            };
+            insert Address {
+                coordinates := (
+                    lat := <std::float32>40.07987,
+                    lng := <std::float32>20.56509
+                )
+            };
+            '''
+        )
+        await self.assert_query_result(
+            'select Address { coordinates, updated_at }',
+            [
+                {
+                    'coordinates': {'lat': 40.07987, 'lng': 20.56509},
+                    'updated_at': 'now'
+                }
+            ]
+        )