activerecord 4.1.7.1 → 4.1.8
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/lib/active_record/associations/through_association.rb +5 -1
- data/lib/active_record/attribute_methods.rb +4 -2
- data/lib/active_record/connection_adapters/abstract/quoting.rb +6 -1
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +13 -1
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +2 -2
- data/lib/active_record/connection_adapters/mysql_adapter.rb +3 -3
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +2 -2
- data/lib/active_record/connection_handling.rb +1 -1
- data/lib/active_record/core.rb +0 -2
- data/lib/active_record/fixtures.rb +6 -6
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/migration.rb +1 -1
- data/lib/active_record/persistence.rb +2 -2
- data/lib/active_record/railties/databases.rake +4 -10
- data/lib/active_record/relation/query_methods.rb +7 -0
- data/lib/active_record/tasks/database_tasks.rb +17 -1
- data/lib/active_record/tasks/mysql_database_tasks.rb +1 -1
- data/lib/active_record/tasks/sqlite_database_tasks.rb +5 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 575005ac173e9a4d7b43b73dc83c14d228052a60
|
4
|
+
data.tar.gz: 8294883a17389a89740a1731db96f7b443b4f822
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbdc8e28b13114856fed07d2bd410f796b557830d49859c9819d3464aee0fa77a5cff1226361800d2f3980d7268ee7ac1c29125431408f2c995c2e07bad890c9
|
7
|
+
data.tar.gz: afc3bd007798be314894098c912b06fc86937329ad8e0d4a1fcc9a35396dd1e97d9cc9e74469e88e15974bb43f3adc051f1ca2d814fc37d8f79bcce2f1b51969
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,41 @@
|
|
1
|
+
* Do not use `RENAME INDEX` syntax for MariaDB 10.0.
|
2
|
+
|
3
|
+
Fixes #15931.
|
4
|
+
|
5
|
+
*Jeff Browning*
|
6
|
+
|
7
|
+
* Allow included modules to override association methods.
|
8
|
+
|
9
|
+
Fixes #16684.
|
10
|
+
|
11
|
+
*Yves Senn*
|
12
|
+
|
13
|
+
* Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
|
14
|
+
the database connection to the current environment.
|
15
|
+
|
16
|
+
Fixes #16757.
|
17
|
+
|
18
|
+
*Joshua Cody*, *Yves Senn*
|
19
|
+
|
20
|
+
* `db:purge` with MySQL respects `Rails.env`.
|
21
|
+
|
22
|
+
*Yves Senn*
|
23
|
+
|
24
|
+
* Fixed automatic maintaining test schema to properly handle sql structure
|
25
|
+
schema format.
|
26
|
+
|
27
|
+
Fixes #15394.
|
28
|
+
|
29
|
+
*Wojciech Wnętrzak*
|
30
|
+
|
31
|
+
* Fix has_many :through relation merging failing when dynamic conditions are
|
32
|
+
passed as a lambda with an arity of one.
|
33
|
+
|
34
|
+
Fixes #16128.
|
35
|
+
|
36
|
+
*Agis Anastasopoulos*
|
37
|
+
|
38
|
+
|
1
39
|
## Rails 4.1.6 (September 11, 2014) ##
|
2
40
|
|
3
41
|
* Fixed a regression where whitespaces were stripped from DISTINCT queries in
|
@@ -15,7 +15,11 @@ module ActiveRecord
|
|
15
15
|
scope = super
|
16
16
|
chain.drop(1).each do |reflection|
|
17
17
|
relation = reflection.klass.all
|
18
|
-
|
18
|
+
|
19
|
+
reflection_scope = reflection.scope
|
20
|
+
if reflection_scope && reflection_scope.arity.zero?
|
21
|
+
relation.merge!(reflection_scope)
|
22
|
+
end
|
19
23
|
|
20
24
|
scope.merge!(
|
21
25
|
relation.except(:select, :create_with, :includes, :preload, :joins, :eager_load)
|
@@ -29,7 +29,7 @@ module ActiveRecord
|
|
29
29
|
end
|
30
30
|
}
|
31
31
|
|
32
|
-
BLACKLISTED_CLASS_METHODS = %w(private public protected)
|
32
|
+
BLACKLISTED_CLASS_METHODS = %w(private public protected allocate new name parent superclass)
|
33
33
|
|
34
34
|
class AttributeMethodCache
|
35
35
|
def initialize
|
@@ -63,6 +63,8 @@ module ActiveRecord
|
|
63
63
|
@generated_attribute_methods = GeneratedAttributeMethods.new { extend Mutex_m }
|
64
64
|
@attribute_methods_generated = false
|
65
65
|
include @generated_attribute_methods
|
66
|
+
|
67
|
+
super
|
66
68
|
end
|
67
69
|
|
68
70
|
# Generates all the attribute related methods for columns in the database
|
@@ -103,7 +105,7 @@ module ActiveRecord
|
|
103
105
|
# # => false
|
104
106
|
def instance_method_already_implemented?(method_name)
|
105
107
|
if dangerous_attribute_method?(method_name)
|
106
|
-
raise DangerousAttributeError, "#{method_name} is defined by Active Record"
|
108
|
+
raise DangerousAttributeError, "#{method_name} is defined by Active Record. Check to make sure that you don't have an attribute or method with the same name."
|
107
109
|
end
|
108
110
|
|
109
111
|
if superclass == Base
|
@@ -30,7 +30,12 @@ module ActiveRecord
|
|
30
30
|
# BigDecimals need to be put in a non-normalized form and quoted.
|
31
31
|
when nil then "NULL"
|
32
32
|
when BigDecimal then value.to_s('F')
|
33
|
-
when Numeric, ActiveSupport::Duration
|
33
|
+
when Numeric, ActiveSupport::Duration
|
34
|
+
if column.try(:type) == :string
|
35
|
+
quote(value.to_s, column)
|
36
|
+
else
|
37
|
+
value.to_s
|
38
|
+
end
|
34
39
|
when Date, Time then "'#{quoted_date(value)}'"
|
35
40
|
when Symbol then "'#{quote_string(value.to_s)}'"
|
36
41
|
when Class then "'#{value.to_s}'"
|
@@ -489,7 +489,7 @@ module ActiveRecord
|
|
489
489
|
end
|
490
490
|
|
491
491
|
def rename_index(table_name, old_name, new_name)
|
492
|
-
if
|
492
|
+
if supports_rename_index?
|
493
493
|
execute "ALTER TABLE #{quote_table_name(table_name)} RENAME INDEX #{quote_table_name(old_name)} TO #{quote_table_name(new_name)}"
|
494
494
|
else
|
495
495
|
super
|
@@ -727,10 +727,22 @@ module ActiveRecord
|
|
727
727
|
|
728
728
|
private
|
729
729
|
|
730
|
+
def version
|
731
|
+
@version ||= full_version.scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map { |v| v.to_i }
|
732
|
+
end
|
733
|
+
|
734
|
+
def mariadb?
|
735
|
+
full_version =~ /mariadb/i
|
736
|
+
end
|
737
|
+
|
730
738
|
def supports_views?
|
731
739
|
version[0] >= 5
|
732
740
|
end
|
733
741
|
|
742
|
+
def supports_rename_index?
|
743
|
+
mariadb? ? false : (version[0] == 5 && version[1] >= 7) || version[0] >= 6
|
744
|
+
end
|
745
|
+
|
734
746
|
def column_for(table_name, column_name)
|
735
747
|
unless column = columns(table_name).find { |c| c.name == column_name.to_s }
|
736
748
|
raise "No such column: #{table_name}.#{column_name}"
|
@@ -272,8 +272,8 @@ module ActiveRecord
|
|
272
272
|
super
|
273
273
|
end
|
274
274
|
|
275
|
-
def
|
276
|
-
@
|
275
|
+
def full_version
|
276
|
+
@full_version ||= @connection.info[:version]
|
277
277
|
end
|
278
278
|
|
279
279
|
def set_field_encoding field_name
|
@@ -558,9 +558,9 @@ module ActiveRecord
|
|
558
558
|
rows
|
559
559
|
end
|
560
560
|
|
561
|
-
# Returns the version of the connected MySQL server.
|
562
|
-
def
|
563
|
-
@
|
561
|
+
# Returns the full version of the connected MySQL server.
|
562
|
+
def full_version
|
563
|
+
@full_version ||= @connection.server_info
|
564
564
|
end
|
565
565
|
|
566
566
|
def set_field_encoding field_name
|
@@ -56,8 +56,8 @@ module ActiveRecord
|
|
56
56
|
def create_database(name, options = {})
|
57
57
|
options = { encoding: 'utf8' }.merge!(options.symbolize_keys)
|
58
58
|
|
59
|
-
option_string = options.
|
60
|
-
case key
|
59
|
+
option_string = options.inject("") do |memo, (key, value)|
|
60
|
+
memo += case key
|
61
61
|
when :owner
|
62
62
|
" OWNER = \"#{value}\""
|
63
63
|
when :template
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module ConnectionHandling
|
3
|
-
RAILS_ENV = -> { Rails.env if defined?(Rails) }
|
3
|
+
RAILS_ENV = -> { (Rails.env if defined?(Rails)) || ENV["RAILS_ENV"] || ENV["RACK_ENV"] }
|
4
4
|
DEFAULT_ENV = -> { RAILS_ENV.call || "default_env" }
|
5
5
|
|
6
6
|
# Establishes the connection to the database. Accepts a hash as input where
|
data/lib/active_record/core.rb
CHANGED
@@ -124,7 +124,7 @@ module ActiveRecord
|
|
124
124
|
# that is included in <tt>ActiveRecord::FixtureSet.context_class</tt>.
|
125
125
|
#
|
126
126
|
# - define a helper method in `test_helper.rb`
|
127
|
-
#
|
127
|
+
# module FixtureFileHelpers
|
128
128
|
# def file_sha(path)
|
129
129
|
# Digest::SHA2.hexdigest(File.read(Rails.root.join('test/fixtures', path)))
|
130
130
|
# end
|
@@ -861,11 +861,11 @@ module ActiveRecord
|
|
861
861
|
def try_to_load_dependency(file_name)
|
862
862
|
require_dependency file_name
|
863
863
|
rescue LoadError => e
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
864
|
+
unless fixture_class_names.key?(file_name.pluralize)
|
865
|
+
if ActiveRecord::Base.logger
|
866
|
+
ActiveRecord::Base.logger.warn("Unable to load #{file_name}, make sure you added it to ActiveSupport::TestCase.set_fixture_class")
|
867
|
+
ActiveRecord::Base.logger.warn("underlying cause #{e.message} \n\n #{e.backtrace.join("\n")}")
|
868
|
+
end
|
869
869
|
end
|
870
870
|
end
|
871
871
|
|
@@ -404,8 +404,8 @@ module ActiveRecord
|
|
404
404
|
end
|
405
405
|
|
406
406
|
# Saves the record with the updated_at/on attributes set to the current time.
|
407
|
-
# Please note that no validation is performed and only the +after_touch
|
408
|
-
#
|
407
|
+
# Please note that no validation is performed and only the +after_touch+,
|
408
|
+
# +after_commit+ and +after_rollback+ callbacks are executed.
|
409
409
|
# If an attribute name is passed, that attribute is updated along with
|
410
410
|
# updated_at/on attributes.
|
411
411
|
#
|
@@ -235,7 +235,7 @@ db_namespace = namespace :db do
|
|
235
235
|
|
236
236
|
desc 'Load a schema.rb file into the database'
|
237
237
|
task :load => [:environment, :load_config] do
|
238
|
-
ActiveRecord::Tasks::DatabaseTasks.
|
238
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:ruby, ENV['SCHEMA'])
|
239
239
|
end
|
240
240
|
|
241
241
|
task :load_if_ruby => ['db:create', :environment] do
|
@@ -281,7 +281,7 @@ db_namespace = namespace :db do
|
|
281
281
|
|
282
282
|
# desc "Recreate the databases from the structure.sql file"
|
283
283
|
task :load => [:environment, :load_config] do
|
284
|
-
ActiveRecord::Tasks::DatabaseTasks.
|
284
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:sql, ENV['DB_STRUCTURE'])
|
285
285
|
end
|
286
286
|
|
287
287
|
task :load_if_sql => ['db:create', :environment] do
|
@@ -312,9 +312,8 @@ db_namespace = namespace :db do
|
|
312
312
|
task :load_schema => %w(db:test:deprecated db:test:purge) do
|
313
313
|
begin
|
314
314
|
should_reconnect = ActiveRecord::Base.connection_pool.active_connection?
|
315
|
-
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
|
316
315
|
ActiveRecord::Schema.verbose = false
|
317
|
-
|
316
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema_for ActiveRecord::Base.configurations['test'], :ruby, ENV['SCHEMA']
|
318
317
|
ensure
|
319
318
|
if should_reconnect
|
320
319
|
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ActiveRecord::Tasks::DatabaseTasks.env])
|
@@ -324,12 +323,7 @@ db_namespace = namespace :db do
|
|
324
323
|
|
325
324
|
# desc "Recreate the test database from an existent structure.sql file"
|
326
325
|
task :load_structure => %w(db:test:deprecated db:test:purge) do
|
327
|
-
|
328
|
-
ActiveRecord::Tasks::DatabaseTasks.current_config(:config => ActiveRecord::Base.configurations['test'])
|
329
|
-
db_namespace["structure:load"].invoke
|
330
|
-
ensure
|
331
|
-
ActiveRecord::Tasks::DatabaseTasks.current_config(:config => nil)
|
332
|
-
end
|
326
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema_for ActiveRecord::Base.configurations['test'], :sql, ENV['SCHEMA']
|
333
327
|
end
|
334
328
|
|
335
329
|
# desc "Recreate the test database from a fresh schema"
|
@@ -866,6 +866,13 @@ module ActiveRecord
|
|
866
866
|
arel.from(build_from) if from_value
|
867
867
|
arel.lock(lock_value) if lock_value
|
868
868
|
|
869
|
+
# Reorder bind indexes if joins produced bind values
|
870
|
+
bvs = arel.bind_values + bind_values
|
871
|
+
arel.ast.grep(Arel::Nodes::BindParam).each_with_index do |bp, i|
|
872
|
+
column = bvs[i].first
|
873
|
+
bp.replace connection.substitute_at(column, i)
|
874
|
+
end
|
875
|
+
|
869
876
|
arel
|
870
877
|
end
|
871
878
|
|
@@ -157,20 +157,36 @@ module ActiveRecord
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def load_schema(format = ActiveRecord::Base.schema_format, file = nil)
|
160
|
+
load_schema_current(format, file)
|
161
|
+
end
|
162
|
+
|
163
|
+
# This method is the successor of +load_schema+. We should rename it
|
164
|
+
# after +load_schema+ went through a deprecation cycle. (Rails > 4.2)
|
165
|
+
def load_schema_for(configuration, format = ActiveRecord::Base.schema_format, file = nil) # :nodoc:
|
160
166
|
case format
|
161
167
|
when :ruby
|
162
168
|
file ||= File.join(db_dir, "schema.rb")
|
163
169
|
check_schema_file(file)
|
170
|
+
purge(configuration)
|
171
|
+
ActiveRecord::Base.establish_connection(configuration)
|
164
172
|
load(file)
|
165
173
|
when :sql
|
166
174
|
file ||= File.join(db_dir, "structure.sql")
|
167
175
|
check_schema_file(file)
|
168
|
-
|
176
|
+
purge(configuration)
|
177
|
+
structure_load(configuration, file)
|
169
178
|
else
|
170
179
|
raise ArgumentError, "unknown format #{format.inspect}"
|
171
180
|
end
|
172
181
|
end
|
173
182
|
|
183
|
+
def load_schema_current(format = ActiveRecord::Base.schema_format, file = nil, environment = env)
|
184
|
+
each_current_configuration(environment) { |configuration|
|
185
|
+
load_schema_for configuration, format, file
|
186
|
+
}
|
187
|
+
ActiveRecord::Base.establish_connection(environment.to_sym)
|
188
|
+
end
|
189
|
+
|
174
190
|
def check_schema_file(filename)
|
175
191
|
unless File.exist?(filename)
|
176
192
|
message = %{#{filename} doesn't exist yet. Run `rake db:migrate` to create it, then try again.}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.1.
|
19
|
+
version: 4.1.8
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.1.
|
26
|
+
version: 4.1.8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.1.
|
33
|
+
version: 4.1.8
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.1.
|
40
|
+
version: 4.1.8
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: arel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
248
|
version: '0'
|
249
249
|
requirements: []
|
250
250
|
rubyforge_project:
|
251
|
-
rubygems_version: 2.
|
251
|
+
rubygems_version: 2.4.2
|
252
252
|
signing_key:
|
253
253
|
specification_version: 4
|
254
254
|
summary: Object-relational mapper framework (part of Rails).
|