Skip to content

TRIM(LEADING | TRAILING | BOTH ... FROM x) is a parse error #2800

Open

Description

@mathiasrw

The SQL-92 form TRIM([LEADING | TRAILING | BOTH] [chars] FROM x) is a parse error. TRIM(x) works.

Seen in the NIST SQL Test Suite run: 6 checks in dml112.sql (TRIM (LEADING ' ' FROM SPONSOR)). Reproduced on develop (38bf3c3):

alasql("SELECT TRIM('  xy  ') AS x");                   // [{x: 'xy'}]
alasql("SELECT TRIM(LEADING ' ' FROM '  xy  ') AS x");  // Parse error
alasql("SELECT TRIM(TRAILING FROM '  xy  ') AS x");     // Parse error
alasql("SELECT TRIM(BOTH 'z' FROM 'zzxyz') AS x");      // Parse error
alasql("SELECT TRIM('z' FROM 'zzxyz') AS x");           // Parse error

Expected: 'xy ', ' xy', 'xy' and 'xy'. Without a character the default is a space, and without LEADING, TRAILING or BOTH the default is BOTH.

Breaking?

No. Today these are parse errors.

Activity

  1. modified the milestones: v5.x Focus, v5.0.0 on Oct 22, 2026
  2. mateuscmtropical commented on Nov 11, 2026

    @mateuscmtropical
    Contributor

    Hi, I'd like to work on this one.

  3. mateuscmtropical commented on Nov 11, 2026

    @mateuscmtropical
    Contributor

    Hi, I've opened a PR for this: #3042

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions