Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tons of bug fixes.

* Fix exists? with offset by patching visitor. Fixes #171 and Fixes #167
* Set default text size to 2147483647 for TinyTDS connections. Fixes #181
* Set @config ivar for 3rd party libs. Fixes #177
* Make #sql_type_for_statement work for integers that may have empty parens or none at all. Fixes #175
  • Loading branch information...
commit 8c9f89e0d7d4b32ae10a011cb2bc2c24de13fe1a 1 parent 18f4d02
@metaskills metaskills authored
View
11 CHANGELOG
@@ -1,4 +1,15 @@
+* 3.2.2 *
+
+* Fix exists? with offset by patching visitor. Fixes #171 and Fixes #167
+
+* Set default text size to 2147483647 for TinyTDS connections. Fixes #181
+
+* Set @config ivar for 3rd party libs. Fixes #177
+
+* Make #sql_type_for_statement work for integers that may have empty parens or none at all. Fixes #175
+
+
* 3.2.1 *
* Add explicit order-by clause for windowed results. Fixes #161.
View
4 lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -96,7 +96,7 @@ def is_real?
def sql_type_for_statement
if is_integer? || is_real?
- sql_type.sub(/\(\d+\)/,'')
+ sql_type.sub(/\((\d+)?\)/,'')
else
sql_type
end
@@ -199,6 +199,7 @@ def initialize(connection, logger, pool, config)
@schema_cache = Sqlserver::SchemaCache.new self
@visitor = Arel::Visitors::SQLServer.new self
# Our Responsibility
+ @config = config
@connection_options = config
connect
@database_version = select_value 'SELECT @@version', 'SCHEMA'
@@ -438,6 +439,7 @@ def connect
client.execute("SET CURSOR_CLOSE_ON_COMMIT OFF").do
client.execute("SET IMPLICIT_TRANSACTIONS OFF").do
end
+ client.execute("SET TEXTSIZE 2147483647").do
end
when :odbc
if config[:dsn].include?(';')
View
2  lib/arel/visitors/sqlserver.rb
@@ -156,7 +156,7 @@ def visit_Arel_Nodes_SelectStatementWithOutOffset(o, windowed=false)
[ ("SELECT" if !windowed),
(visit(core.set_quantifier) if core.set_quantifier),
(visit(o.limit) if o.limit && !windowed),
- (projections.map{ |x| visit(x) }.join(', ')),
+ (projections.map{ |x| v = visit(x); v == "1" ? "1 AS [__wrp]" : v }.join(', ')),
(source_with_lock_for_select_statement(o)),
("WHERE #{core.wheres.map{ |x| visit(x) }.join ' AND ' }" unless core.wheres.empty?),
("GROUP BY #{groups.map { |x| visit x }.join ', ' }" unless groups.empty?),
View
8 test/cases/offset_and_limit_test_sqlserver.rb
@@ -20,10 +20,14 @@ class OffsetAndLimitTestSqlserver < ActiveRecord::TestCase
context 'When selecting with offset' do
- should 'have limit (top) of 2147483647 if only offset is passed' do
+ should 'have limit (top) of 9223372036854775807 if only offset is passed' do
assert_sql(/SELECT TOP \(9223372036854775807\) \[__rnt\]\.\* FROM.*WHERE \[__rnt\]\.\[__rn\] > \(1\)/) { Book.all(:offset=>1) }
end
-
+
+ should 'support calling exists?' do
+ assert Book.offset(3).exists?
+ end
+
end
context 'When selecting with limit and offset' do
Please sign in to comment.
Something went wrong with that request. Please try again.