Skip to content

Commit 9bb1724

Browse files
author
Anna
committed
tidying
1 parent fb1740d commit 9bb1724

File tree

8 files changed

+23
-9
lines changed

8 files changed

+23
-9
lines changed

Gemfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ group :development do
4646
gem 'rake', '~> 0.9.2'
4747
gem 'ruby-prof'
4848
gem 'simplecov'
49-
gem 'turn'
50-
gem 'rubocop'
5149
gem 'ruby-graphviz'
5250
end
5351

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def execute(sql, name = nil)
1515
end
1616
end
1717

18+
# TODO I bet there's a better way than a regex to take care of this
1819
def exec_query(sql, name = 'SQL', binds = [], sqlserver_options = {})
1920
# We can't update Identiy columns in sqlserver. So, strip out the id from the update.
2021
if sql =~ /UPDATE/

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def initialize(name, default, sql_type = nil, null = true, sqlserver_options = {
6666
class << self
6767

6868
def string_to_binary(value)
69-
"0x#{value.unpack("H*")[0]}"
69+
"0x#{value.unpack("H*")[0]}"
7070
end
7171

7272
def binary_to_string(value)

lib/arel/visitors/sqlserver.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class SQLServer < Arel::Visitors::ToSql
2828
# SQLServer ToSql/Visitor (Overides)
2929

3030
def visit_Arel_Nodes_SelectStatement(o, a)
31-
puts "o.cores.size#{o.cores.size}" unless o.cores.size < 2
3231
if complex_count_sql?(o)
3332
visit_Arel_Nodes_SelectStatementForComplexCount(o, a)
3433
elsif o.offset

test/cases/column_test_sqlserver.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
require 'models_sqlserver/sql_server_string'
88
require 'models_sqlserver/sql_server_unicode'
99
require 'models_sqlserver/table_with_real_column'
10-
1110
require 'models_sqlserver/topic'
1211
require "cases/migration/helper"
1312

test/cases/finder_test_sqlserver.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
require 'cases/sqlserver_helper'
22
require 'models/event'
3+
require 'models/author'
4+
require 'models/post'
35
require 'models_sqlserver/topic'
46

57
class FinderTestSqlserver < ActiveRecord::TestCase
68
end
79

810
class FinderTest < ActiveRecord::TestCase
9-
11+
fixtures :authors, :author_addresses, :posts
1012
COERCED_TESTS = [
1113
:test_exists_does_not_select_columns_without_alias,
1214
:test_string_sanitation,
13-
:test_take_and_first_and_last_with_integer_should_use_sql_limit
15+
:test_take_and_first_and_last_with_integer_should_use_sql_limit,
16+
:test_find_with_order_on_included_associations_with_construct_finder_sql_for_association_limiting_and_is_distinct
17+
1418
]
1519

1620
include SqlserverCoercedTest
1721

22+
23+
def test_coerced_find_with_order_on_included_associations_with_construct_finder_sql_for_association_limiting_and_is_distinct
24+
p = Post.all.merge!(:includes => { :authors => :author_address },
25+
:order => 'author_addresses.id DESC ',
26+
:limit => 2)
27+
arel_to_png(p)
28+
assert_equal 2, p.to_a.size
29+
puts "*****#{ActiveRecord::SQLCounter.log_all.join("\n\n")}"
30+
31+
assert_equal 3, Post.all.merge!(:includes => { :author => :author_address, :authors => :author_address},
32+
:order => 'author_addresses_authors.id DESC ', :limit => 3).to_a.size
33+
end
34+
35+
1836
def test_coerced_exists_does_not_select_columns_without_alias
1937
assert_sql(/SELECT TOP \(1\) 1 AS one FROM \[topics\]/i) do
2038
Topic.exists?

test/cases/inheritance_test_sqlserver.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def test_coerced_a_bad_type_column
2424
assert_raise(ActiveRecord::SubclassNotFound) { Company.find(100) }
2525
end
2626

27-
2827
def test_coerced_eager_load_belongs_to_primary_key_quoting
2928
con = Account.connection
3029
assert_sql(/\[companies\]\.\[id\] IN \(N''1''\)/) do
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class SqlServerNaturalPkData < ActiveRecord::Base
22
self.table_name = 'natural_pk_data'
3-
self.primary_key = 'legacy_id'
3+
self.primary_key = 'legacy_id'
44
end

0 commit comments

Comments
 (0)