提交 ce66bfdc 编写于 作者: M Marcin Raczkowski 提交者: Emilio Tagua

IdentityMap - misc fixes

- Added IdentityMap to be included into AR::Base
- Fixed bug with Mysql namespace missing when running tests only for sqlite
- Added sqlite as default connection
上级 ce3ea558
......@@ -1848,6 +1848,7 @@ def populate_with_current_scope_attributes
include ActiveModel::MassAssignmentSecurity
include Callbacks, ActiveModel::Observing, Timestamp
include Associations, AssociationPreload, NamedScope
include IdentityMap
# AutosaveAssociation needs to be included before Transactions, because we want
# #save_with_autosave_associations to be wrapped inside a transaction.
......
......@@ -892,7 +892,9 @@ def setup_fixture_accessors(table_names = nil)
@fixture_cache[table_name].delete(fixture) if force_reload
if @loaded_fixtures[table_name][fixture.to_s]
@fixture_cache[table_name][fixture] ||= @loaded_fixtures[table_name][fixture.to_s].find
ActiveRecord::IdentityMap.without do
@fixture_cache[table_name][fixture] ||= @loaded_fixtures[table_name][fixture.to_s].find
end
else
raise StandardError, "No fixture with name '#{fixture}' found for table '#{table_name}'"
end
......
......@@ -102,7 +102,7 @@ def test_exec_typecasts_bind_vals
end
# Test that MySQL allows multiple results for stored procedures
if Mysql.const_defined?(:CLIENT_MULTI_RESULTS)
if defined?(Mysql) && Mysql.const_defined?(:CLIENT_MULTI_RESULTS)
def test_multi_results
rows = ActiveRecord::Base.connection.select_rows('CALL ten();')
assert_equal 10, rows[0][0].to_i, "ten() did not return 10 as expected: #{rows.inspect}"
......
......@@ -11,7 +11,14 @@
require 'active_record'
require 'active_support/dependencies'
require 'connection'
begin
require 'connection'
rescue LoadError
# If we cannot load connection we assume that driver was not loaded for this test case, so we load sqlite3 as default one.
# This allows for running separate test cases by simply running test file.
connection_type = defined?(JRUBY_VERSION) ? 'jdbc' : 'native'
require "test/connections/#{connection_type}_sqlite3/connection"
end
begin
require 'ruby-debug'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册