Repository: edgedb/edgedb

Issue:
`insert foo { id }` produces invalid SQL (should just be rejected)
Stack Trace
```
InternalServerError: invalid reference to FROM-clause entry for table "Person~1"
    at RawConnection._parseErrorMessage (/home/bmorris/internalfx/projects/internalfx-icx/node_modules/edgedb/dist/rawConn.js:371:21)
    at RawConnection._executeFlow (/home/bmorris/internalfx/projects/internalfx-icx/node_modules/edgedb/dist/rawConn.js:861:34)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RawConnection.fetch (/home/bmorris/internalfx/projects/internalfx-icx/node_modules/edgedb/dist/rawConn.js:981:13)
    at async ClientConnectionHolder.retryingFetch (/home/bmorris/internalfx/projects/internalfx-icx/node_modules/edgedb/dist/client.js:178:26)
    at async Client.querySingle (/home/bmorris/internalfx/projects/internalfx-icx/node_modules/edgedb/dist/client.js:486:20)
    at async Object.create [as peopleController.create] (/home/bmorris/internalfx/projects/internalfx-icx/api/controllers/peopleController.js:79:20)
    at async /home/bmorris/internalfx/projects/internalfx-icx/system/middleware/router.js:40:7
    at async /home/bmorris/internalfx/projects/internalfx-icx/system/middleware/nuxtRender.js:32:5
    at async /home/bmorris/internalfx/projects/internalfx-icx/system/middleware/httpError.js:5:7
    at async /home/bmorris/internalfx/projects/internalfx-icx/system/middleware/performance.js:5:5
    at async cors (/home/bmorris/internalfx/projects/internalfx-icx/node_modules/@koa/cors/index.js:106:16)
    at async ratelimit (/home/bmorris/internalfx/projects/internalfx-icx/node_modules/koa-ratelimit/index.js:100:33) {
  source: undefined
}
```

<!-- Please search existing issues to avoid creating duplicates. -->
- EdgeDB Version: EdgeDB 1.2+5aecabc
- OS Version: POP_os 21.10

Steps to Reproduce:

1. `const query = e.insert(e.Person, () => ({
      firstName: 'john',
      lastName: 'smith',
    }))`
3. `const person = await query.run(client)`

<!-- If the issue is about a query error, please also provide your schema -->
Schema:
```
module default {
  type Person {
    property firstName -> str;
    property middleName -> str;
    property lastName -> str;

    property fullName := .firstName ++ ' ' ++ .lastName;
  }
}
```


Discussion:
User error.
Re-opening since the InternalServerError is a bug.

Querybuilder generates the (incorrect) edgeql:
```edgeql
INSERT default::Person {
  id
}
```
Hi @jaclarke,

I closed this because I found out I had erroneously used a function when it should have been an object literal.
Yes, the querybuilder insert usage is incorrect, but the ISE is a bug in EdgeDB, and we should also still throw a useful error in the querybuilder. (I've opened an issue for this in edgeql-js)
> we should also still throw a useful error in the querybuilder.

Awesome, agreed.

Resolving patch:
diff --git a/edb/edgeql/compiler/viewgen.py b/edb/edgeql/compiler/viewgen.py
--- a/edb/edgeql/compiler/viewgen.py
+++ b/edb/edgeql/compiler/viewgen.py
@@ -536,12 +536,11 @@ def _normalize_view_ptr_expr(
     ptrname = lexpr.ptr.name
 
     compexpr: Optional[qlast.Expr] = shape_el.compexpr
-    if compexpr is None and is_mutation and shape_el.elements:
-        # Short shape form in INSERT or UPDATE, e.g
-        #     INSERT Foo { bar: Spam { name := 'name' }}
-        # is prohibited.
-        raise errors.EdgeQLSyntaxError(
-            "unexpected ':'", context=steps[-1].context)
+    if compexpr is None and is_mutation:
+        raise errors.QueryError(
+            "mutation queries must specify values with ':='",
+            context=steps[-1].context,
+        )
 
     ptrcls: Optional[s_pointers.Pointer]
 


Test patch:
diff --git a/tests/test_edgeql_insert.py b/tests/test_edgeql_insert.py
--- a/tests/test_edgeql_insert.py
+++ b/tests/test_edgeql_insert.py
@@ -68,6 +68,15 @@ async def test_edgeql_insert_fail_3(self):
                 };
             ''')
 
+    async def test_edgeql_insert_fail_4(self):
+        with self.assertRaisesRegex(
+            edgedb.QueryError,
+            r"mutation queries must specify values with ':='",
+        ):
+            await self.con.execute('''
+                INSERT Person { name };
+            ''')
+
     async def test_edgeql_insert_simple_01(self):
         await self.con.execute(r"""
             INSERT InsertTest {
diff --git a/tests/test_edgeql_update.py b/tests/test_edgeql_update.py
--- a/tests/test_edgeql_update.py
+++ b/tests/test_edgeql_update.py
@@ -3396,8 +3396,9 @@ async def test_edgeql_update_covariant_03(self):
 
     async def test_edgeql_update_subnavigate_01(self):
         with self.assertRaisesRegex(
-                edgedb.EdgeQLSyntaxError,
-                "unexpected ':'"):
+            edgedb.QueryError,
+            r"mutation queries must specify values with ':='",
+        ):
             await self.con.execute('''
                 UPDATE UpdateTest
                 SET {