Skip to content

String ordering returns unexpected results for uppercase and lowercase values #2604

Open

Description

@YGY-001

Environment

  • Apache AGE: 1.8.0
  • PostgreSQL: 18.6
  • Docker image: apache/age:release_PG18_1.8.0
  • Access method: psql

Description

String comparison results appear inconsistent with Unicode code point order.
For example, uppercase D (U+0044) is less than lowercase a (U+0061), but AGE
returns false for 'D' < 'a'.

Reproduction

Environment setup:

LOAD 'age';
SET search_path = ag_catalog, public;
SELECT create_graph('test');

Run:

SELECT * FROM cypher('test', $$
  RETURN 'D' < 'a' AS upper_before_lower,
         'DD' < 'a' AS doubled_before_lower,
         'DD' >= 'a' AS doubled_gte_lower
$$) AS (
  upper_before_lower agtype,
  doubled_before_lower agtype,
  doubled_gte_lower agtype
);

Actual result

false | false | true

Expected result

true | true | false

Impact

The comparison also affects predicates over concatenated strings:

SELECT * FROM cypher('test', $$
UNWIND ['D', 'eUu'] AS value
RETURN value,
value + value AS doubled,
NOT ((value + value) >= 'a') AS keep
$$) AS (value agtype, doubled agtype, keep agtype);

AGE returns keep=false for both rows. Based on code point ordering, the
expected values are keep=true for D and keep=false for eUu.

Activity

  1. Almaryj1 commented on Nov 13, 2026

    @Almaryj1

    Hi @jrgemignani @YGY-001 , I'd like to work on this. I'll add a regression test to document this string ordering behaviour. Will submit a PR shortly.

  2. Almaryj1 commented on Nov 13, 2026

    @Almaryj1

    I've submitted a PR with regression tests documenting this string ordering behavior: #2610. @jrgemignani would love your feedback when you get a chance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions