Copilot commented on code in PR #2405:
URL: https://github.com/apache/age/pull/2405#discussion_r3149448395
##########
regress/sql/agtype.sql:
##########
@@ -229,6 +229,13 @@ SELECT '3'::agtype + '3.14'::agtype;
SELECT '3'::agtype + '3.14::numeric'::agtype;
SELECT '3.14'::agtype + '3.14::numeric'::agtype;
SELECT '3.14::numeric'::agtype + '3.14::numeric'::agtype;
+SELECT 'null'::agtype - '1';
+SELECT 'null'::agtype + '1';
+SELECT 'null'::agtype * '1';
+SELECT 'null'::agtype / '1';
+SELECT 'null'::agtype % '1';
+SELECT 'null'::agtype ^ '1';
Review Comment:
These tests pass a bare string literal as the RHS (type `unknown`), which
relies on implicit coercion/operator resolution and can make the intent of
testing the *scalar agtype operator path* less explicit. Consider casting the
RHS to `agtype` (e.g., `'1'::agtype`) so the tests more directly exercise
agtype-vs-agtype arithmetic and are less sensitive to changes in implicit casts.
```suggestion
SELECT 'null'::agtype ^ '1'::agtype;
```
##########
src/backend/utils/adt/agtype_ops.c:
##########
@@ -165,6 +165,12 @@ Datum agtype_add(PG_FUNCTION_ARGS)
agtv_lhs = get_ith_agtype_value_from_container(&lhs->root, 0);
agtv_rhs = get_ith_agtype_value_from_container(&rhs->root, 0);
+ /* openCypher: arithmetic over null yields null. */
+ if (agtv_lhs->type == AGTV_NULL || agtv_rhs->type == AGTV_NULL)
+ {
+ PG_RETURN_NULL();
+ }
Review Comment:
The identical `AGTV_NULL` short-circuit block is now duplicated across
multiple operator functions (`add/sub/mul/div/mod/pow/neg`). To reduce
repetition and keep behavior consistent over time, consider factoring this into
a small helper (e.g., a static inline function or macro) used by each operator.
--
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]