zshamrock / dynosql

Run SQL queries against DynamoDB
GNU General Public License v3.0
3 stars 0 forks source link

Rewrite the logic of processing WHERE statement #30

Closed zshamrock closed 6 years ago

zshamrock commented 6 years ago

Considering how relatively complex WHERE statement could be, i.e. IN, functions, IS NULL, IS NOT NULL, spaces in the string literals, parens, as well as detecting the type of the literal (i.e. number or string) I thought of the different approach of parsing the WHERE statement.

The idea is to parse WHERE condition character by character, identifying the token (also including parens, quotes, commas, etc.) and establish the context, where the action will depend on the current context, i.e. inside the string, or inside the IN, etc.

This also allows to do the validation where knowing the current token we can validate the next token on the list of the supported tokens for the current one. Ex.: IN token expects the next one will be '(', etc.

Hope this allows to resolve all SQL related tickets all at once.