“map data type” 的正确语法是 “映射数据类型”。

huangapple go评论46阅读模式
英文:

The correct syntax for map data type in age

问题

The correct syntax for the map age data type is:

{‘name’: ‘John’, ‘age’: 23}

Both syntax examples you provided use a comma , as the separator. The second example with a semicolon ; is not valid.

英文:

What is the correct syntax for the map age data type

{‘name’: ‘John’, ‘age’: 23}

Or

{‘name’: ‘John’; ‘age’: 23}

Pay attention to the separator , and ;. Both syntax have been used in the age docs. Are both valid or it’s just a typo?

答案1

得分: 1

需要逗号分隔符,; 是一个拼写错误。

英文:

You need the comma separator, ; is a typo

答案2

得分: 1

这是一个明显的拼写错误。您应该使用逗号作为属性分隔符。

在操作中:

使用 ; 分隔符输出(不起作用):

test=# select * from cypher('test_graph', $$
test$# CREATE (n:Person {name:'mohamed'; age:12}) RETURN n; $$) as (res agtype);
ERROR:  syntax error at or near ";"
LINE 2: CREATE (n:Person {name:'mohamed'; age:12}) RETURN n $$) as ...

使用 , 分隔符输出(有效):

select * from cypher('test_graph', $$
CREATE (n:Person {name:'mohamed', age:12}) RETURN n $$) as (res agtype);
                                               res                              
--------------------------------------------------------------------------------
 { "id": 844424930131969, "label": "Person", "properties": {"age": 12, "name": "mohamed"}}::vertex
(1 row)

请参考Apache AGE手册:https://age.apache.org/age-manual/master/intro/types.html#accessing-list-elements-in-maps

英文:

It is a typo for sure. You should use comma as a properties separator.
In action:
using ; separator outputs (not working):

test=# select * from cypher('test_graph', $$
test$# CREATE (n:Person {name:'mohamed'; age:12}) RETURN n; $$) as (res agtype);
ERROR:  syntax error at or near ";"
LINE 2: CREATE (n:Person {name:'mohamed'; age:12}) RETURN n $$) as ...

using , separator outputs (working):

select * from cypher('test_graph', $$
CREATE (n:Person {name:'mohamed', age:12}) RETURN n $$) as (res agtype);
                                               res                              
                  
--------------------------------------------------------------------------------
------------------
 {"id": 844424930131969, "label": "Person", "properties": {"age": 12, "name": "m
ohamed"}}::vertex
(1 row)

Referring to the Apache AGE manual: https://age.apache.org/age-manual/master/intro/types.html#accessing-list-elements-in-maps

答案3

得分: 1

使用逗号 , 作为分隔符是在类似以下示例中的映射语法中的正确方法

SELECT *
FROM cypher('graph_name', $$
    WITH {int_key: 1, float_key: 1.0, numeric_key: 1::numeric, bool_key: true, string_key: 'Value'} as m
    RETURN m
$$) AS (m agtype);

参考:AGE文档中的数据类型

英文:

using separator , is the correct way in the map syntax like the following example

SELECT *
FROM cypher('graph_name', $$
    WITH {int_key: 1, float_key: 1.0, numeric_key: 1::numeric, bool_key: true, string_key: 'Value'} as m
    RETURN m
$$) AS (m agtype);

Ref: Data Types in a AGE docs

答案4

得分: 1

对于地图,您需要使用“,”而不是“:”。

这在链接中有解释。

英文:

For the map, you need to use ',' and not ':'.

This is explained in the link.

答案5

得分: 1

以下是要翻译的内容:

正确的语法在您的情况下应为:

> {'name': 'John', 'age': 23}

使用分号作为分隔符是错误的。这基本上是一个打字错误或错误。

英文:

The correct syntax in your case would be:

> {'name': 'John', 'age': 23}

The use of semicolon as a separator is wrong. It is basically a typo or error.

答案6

得分: 1

以下是翻译好的部分:

下面的查询解释了如何使用Cypher查询创建地图:

SELECT *
FROM cypher('graph_name', $$
WITH {key: 1, lenght_value: 1.0, numeric_key: 1::numeric, bool_key: true, 
name: 'Waleed Ahmed Shahid'} as m
RETURN m
$$) AS (m agtype);

我们还可以创建包含复合数据类型的地图。下面的查询解释了这一点:

SELECT *
FROM cypher('graph_name', $$
WITH {listKey: [{inner: 'Map1'}, {inner: 'Map2'}], mapKey: {i: 0}} as m
RETURN m
$$) AS (m agtype);

从上面的示例中,您可以看到正在创建地图,并且上面的示例中还创建了嵌套地图和其他变量。

您可以查阅文档以获取更多理解:

文档

英文:

The below query explains how to make a map using the cypher query:

SELECT *
FROM cypher('graph_name', $$
WITH {key: 1, lenght_value: 1.0, numeric_key: 1::numeric, bool_key: true, 
name: 'Waleed Ahmed Shahid'} as m
RETURN m
$$) AS (m agtype);

We can also create a map with composite data types.
The below query explains that:

SELECT *
FROM cypher('graph_name', $$
WITH {listKey: [{inner: 'Map1'}, {inner: 'Map2'}], mapKey: {i: 0}} as m
RETURN m
$$) AS (m agtype);

You can see from the above example that a map is being made and the nested maps and other variables have also been created in the above example.

You can consult the documentation for more understanding.

Documentation

答案7

得分: -1

正确的地图数据类型语法是逗号(,)作为键值对之间的分隔符。使用分号(;)是一个拼写错误。

英文:

The correct syntax for the map data type is the comma (,) as the separator between key-value pairs. Using (;) is a typo.

答案8

得分: -1

For map age data type, you must use (,) and (;) is a typo.

SELECT *
FROM cypher('graph_name', $$
WITH {int_key: 1, float_key: 1.0, numeric_key: 1::numeric, bool_key: true, string_key: 'Value'} as m
RETURN m
$$) AS (m agtype);

You can follow this tutorial & official docs.

英文:

Basically, For map age data type, you must use (,) and (;) is a typo.

<!-- begin snippet: js hide: false console: true babel: false -->

SELECT *
FROM cypher(&#39;graph_name&#39;, $$
    WITH {int_key: 1, float_key: 1.0, numeric_key: 1::numeric, bool_key: true, string_key: &#39;Value&#39;} as m
    RETURN m
$$) AS (m agtype);

You can follow this tutorial & official docs.

答案9

得分: -1

逗号分隔的有效,分号不是。

英文:

The one with comma separator is valid not with semi-colon.

答案10

得分: -1

Apache AGE主要基于属性图模型,地图数据类型的正确语法是使用逗号(,)作为键值对之间的分隔符。分号(;)不是有效的分隔符。

在AGE中,地图数据类型的正确语法应为:

{ 'name': 'John', 'age': 23 }

这是一个简单的示例,展示了在AGE语法中使用地图来存储和表示产品实体的属性。

英文:

Apache AGE is primarily based on the property graph model and the correct syntax for the map data type is to use the comma (,) as the separator between key-value pairs. The semicolon (;) is not a valid separator.

The correct syntax for a map data type in AGE would be:

{ &#39;name&#39;: &#39;John&#39;, &#39;age&#39;: 23 }

This is a simple example showcasing the use of a map to store and represent the properties of a product entity in the AGE syntax.

答案11

得分: -1

这肯定是一个拼写错误,逗号是有效的分隔符,而不是分号。

英文:

It surely is a typo, comma is a valid separator and not semicolon.

huangapple
  • 本文由 发表于 2023年5月21日 20:15:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76299861.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定