How to escape a reserved sql keyword in a Ballerina ParameterizedQuery
13:26 24 Nov 2025

I have a table named groups in my db and the following code that queries it:

sql:ParameterizedQuery query = `
    SELECT DISTINCT
        g.group_id,
        g.group_name,
        g.org_uuid,
        g.description,
        g.created_at,
        g.updated_at
    FROM groups g
    INNER JOIN group_user_mapping gum ON g.group_id = gum.group_id
    WHERE gum.user_uuid = ${userUuid}
    ORDER BY g.group_name
`;

sql:Client dbClient = getDbClient();
stream resultStream = dbClient->query(query);

Group[] groups = check from Group group in resultStream
    select group;

check resultStream.close();
return groups;

This worked fine with an h2 db, but when I connect to a mysql db, it results in the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version 
for the right syntax to use near 'groups g
        INNER JOIN group_user_mapping gum ON g.group_id = gum.group_id
' at line 8.

I tried escaping the word with "groups", 'groups', and [groups] which all gave the same error. Claude suggested using \`groups\` but that gives a syntax error. What is the proper way to escape this?

ballerina ballerina-swan-lake