apache / apache/age

Dynamically unpacking properties with UNWIND and SET s = row fails with Error: properties() argument must resolve to a scalar value

Open
#2,167 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
4.8k
Forks
523
Avg merge
1d 2h
Merged PRs (30d)
9

Description

**Describe the bug**
Similar to a previous bug #1634 trying to dynamically unpack properties when using the combination of UNWIND and SET leads to an error: `properties() argument must resolve to a scalar value`

**How are you accessing AGE (Command line, driver, etc.)?**
- Both Command line and NodeJS driver

**What data setup do we need to do?**
- None

**What is the necessary configuration info needed?**
- None

**What is the command that caused the error?**
```pgsql
SELECT * FROM cypher('my_graph_name', $$
UNWIND [{id: 'stock_1', quantity: 100 }] as row
CREATE (s:Stock {id: row.id})
SET s = row
RETURN s
$$) as (a agtype)
```
```
ERROR: properties() argument must resolve to a scalar value
```

**Expected behavior**
Creation of Nodes where all input data are propagated as properties: (Stock {id: 'stock_1', quantity: 100})

As it is when explicitly stating the property key and value:
```pgsql
SELECT * FROM cypher('my_graph_name', $$
UNWIND [{id: 'stock_1', quantity: 100 }] as row
CREATE (s:Stock {id: row.id})
SET s.quantity = row.quantity
RETURN s
$$) as (s agtype)
```

**Environment (please complete the following information):**
- Version: 1.5.0 running in Docker and on an Azure Database for PostgreSQL flexible server

**Additional context**
For Neo4j using the combination of UNWIND and SET does work as expected:
```pgsql
UNWIND [{id: 'stock_1', quantity: 100 }] AS row
MERGE (n:${nodeLabel} {id: row.id})
SET n = row
RETURN n
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.