The current function implementation for dbOpenParenthesis will not add the necessary "AND" / "OR" to the SQL string. Also, it should be permitted for the WHERE clause to start with "(" and not require something else first.
Here's a suggested function implementation (included in the pull request):
on dbOpenParenthesis pConcatenationOperator
if pConcatenationOperator is empty then
put "AND" into pConcatenationOperator
end if
-- BWM - properly handle concatenation operator when parenthesis used
if the last word of dbA["where"] = "(" then
put empty into pConcatenationOperator
end if
if dbA["where"] is not empty then
put " " & pConcatenationOperator && "(" after dbA["where"]
else
put "WHERE (" before dbA["where"]
end if
-- BWM - count opening parenthesis so they can be automatically closed
if dbA["parenLevel"] is empty then
put 1 into dbA["parenLevel"]
else
add 1 to dbA["parenLevel"]
end if
end dbOpenParenthesis
Here is the corresponding code for close:
on dbCloseParenthesis
--BWM - use open parenthesis level to check if call is valid
if dbA["parenLevel"] > 0 then
put " ) " after dbA["where"]
subtract 1 from dbA["parenLevel"]
end if
end dbCloseParenthesis
The current function implementation for dbOpenParenthesis will not add the necessary "AND" / "OR" to the SQL string. Also, it should be permitted for the WHERE clause to start with "(" and not require something else first.
Here's a suggested function implementation (included in the pull request):
Here is the corresponding code for close: