misc updates

This commit is contained in:
Brian Lopez 2010-03-30 23:54:07 -07:00
parent 1848b0da4a
commit 26619b10b6
2 changed files with 11 additions and 12 deletions

View File

@ -16,12 +16,12 @@ Benchmark.bmbm do |x|
puts "Mysql" puts "Mysql"
number_of.times do number_of.times do
mysql_result = mysql.query sql mysql_result = mysql.query sql
number = 0 # number = 0
mysql_result.each_hash do |res| mysql_result.each_hash do |res|
number += 1 # number += 1
# puts res.inspect # puts res.inspect
end end
puts "Processed #{number} results" # puts "Processed #{number} results"
end end
end end
@ -31,12 +31,12 @@ Benchmark.bmbm do |x|
puts "Mysql2" puts "Mysql2"
number_of.times do number_of.times do
mysql2_result = mysql2.query sql mysql2_result = mysql2.query sql
number = 0 # number = 0
mysql2_result.each(:symbolize_keys => true) do |res| mysql2_result.each(:symbolize_keys => true) do |res|
number += 1 # number += 1
# puts res.inspect # puts res.inspect
end end
puts "Processed #{number} results" # puts "Processed #{number} results"
end end
end end
end end

View File

@ -137,7 +137,7 @@ static VALUE rb_mysql_result_fetch_row(int argc, VALUE * argv, VALUE self) {
} else { } else {
val = Qtrue; val = Qtrue;
} }
break; //infer_ruby_type break;
case MYSQL_TYPE_BIT: // BIT field (MySQL 5.0.3 and up) case MYSQL_TYPE_BIT: // BIT field (MySQL 5.0.3 and up)
case MYSQL_TYPE_SHORT: // SMALLINT field case MYSQL_TYPE_SHORT: // SMALLINT field
case MYSQL_TYPE_LONG: // INTEGER field case MYSQL_TYPE_LONG: // INTEGER field
@ -158,16 +158,16 @@ static VALUE rb_mysql_result_fetch_row(int argc, VALUE * argv, VALUE self) {
case MYSQL_TYPE_TIME: // TIME field case MYSQL_TYPE_TIME: // TIME field
case MYSQL_TYPE_DATETIME: // DATETIME field case MYSQL_TYPE_DATETIME: // DATETIME field
// if (memcmp("0000-00-00 00:00:00", row[i], 19) == 0) { // if (memcmp("0000-00-00 00:00:00", row[i], 19) == 0) {
val = rb_str_new(row[i], fieldLengths[i]); // val = rb_str_new(row[i], fieldLengths[i]);
// } else { // } else {
// val = rb_funcall(rb_cTime, intern_parse, 1, rb_str_new(row[i], fieldLengths[i])); // val = rb_funcall(rb_cTime, intern_parse, 1, rb_str_new(row[i], fieldLengths[i]));
// } // }
break; // break;
case MYSQL_TYPE_DATE: // DATE field case MYSQL_TYPE_DATE: // DATE field
case MYSQL_TYPE_NEWDATE: // Newer const used > 5.0 case MYSQL_TYPE_NEWDATE: // Newer const used > 5.0
// val = rb_funcall(cDate, intern_parse, 1, rb_str_new(row[i], fieldLengths[i])); // val = rb_funcall(cDate, intern_parse, 1, rb_str_new(row[i], fieldLengths[i]));
val = rb_str_new(row[i], fieldLengths[i]); // val = rb_str_new(row[i], fieldLengths[i]);
break; // break;
case MYSQL_TYPE_SET: // SET field case MYSQL_TYPE_SET: // SET field
case MYSQL_TYPE_ENUM: // ENUM field case MYSQL_TYPE_ENUM: // ENUM field
case MYSQL_TYPE_GEOMETRY: // Spatial fielda case MYSQL_TYPE_GEOMETRY: // Spatial fielda
@ -175,7 +175,6 @@ static VALUE rb_mysql_result_fetch_row(int argc, VALUE * argv, VALUE self) {
val = rb_str_new(row[i], fieldLengths[i]); val = rb_str_new(row[i], fieldLengths[i]);
break; break;
} }
// TODO: determine field type then inflate a new ruby object around it
rb_hash_aset(rowHash, key, val); rb_hash_aset(rowHash, key, val);
} else { } else {
rb_hash_aset(rowHash, key, Qnil); rb_hash_aset(rowHash, key, Qnil);