Raising an error in the presence of jdbc properties does work.

On Friday, April 24, 2015 at 4:04:19 PM UTC-5, Jeremy Evans wrote:
>
> On Friday, April 24, 2015 at 7:35:37 AM UTC-7, Adam Komblevitz wrote:
>>
>> We are using jruby 1.6.4 and Sequel 4.2.0 and recently upgraded from 
>> ojdbc14 to ojdbc6 in our Sinatra app. This has caused all the Date columns 
>> to come back as Timestamps, so the format of our query results has changed. 
>> We know we can force the behavior to mirror old behavior by setting the 
>> jdbc property 'oracle.jdbc.mapDateToTimestamp' to 'false', but we have not 
>> been able to do so using the :jdbc_properties element in the connection 
>> options. It seems that we have to enter the rescue block in Jdbc.connect in 
>> order for our property to be set, which we do not execute.
>>
>> We were able to make it work as expected by editing the connect method in 
>> jdbc to include the explicit property setting before creating the 
>> connection. Our changes are highlighted:
>>
>
> Thanks for bringing this issue to my attention. I don't know if there is 
> currently a way to achieve the same results without making modifications.
>
> While your patch does fix things, it results in duplication that I'd 
> rather avoid, and I have no idea how it would affect usage with other jdbc 
> drivers (it may work fine, my JDBC knowledge is limited).
>
> Can you try the following patch and let me know if it works for you?  This 
> patch will automatically skip the 
> JavaSQL::DriverManager.getConnection(*args) code if you have specified the 
> :jdbc_properties option.  This makes sure the :jdbc_properties option is 
> not silently ignored.
>
> Thanks,
> Jeremy
>
> --- a/lib/sequel/adapters/jdbc.rb
> +++ b/lib/sequel/adapters/jdbc.rb
> @@ -204,6 +204,7 @@ module Sequel
>            args.concat([opts[:user], opts[:password]]) if opts[:user] && 
> opts[:password]
>            begin
>              JavaSQL::DriverManager.setLoginTimeout(opts[:login_timeout]) 
> if opts[:login_timeout]
> +            raise StandardError, "skipping regular connection" if 
> opts[:jdbc_properties]
>              JavaSQL::DriverManager.getConnection(*args)
>            rescue JavaSQL::SQLException, NativeException, StandardError => 
> e
>              raise e unless driver
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to