Custom highlighting for property names in SQL

Hello, I am using Codemirror to create a SQL editor. Everything works perfectly, except for property names.

In this example, name is highlighted different color compared to variable name

SELECT orders.*, customer.*, employee.* 
FROM orders
LEFT JOIN customers ON orders.name = customers.name;
LEFT JOIN employees ON orders.name = employees.name;

However, when having some more complex property names e.g customer_id, its not hightlited.

SELECT orders.*, customer.*, employee.* 
FROM orders
LEFT JOIN customers ON orders.customer_id = customers.customer_id;
LEFT JOIN employees ON orders.employee_id = employees.employee_id;

Here is the picture from “Try CodeMirror” explaining what I mean by highlighting property name

The purple color doesn’t indicate it’s a property—it indicates a keyword. The SQL mode doesn’t assign different highlighting tags to identifiers in property position (since those, too, can be tables, when subscripting a schema, this distinction wouldn’t be meaningful). This patch fixes the issue where it parses keywords after periods.

1 Like

Thank you for explaining about that purple highlighting. But If I want to have properties (.something) highlighted in some different color, I would need to write a decorator (Thats what I understand from docs)?

@marijn Pretty much trying to implement highlighting as Programiz has, where they highlight properties with different color.

@marijn This seems to be implemented in CodeMirror 5, works in demo on the website