Division operator in text/x-sql mode


#1

Not sure if this is a mistake, but the forward slash division operator "/" is not present in list of operatorChars in " text/x-sql" mode.

Rather the backslash key string has been added (not sure if that’s intended for division).

Was this added purposefully?


#2

You say backslash, but show "/", which is called forward slash. Which one did you mean?


#3

Apologies for that. Edited my post.


#4

Ah, right, that looks like an oversight. Fixed in this patch.


#5

Thanks marijn.

I tried using the updated code however it still is not styling the division operator separately. I’m using the “text/x-sql” as mode and typed this in editor -

12/12

Here’s what i see in HTML :

I guess we also require the change in this part of code :

  // A generic SQL Mode. It's not a standard, it just try to support what is generally supported
  CodeMirror.defineMIME("text/x-sql", {
    name: "sql",
    keywords: set(sqlKeywords + "begin"),
    builtin: set("bool boolean bit blob enum long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision real date datetime year unsigned signed decimal numeric"),
    atoms: set("false true null unknown"),
    operatorChars: /^[*+\-%<>!=]/,
    dateSQL: set("date time timestamp"),
    support: set("ODBCdotTable doubleQuote binaryNumber hexNumber")
  }); 

Replace operatorChars: /^[*+-%<>!=]/ with operatorChars: /^[*+-%<>!=\/]/


#6

Hm, seems text/x-sql overrode operatorChars with something that also didn’t include the /. Should be fixed now.


#7

Cool. Working now.