Zainab-Saad commented on code in PR #905:
URL: https://github.com/apache/age/pull/905#discussion_r1189040581
##########
regress/expected/agtype.out:
##########
@@ -2138,6 +2142,50 @@ SELECT agtype_to_int8(agtype_in('false'));
0
(1 row)
+--
+-- Test boolean to integer cast
+--
+SELECT agtype_to_int4(agtype_in('true'));
+ agtype_to_int4
+----------------
+ 1
+(1 row)
+
+SELECT agtype_to_int4(agtype_in('false'));
+ agtype_to_int4
+----------------
+ 0
+(1 row)
+
+SELECT agtype_to_int4(agtype_in('null'));
+ agtype_to_int4
+----------------
+
+(1 row)
+
+SELECT agtype_to_int4(agtype_in('1'));
+ agtype_to_int4
+----------------
+ 1
+(1 row)
+
+SELECT agtype_to_int4(agtype_in('1.45'));
+ agtype_to_int4
+----------------
+ 1
+(1 row)
+
+SELECT agtype_to_int4(agtype_in('1.444::numeric'));
+ agtype_to_int4
+----------------
+ 1
+(1 row)
+
+-- These should all fail
+SELECT agtype_to_int4(agtype_in('"string"'));
+ERROR: invalid input syntax for integer: "string"
+SELECT agtype_to_int4(agtype_in('[1, 2, 3]'));
+ERROR: cannot cast agtype array to type int
Review Comment:
`SELECT agtype_to_int4(1);` and `SELECT agtype_to_int4(true);` termiantes
the connection to server. The other two give error.
--
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]