Skip to content

Commit 068df84

Browse files
committed
Pass all tests for DBLIB/TinyTDS connection mode and current state of rails 3.1.
1 parent 8fb299b commit 068df84

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ def execute(sql, name = nil)
1616
end
1717

1818
def exec_query(sql, name = 'SQL', binds = [])
19+
return raw_select(sql, name, binds, :ar_result => true) if binds.empty?
1920
if id_insert_table_name = query_requires_identity_insert?(sql)
20-
with_identity_insert_enabled(id_insert_table_name) do
21-
binds.empty? ? raw_select(sql, name, binds, :ar_result => true) : do_exec_query(sql, name, binds)
22-
end
21+
with_identity_insert_enabled(id_insert_table_name) { do_exec_query(sql, name, binds) }
2322
else
24-
binds.empty? ? raw_select(sql, name, binds, :ar_result => true) : do_exec_query(sql, name, binds)
23+
do_exec_query(sql, name, binds)
2524
end
2625
end
2726

2827
def exec_insert(sql, name, binds)
28+
sql = "#{sql}; SELECT CAST(SCOPE_IDENTITY() AS bigint) AS Ident"
2929
exec_query(sql, name, binds)
3030
end
3131

lib/active_record/connection_adapters/sqlserver/schema_statements.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ def indexes(table_name, name = nil)
3939

4040
def columns(table_name, name = nil)
4141
return [] if table_name.blank?
42+
<<<<<<< HEAD
4243
cache_key = unqualify_table_name(table_name)
44+
=======
45+
cache_key = columns_cache_key(table_name)
46+
>>>>>>> Pass all tests for DBLIB/TinyTDS connection mode and current state of rails 3.1.
4347
column_definitions(table_name).collect do |ci|
4448
sqlserver_options = ci.except(:name,:default_value,:type,:null).merge(:database_year=>database_year)
4549
SQLServerColumn.new ci[:name], ci[:default_value], ci[:type], ci[:null], sqlserver_options
@@ -198,8 +202,16 @@ def column_definitions(table_name)
198202
ELSE 1
199203
END as is_identity
200204
FROM #{db_name_with_period}INFORMATION_SCHEMA.COLUMNS columns
205+
<<<<<<< HEAD
201206
WHERE columns.TABLE_NAME = @0
207+
=======
208+
<<<<<<< HEAD
209+
WHERE columns.TABLE_NAME = '#{table_name}'
210+
>>>>>>> Pass all tests for DBLIB/TinyTDS connection mode and current state of rails 3.1.
202211
AND columns.TABLE_SCHEMA = #{table_schema.nil? ? "schema_name() " : "'#{table_schema}' "}
212+
=======
213+
WHERE columns.TABLE_NAME = @0
214+
>>>>>>> Pass all tests for DBLIB/TinyTDS connection mode and current state of rails 3.1.
203215
ORDER BY columns.ordinal_position
204216
}.gsub(/[ \t\r\n]+/,' ')
205217
results = info_schema_query { do_exec_query(sql, 'InfoSchema::ColumnDefinitions', [['table_name', table_name]]) }

test/cases/sqlserver_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def method_added(method)
8282
module ActiveRecord
8383
class SQLCounter
8484
IGNORED_SQL << %r|SELECT SCOPE_IDENTITY| << %r{INFORMATION_SCHEMA\.(TABLES|VIEWS|COLUMNS)} <<
85-
%r|SELECT @@IDENTITY| << %r|SELECT @@ROWCOUNT| << %r|SELECT @@version| << %r|SELECT @@TRANCOUNT|
85+
%r|SELECT @@IDENTITY| << %r|SELECT @@ROWCOUNT| << %r|SELECT @@version| << %r|SELECT @@TRANCOUNT| <<
86+
%r{(BEGIN|COMMIT|ROLLBACK|SAVE) TRANSACTION}
8687

8788
end
8889
end

0 commit comments

Comments
 (0)