Writing a textual based SQL like search for documents. Close to a Westlaw syntax.
This search has a syntax error:

select field1, field2,, field3 from documents   

Should I tell them the ",," is wrong and make them fix it or just remove the second ","?

Would you go even further and if the field name is not correct but within one or two characters of a valid name then replace it. In the select it would be non-destructive. In the where I would not auto-fix.

where subjext = 'spam'

My users are not technical and impatient but amazingly like a Westlaw like syntax

2 Answers 2


Given that your average grandma will not be writing this SQL like text, but more likely technical users such as programmers, DBAs or others that will already be familiar with the concept of proper "programming language" syntax, I say throw the error back to the user, since they likely are already used to fixing minor syntactical errors.

A few examples that come to mind ...

  • While editing a function within a google spreadsheet, it yells at you for any little thing being off.
  • Task Queries in Atlassian's JIRA, are not forgiving as well and are broken until you correct them to exactly what is required.
  • Then there's the countless number of programming languages, query languages and compilers that do the same thing, if something is off, the user needs to fix it or else they just give up.

Generally there is good reason to follow strict syntax requirements, namely you are telling a computer to perform specific functions or commands, and having any ambiguity may return undesired or varying results.

Considering the user experience involved with the user writing these queries, if the end results of "effectively the same" queries yield different results, then that user will have less trust in the query language to get exactly what they are querying for.

Sure it might be nice to help the user out by removing that extra comma, but what if later in your language you want to assign a special meaning to a double comma ",," or even an empty value between commas? Sure it might not happen, but by keeping the syntax strict you would later have the freedom to extend your language with additional features that may have been hampered by too loose of syntactical requirements early on.

Of course, if you don't foresee ever having a special meaning for ", ," then this arguably could be one place to make an exception; however, once you start making an exception in one place, it's easier to make them in other places as well, and pretty soon you could be maintaining a big mess of extra logic that could have been avoided.

I definitely would not correct the spelling of variables, such as subject. If you do then you may end up maintaining a big giant list of misspelled words that map to "subject", and if at some future time one of those misspelled variants actually was some other field name your system now supports, then this would break any existing saved queries, which would frustrate many users at that point.

To summarize, by keeping the syntax strict and simple, the experience of using a straightforward query language that does exactly what you tell it to do, would outweigh any minor inconvenience cause by small syntactical errors that I can quickly fix along the way.

  • That was kind of my thought too. I don't have to translate close - I use levenshtein distance and they love it other areas. Email and similar email. Subject and similar subject. The grammar is not like to change.
    – paparazzo
    Sep 15, 2016 at 0:26
  • Like a good IDE though, in addition to enforcing strict syntax rules, you should strive to provide interactive hints as soon as possible (after each keystroke?) when the entry deviates from the grammar. Sep 22, 2016 at 2:19

I would also shy away from the idea of fixing anything FOR the user without being very explicit about what you've done for them, and giving them the option to undo it. Clear validation messages about what they've done wrong and how to fix it will be very helpful however.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.