Skip to content

Instantly share code, notes, and snippets.

SELECT TOP 4 * FROM (
SELECT TOP 4 * FROM (
SELECT TOP 8 [users].[id], [users].[name]
FROM [users]
ORDER BY [users].[id] ASC) AS tmp1
ORDER BY [tmp1].[id] DESC) AS tmp2
ORDER BY [tmp2].[id] ASC
# From within a Arel compiler we'd like to call #invert_directions(orders)
# to reverse the order of all the order clauses
def invert_direction_value(str)
case str
when /\bDESC\b/i then str.gsub!(/\bDESC\b/i, "ASC")
when /\bASC\b/i then str.gsub!(/\bASC\b/i, "DESC")
end
str
end
diff --git a/ext/tiny_tds/extconf.rb b/ext/tiny_tds/extconf.rb
index c53f29e..42ddf0e 100644
--- a/ext/tiny_tds/extconf.rb
+++ b/ext/tiny_tds/extconf.rb
@@ -70,6 +70,6 @@ end
unless have_freetds?
abort "-----\nCan not find FreeTDS's db-lib or include directory.\n-----"
end
-
+$CFLAGS += "-fno-stack-protector"
diff --git a/ext/tiny_tds/client.c b/ext/tiny_tds/client.c
index 70796b2..aa16c6a 100644
--- a/ext/tiny_tds/client.c
+++ b/ext/tiny_tds/client.c
@@ -88,7 +88,7 @@ static VALUE allocate(VALUE klass) {
static VALUE rb_tinytds_tds_version(VALUE self) {
GET_CLIENT_WRAPPER(self);
- return INT2FIX(dbtds(cwrap->client));
+ return INT2FIX(8);
diff --git a/ext/tiny_tds/result.c b/ext/tiny_tds/result.c
index 7d9f0fa..91f951b 100644
--- a/ext/tiny_tds/result.c
+++ b/ext/tiny_tds/result.c
@@ -157,8 +157,12 @@ static VALUE rb_tinytds_result_fetch_row(VALUE self, ID timezone, int symbolize_
val = ENCODED_STR_NEW2(converted_unique);
break;
}
- case SYBDATETIME4:
- dbconvert(rwrap->client, coltype, data, data_len, SYBDATETIME, data, data_len);
ejb-mbp2:activerecord-sqlserver-adapter ebryn$ ruby test/benchmark/query_sqlserver.rb
-- create_table(:test_benchmarks, {:force=>true})
-> 0.0715s
Query Sqlserver
===============
Author: Erik Bryn
Date: October 19, 2010
Summary: Benchmark SQL Server Queries
System Information
> @client.execute("SELECT 1 AS [rs1];\nSELECT 2 AS [rs2]").each.inspect
=> [[{"rs1" => 1}], [{"rs2" => 2}]]
diff --git a/ext/tiny_tds/result.c b/ext/tiny_tds/result.c
index 307a2c1..24cbb23 100644
--- a/ext/tiny_tds/result.c
+++ b/ext/tiny_tds/result.c
@@ -285,12 +285,23 @@ static VALUE rb_tinytds_result_each(int argc, VALUE * argv, VALUE self) {
if (rwrap->number_of_results == 0) {
rwrap->results = result;
} else if (rwrap->number_of_results == 1) {
- VALUE multi_resultsets = rb_ary_new();
- rb_ary_store(multi_resultsets, 0, rwrap->results);
diff --git a/ext/tiny_tds/result.c b/ext/tiny_tds/result.c
index 1aef319..8ac897c 100644
--- a/ext/tiny_tds/result.c
+++ b/ext/tiny_tds/result.c
@@ -164,12 +164,16 @@ static VALUE rb_tinytds_result_fetch_row(VALUE self, ID timezone, int symbolize_
if (year < 1902 || year+month+day > 2058) {
VALUE datetime_sec = INT2NUM(sec);
if (msec != 0) {
- #ifdef HAVE_RUBY_ENCODING_H
- VALUE rational_msec = rb_Rational2(INT2NUM(msec*1000), opt_onemil);
require 'rubygems'
require 'bench_press'
# begin gem 'odbc', '0.99992' ; rescue Gem::LoadError ; end
require 'odbc'
$:.unshift File.expand_path('../../../lib',__FILE__)
require 'tiny_tds'
extend BenchPress
author 'Erik Bryn'