From a6b5e9c28c45146ac517721cf00b57f729752444 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Thu, 14 Oct 2010 08:12:52 -0700 Subject: [PATCH] add connect_flags to default options and add REMEMBER_OPTIONS to that list. fix NUM2INT to be NUM2ULONG as it should be for flags --- ext/mysql2/client.c | 2 +- lib/mysql2/client.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ext/mysql2/client.c b/ext/mysql2/client.c index cd8c844..8680521 100644 --- a/ext/mysql2/client.c +++ b/ext/mysql2/client.c @@ -174,7 +174,7 @@ static VALUE rb_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE po args.passwd = NIL_P(pass) ? NULL : StringValuePtr(pass); args.db = NIL_P(database) ? NULL : StringValuePtr(database); args.mysql = wrapper->client; - args.client_flag = NUM2INT(flags); + args.client_flag = NUM2ULONG(flags); if (rb_thread_blocking_region(nogvl_connect, &args, RUBY_UBF_IO, 0) == Qfalse) { // unable to connect diff --git a/lib/mysql2/client.rb b/lib/mysql2/client.rb index bf55621..8ba220e 100644 --- a/lib/mysql2/client.rb +++ b/lib/mysql2/client.rb @@ -8,7 +8,8 @@ module Mysql2 :symbolize_keys => false, # return field names as symbols instead of strings :database_timezone => :local, # timezone Mysql2 will assume datetime objects are stored in :application_timezone => nil, # timezone Mysql2 will convert to before handing the object back to the caller - :cache_rows => true # tells Mysql2 to use it's internal row cache for results + :cache_rows => true, # tells Mysql2 to use it's internal row cache for results + :connect_flags => REMEMBER_OPTIONS } def initialize(opts = {}) @@ -31,7 +32,7 @@ module Mysql2 port = opts[:port] || 3306 database = opts[:database] socket = opts[:socket] - flags = opts[:flags] || 0 + flags = opts[:flags] ? opts[:flags] | @query_options[:connect_flags] : @query_options[:connect_flags] connect user, pass, host, port, database, socket, flags end