这是indexloc提供的服务,不要输入任何密码
Skip to content

MS SQL Server empty array inserts raises syntax error #8959

@Aiden0

Description

@Aiden0

Version Information

Server Version: v2.10.0.cli-migrations-v3

Environment

OSS

What is the current behaviour?

If i have a simple table, in sql server database, with columns id and name and I insert an empty array like so:

mutation {
  insert_test_table(objects: []) {
    affected_rows
  }
}

I get the error back:

{
 "errors": [
   {
     "extensions": {
       "code": "unexpected",
       "internal": {
         "exception": {
           "message": "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near 'VALUES'.",
           "type": "unsuccessful_return_code"
         },
         "query": "INSERT INTO [dbo].[test_table] OUTPUT INSERTED.[name], INSERTED.[id] INTO #inserted([name], [id]) VALUES "
       },
       "path": "$"
     },
     "message": "database query error"
   }
 ]
}

What is the expected behaviour?

Should give the response:

{
  "data": {
    "insert_test_tables": {
      "affected_rows": 0
    }
  }
}

which it does for PostgreSQL database.

How to reproduce the issue?

  1. Create any table
  2. do graphql insert with objects being empty array on that table

Can you identify the location in the source code where the problem exists?

I think it is occurring here. I am not too familiar with Haskell, so will have to look at more later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions