age icon indicating copy to clipboard operation
age copied to clipboard

Regression in string concatenation using the + operator

Open konradziczek opened this issue 2 months ago • 6 comments

Describe the bug

In earlier versions, the + operator correctly concatenated data of different types. In v1.6.0 this operator returns an incorrect result. I couldn’t find any information about changes in this behavior in the changelog.

For example:

CREATE (n30164502:Node {data_id: 30164502}) RETURN id(n30164502) + ':test_n' + n30164502.data_id

before returned:

"844424930131969:test_n30164502"

now returns:

"1:test_n22"

I tried to use || operator, but it returned list instead of a string:

[844424930131969, ":test_n", 30164502]

How are you accessing AGE (Command line, driver, etc.)?

  • psycopg2 v2.9.5

Environment (please complete the following information):

  • Version: AGE 1.6.0, PG 16

konradziczek avatar Nov 12 '25 17:11 konradziczek

@konradziczek I am not able to reproduce your previous results in PG16 1.5.0.

In both versions the same pathway is called. The actual conversion of the integer id is done by a PG function called int8out. The code for the AGE part has not been modified since 2020. That being said, the results don't appear to be correct. I will look into this further.

psql-16.2-5432-pgsql=# \dx
                 List of installed extensions
  Name   | Version |   Schema   |         Description
---------+---------+------------+------------------------------
 age     | 1.5.0   | ag_catalog | AGE database extension
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
(2 rows)

psql-16.2-5432-pgsql=# select * from cypher('issue_2243', $$ CREATE (n30164502:Node {data_id: 30164502}) RETURN id(n30164502) + ':test_n' + n30164502.data_id $$ ) as (result agtype);
    result
--------------
 "1:test_n22"
(1 row)

psql-16.2-5432-pgsql=# select * from cypher('issue_2243', $$ CREATE (n30164502:Node {data_id: 30164502}) RETURN id(n30164502) + ':test_n' + n30164502.data_id $$ ) as (result agtype);
    result
--------------
 "2:test_n22"
(1 row)

psql-16.2-5432-pgsql=# select * from cypher('issue_2243', $$ match (u) return id(u) + ":test_n" + u.data_id $$ ) as (result agtype)

    result
--------------
 "1:test_n22"
 "2:test_n22"
(2 rows)

jrgemignani avatar Nov 12 '25 21:11 jrgemignani

@jrgemignani Thank you for taking the time to help. I checked this on version 1.3.0 (I had old image taken from AGE profile on dockerhub) and the behavior was different there (returned "844424930131969:test_n30164502"), but as far as I remember, you should see the same on 1.4.0 (PG 14 from dockerhub) as well.

konradziczek avatar Nov 12 '25 23:11 konradziczek

@konradziczek I'm creating a PR to fix this in the master branch, going forward with the releases that follow 1.6.0. 1.6.0 is already frozen and won't have this fix.

The issue is due to the wrong integer to datum function, thus truncating large numbers. It is possible that, in the lower versions < 1.5.0, a different path was used and this particular function wasn't called.

jrgemignani avatar Nov 13 '25 00:11 jrgemignani

@konradziczek PR #2244

jrgemignani avatar Nov 13 '25 00:11 jrgemignani

Thank you so much!!!

konradziczek avatar Nov 13 '25 23:11 konradziczek

Please don't forget to close this issue if it is resolved :)

jrgemignani avatar Nov 14 '25 21:11 jrgemignani