|
From: Paul D. <pa...@sn...> - 2003-05-15 02:05:50
|
I've recently discovered that single minus signs are being dropped
from queries. For example, this query:
SELECT 1 - 3
gets turned into:
SELECT 1 3
I *believe* this is happening in dbi/sql.rb in the following method:
## Break the sql string into parts.
#
# This is NOT a full lexer for SQL. It just breaks up the SQL
# string enough so that question marks, double question marks and
# quoted strings are separated. This is used when binding
# arguments to "?" in the SQL string.
#
# C-style (/* */) and Ada-style (--) comments are handled.
# Note: Nested C-style comments are NOT handled!
#
def tokens(sql)
sql.scan(%r{
(
-- .* (?# matches "--"
style comments to the end of line or string )
|
/[*] .*? [*]/ (?# matches C-style comments )
|
' ( [^'\\] | '' | \\. )* ' (?# match strings
surrounded by apostophes )
|
" ( [^"\\] | "" | \\. )* " (?# match strings
surrounded by " )
|
\?\?? (?# match one or two
question marks )
|
[^-/'"?]+ (?# match all
characters except ' " ? - and / )
)}x).collect {|t| t.first}
end
If I remove the minus sign from the last pattern ([^-/'"?]+), then
my queries start working again. I don't know what the "proper" fix
is, though.
|