From: Michael Neumann Date: 2003-02-01T22:54:40+09:00 Subject: Re: ruby-dbi and oracle error - ORA-24374 - upon further review --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Daniel Berger wrote: > > > > On Friday, January 31, 2003, 2:16:24 AM, Daniel wrote: > > > > > I've noticed a parsing problem with leading sql comments and sql that > > ends > > > with a placeholder. For example, > > > > > --random comment > > > select column1, column2 > > > from table1 > > > where somevalue > ? > > > > I should have posted a more accurate comment. Try this: > > --Dan's query > --random comment > select column1, column2 > from table1 > where somevalue = ? Try out the newest lib/dbi/sql.rb file from CVS or use the attached patch. Regards, Michael --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sql.rb.diff" =================================================================== RCS file: /cvsroot/ruby-dbi/src/lib/dbi/sql.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -c -r1.12 -r1.13 *** ruby-dbi/src/lib/dbi/sql.rb 2002/02/06 14:24:21 1.12 --- ruby-dbi/src/lib/dbi/sql.rb 2003/02/01 13:45:23 1.13 *************** *** 1,5 **** # ! # $Id: sql.rb,v 1.12 2002/02/06 14:24:21 mneumann Exp $ # # parts extracted from Jim Weirichs DBD::Pg # --- 1,5 ---- # ! # $Id: sql.rb,v 1.13 2003/02/01 13:45:23 mneumann Exp $ # # parts extracted from Jim Weirichs DBD::Pg # *************** *** 140,151 **** # 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. Note: comments are not ! # handled. # def tokens(sql) ! toks = sql.scan(/('([^'\\]|''|\\.)*'|"([^"\\]|""|\\.)*"|\?\??|[^'"?]+)/) ! toks.collect {|t| t[0]} end end # module BasicBind --- 140,166 ---- # 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 end # module BasicBind --wRRV7LY7NUeQGEoC--