jrgemignani commented on code in PR #895:
URL: https://github.com/apache/age/pull/895#discussion_r1189159431


##########
regress/expected/expr.out:
##########
@@ -1667,6 +1667,135 @@ SELECT agtype_in('[NaN, {"e": 2.718281::numeric, "one": 
Infinity, "pie": 3.14159
  [NaN, {"e": 2.718281::numeric, "one": Infinity, "pie": 3.1415927}, 
2::numeric, null]
 (1 row)
 
+--
+-- Test typecast ::pg_float8
+--
+SELECT * FROM cypher('expr', $$
+RETURN 0::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ 0.0
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN '2.71'::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ 2.71
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN 2.71::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ 2.71
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN ([0, {one: 1, pie: 3.1415927, e: 2::numeric}, 2, 
null][1].one)::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ 1.0
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN ([0, {one: 1::pg_float8, pie: 3.1415927, e: 2.718281::numeric}, 2, 
null][1].one)
+$$) AS r(result agtype);
+ result 
+--------
+ 1.0
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN ([0, {one: 1::pg_float8, pie: 3.1415927, e: 2.718281::numeric}, 2, 
null][1].one)::float
+$$) AS r(result agtype);
+ result 
+--------
+ 1.0
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN ([0, {one: 1, pie: 3.1415927, e: 2.718281::numeric}, 2, 
null][3])::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ 
+(1 row)
+
+-- test NaN, Infinity and -Infinity
+SELECT * FROM cypher('expr', $$
+RETURN 'NaN'::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ NaN
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN 'inf'::pg_float8
+$$) AS r(result agtype);
+  result  
+----------
+ Infinity
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN '-inf'::pg_float8
+$$) AS r(result agtype);
+  result   
+-----------
+ -Infinity
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN 'infinity'::pg_float8
+$$) AS r(result agtype);
+  result  
+----------
+ Infinity
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN '-infinity'::pg_float8
+$$) AS r(result agtype);
+  result   
+-----------
+ -Infinity
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN null::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ 
+(1 row)
+
+-- these should fail
+SELECT * FROM cypher('expr', $$
+RETURN ''::pg_float8
+$$) AS r(result agtype);
+ERROR:  invalid input syntax for type double precision: ""
+SELECT * FROM cypher('expr', $$
+RETURN '2:71'::pg_float8
+$$) AS r(result agtype);
+ERROR:  invalid input syntax for type double precision: "2:71"
+SELECT * FROM cypher('expr', $$
+RETURN 'infi'::pg_float8
+$$) AS r(result agtype);
+ERROR:  invalid input syntax for type double precision: "infi"
+SELECT * FROM cypher('expr', $$

Review Comment:
   Should this fail or does it need to be in a different group?



##########
regress/expected/expr.out:
##########
@@ -1667,6 +1667,135 @@ SELECT agtype_in('[NaN, {"e": 2.718281::numeric, "one": 
Infinity, "pie": 3.14159
  [NaN, {"e": 2.718281::numeric, "one": Infinity, "pie": 3.1415927}, 
2::numeric, null]
 (1 row)
 
+--
+-- Test typecast ::pg_float8
+--
+SELECT * FROM cypher('expr', $$
+RETURN 0::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ 0.0
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN '2.71'::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ 2.71
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN 2.71::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ 2.71
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN ([0, {one: 1, pie: 3.1415927, e: 2::numeric}, 2, 
null][1].one)::pg_float8
+$$) AS r(result agtype);
+ result 
+--------
+ 1.0
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN ([0, {one: 1::pg_float8, pie: 3.1415927, e: 2.718281::numeric}, 2, 
null][1].one)
+$$) AS r(result agtype);
+ result 
+--------
+ 1.0
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN ([0, {one: 1::pg_float8, pie: 3.1415927, e: 2.718281::numeric}, 2, 
null][1].one)::float
+$$) AS r(result agtype);
+ result 
+--------
+ 1.0
+(1 row)
+
+SELECT * FROM cypher('expr', $$
+RETURN ([0, {one: 1, pie: 3.1415927, e: 2.718281::numeric}, 2, 
null][3])::pg_float8

Review Comment:
   what about casting a numeric?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to