activerecord 4.2.5.2 → 4.2.6.rc1
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 +31 -0
- data/lib/active_record/associations/has_many_through_association.rb +5 -0
- data/lib/active_record/attribute_methods/dirty.rb +1 -0
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +2 -1
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +18 -3
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +24 -1
- data/lib/active_record/connection_adapters/mysql_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +11 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +2 -0
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/reflection.rb +1 -1
- data/lib/active_record/relation/spawn_methods.rb +7 -3
- data/lib/active_record/tasks/postgresql_database_tasks.rb +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61919474b136c6451222c6e1b4d463f30e34f84e
|
4
|
+
data.tar.gz: 7f4df11ed28aa5967975d58b3b646d4db47af3da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e82b7fd959629593f2abe3752a11eccd1b081b531ec835530eb52d6dacbaa83e13268ca4da8930941fb7685e5930fe5d6b69b248dd611fbf77166a836b1b114
|
7
|
+
data.tar.gz: 86d857ad9a9798e948bf7a637f1e94977bbe86d2e80afb32316cf5d7830752e62a156d921396fef7a6fe3a924c16d95634dbea685b673885665b981d0defe8cf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,34 @@
|
|
1
|
+
## Rails 4.2.6.rc1 (March 01, 2016) ##
|
2
|
+
|
3
|
+
* Fix a bug where using `t.foreign_key` twice with the same `to_table` within
|
4
|
+
the same table definition would only create one foreign key.
|
5
|
+
|
6
|
+
*George Millo*
|
7
|
+
|
8
|
+
* Fix regression in dirty attribute tracking after #dup. Changes to the
|
9
|
+
clone no longer show as changed attributes in the original object.
|
10
|
+
|
11
|
+
*Dominic Cleal*
|
12
|
+
|
13
|
+
* Fix regression when loading fixture files with symbol keys.
|
14
|
+
|
15
|
+
Closes #22584.
|
16
|
+
|
17
|
+
*Yves Senn*
|
18
|
+
|
19
|
+
* Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
|
20
|
+
|
21
|
+
Fixes #22346.
|
22
|
+
|
23
|
+
*Nick Muerdter*, *ckoenig*
|
24
|
+
|
25
|
+
* Introduce `connection.data_sources` and `connection.data_source_exists?`.
|
26
|
+
These methods determine what relations can be used to back Active Record
|
27
|
+
models (usually tables and views).
|
28
|
+
|
29
|
+
*Yves Senn*, *Matthew Draper*
|
30
|
+
|
31
|
+
|
1
32
|
## Rails 4.2.5.2 (February 26, 2016) ##
|
2
33
|
|
3
34
|
* No changes.
|
@@ -94,6 +94,11 @@ module ActiveRecord
|
|
94
94
|
|
95
95
|
through_record = through_association.build(*options_for_through_record)
|
96
96
|
through_record.send("#{source_reflection.name}=", record)
|
97
|
+
|
98
|
+
if options[:source_type]
|
99
|
+
through_record.send("#{source_reflection.foreign_type}=", options[:source_type])
|
100
|
+
end
|
101
|
+
|
97
102
|
through_record
|
98
103
|
end
|
99
104
|
end
|
@@ -287,6 +287,7 @@ module ActiveRecord
|
|
287
287
|
# Inserts the given fixture into the table. Overridden in adapters that require
|
288
288
|
# something beyond a simple insert (eg. Oracle).
|
289
289
|
def insert_fixture(fixture, table_name)
|
290
|
+
fixture = fixture.stringify_keys
|
290
291
|
columns = schema_cache.columns_hash(table_name)
|
291
292
|
|
292
293
|
key_list = []
|
@@ -295,7 +296,7 @@ module ActiveRecord
|
|
295
296
|
key_list << quote_column_name(name)
|
296
297
|
quote(value, column)
|
297
298
|
else
|
298
|
-
raise Fixture::FixtureError, %(table "#{table_name}" has no column named
|
299
|
+
raise Fixture::FixtureError, %(table "#{table_name}" has no column named #{name.inspect}.)
|
299
300
|
end
|
300
301
|
end
|
301
302
|
|
@@ -99,7 +99,7 @@ module ActiveRecord
|
|
99
99
|
def initialize(types, name, temporary, options, as = nil)
|
100
100
|
@columns_hash = {}
|
101
101
|
@indexes = {}
|
102
|
-
@foreign_keys =
|
102
|
+
@foreign_keys = []
|
103
103
|
@native = types
|
104
104
|
@temporary = temporary
|
105
105
|
@options = options
|
@@ -289,7 +289,7 @@ module ActiveRecord
|
|
289
289
|
end
|
290
290
|
|
291
291
|
def foreign_key(table_name, options = {}) # :nodoc:
|
292
|
-
foreign_keys[table_name
|
292
|
+
foreign_keys.push([table_name, options])
|
293
293
|
end
|
294
294
|
|
295
295
|
# Appends <tt>:datetime</tt> columns <tt>:created_at</tt> and
|
@@ -19,6 +19,20 @@ module ActiveRecord
|
|
19
19
|
table_name[0...table_alias_length].tr('.', '_')
|
20
20
|
end
|
21
21
|
|
22
|
+
# Returns the relation names useable to back Active Record models.
|
23
|
+
# For most adapters this means all tables and views.
|
24
|
+
def data_sources
|
25
|
+
tables
|
26
|
+
end
|
27
|
+
|
28
|
+
# Checks to see if the data source +name+ exists on the database.
|
29
|
+
#
|
30
|
+
# data_source_exists?(:ebooks)
|
31
|
+
#
|
32
|
+
def data_source_exists?(name)
|
33
|
+
data_sources.include?(name.to_s)
|
34
|
+
end
|
35
|
+
|
22
36
|
# Checks to see if the table +table_name+ exists on the database.
|
23
37
|
#
|
24
38
|
# table_exists?(:developers)
|
@@ -213,7 +227,7 @@ module ActiveRecord
|
|
213
227
|
end
|
214
228
|
end
|
215
229
|
|
216
|
-
td.foreign_keys.
|
230
|
+
td.foreign_keys.each do |other_table_name, foreign_key_options|
|
217
231
|
add_foreign_key(table_name, other_table_name, foreign_key_options)
|
218
232
|
end
|
219
233
|
|
@@ -876,11 +890,12 @@ module ActiveRecord
|
|
876
890
|
end
|
877
891
|
|
878
892
|
# Given a set of columns and an ORDER BY clause, returns the columns for a SELECT DISTINCT.
|
879
|
-
#
|
893
|
+
# PostgreSQL, MySQL, and Oracle overrides this for custom DISTINCT syntax - they
|
880
894
|
# require the order columns appear in the SELECT.
|
881
895
|
#
|
882
896
|
# columns_for_distinct("posts.id", ["posts.created_at desc"])
|
883
|
-
|
897
|
+
#
|
898
|
+
def columns_for_distinct(columns, orders) # :nodoc:
|
884
899
|
columns
|
885
900
|
end
|
886
901
|
|
@@ -407,6 +407,7 @@ module ActiveRecord
|
|
407
407
|
result.collect { |field| field.first }
|
408
408
|
end
|
409
409
|
end
|
410
|
+
alias data_sources tables
|
410
411
|
|
411
412
|
def truncate(table_name, name = nil)
|
412
413
|
execute "TRUNCATE TABLE #{quote_table_name(table_name)}", name
|
@@ -426,6 +427,7 @@ module ActiveRecord
|
|
426
427
|
|
427
428
|
tables(nil, schema, table).any?
|
428
429
|
end
|
430
|
+
alias data_source_exists? table_exists?
|
429
431
|
|
430
432
|
# Returns an array of indexes for the given table.
|
431
433
|
def indexes(table_name, name = nil) #:nodoc:
|
@@ -604,8 +606,10 @@ module ActiveRecord
|
|
604
606
|
|
605
607
|
# SHOW VARIABLES LIKE 'name'
|
606
608
|
def show_variable(name)
|
607
|
-
variables = select_all("
|
609
|
+
variables = select_all("select @@#{name} as 'Value'", 'SCHEMA')
|
608
610
|
variables.first['Value'] unless variables.empty?
|
611
|
+
rescue ActiveRecord::StatementInvalid
|
612
|
+
nil
|
609
613
|
end
|
610
614
|
|
611
615
|
# Returns a table's primary key and belonging sequence.
|
@@ -648,6 +652,21 @@ module ActiveRecord
|
|
648
652
|
end
|
649
653
|
end
|
650
654
|
|
655
|
+
# In MySQL 5.7.5 and up, ONLY_FULL_GROUP_BY affects handling of queries that use
|
656
|
+
# DISTINCT and ORDER BY. It requires the ORDER BY columns in the select list for
|
657
|
+
# distinct queries, and requires that the ORDER BY include the distinct column.
|
658
|
+
# See https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html
|
659
|
+
def columns_for_distinct(columns, orders) # :nodoc:
|
660
|
+
order_columns = orders.reject(&:blank?).map { |s|
|
661
|
+
# Convert Arel node to string
|
662
|
+
s = s.to_sql unless s.is_a?(String)
|
663
|
+
# Remove any ASC/DESC modifiers
|
664
|
+
s.gsub(/\s+(?:ASC|DESC)\b/i, '')
|
665
|
+
}.reject(&:blank?).map.with_index { |column, i| "#{column} AS alias_#{i}" }
|
666
|
+
|
667
|
+
[super, *order_columns].join(', ')
|
668
|
+
end
|
669
|
+
|
651
670
|
def strict_mode?
|
652
671
|
self.class.type_cast_config_to_boolean(@config.fetch(:strict, true))
|
653
672
|
end
|
@@ -713,6 +732,10 @@ module ActiveRecord
|
|
713
732
|
subsubselect = select.clone
|
714
733
|
subsubselect.projections = [key]
|
715
734
|
|
735
|
+
# Materialize subquery by adding distinct
|
736
|
+
# to work with MySQL 5.7.6 which sets optimizer_switch='derived_merge=on'
|
737
|
+
subsubselect.distinct unless select.limit || select.offset || select.orders.any?
|
738
|
+
|
716
739
|
subselect = Arel::SelectManager.new(select.engine)
|
717
740
|
subselect.project Arel.sql(key.name)
|
718
741
|
subselect.from subsubselect.as('__active_record_temp')
|
@@ -245,7 +245,7 @@ module ActiveRecord
|
|
245
245
|
return @client_encoding if @client_encoding
|
246
246
|
|
247
247
|
result = exec_query(
|
248
|
-
"
|
248
|
+
"select @@character_set_client",
|
249
249
|
'SCHEMA')
|
250
250
|
@client_encoding = ENCODINGS[result.rows.last.last]
|
251
251
|
end
|
@@ -95,6 +95,16 @@ module ActiveRecord
|
|
95
95
|
SQL
|
96
96
|
end
|
97
97
|
|
98
|
+
def data_sources # :nodoc
|
99
|
+
select_values(<<-SQL, 'SCHEMA')
|
100
|
+
SELECT c.relname
|
101
|
+
FROM pg_class c
|
102
|
+
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
|
103
|
+
WHERE c.relkind IN ('r', 'v','m') -- (r)elation/table, (v)iew, (m)aterialized view
|
104
|
+
AND n.nspname = ANY (current_schemas(false))
|
105
|
+
SQL
|
106
|
+
end
|
107
|
+
|
98
108
|
# Returns true if table exists.
|
99
109
|
# If the schema is not specified as part of +name+ then it will only find tables within
|
100
110
|
# the current schema search path (regardless of permissions to access tables in other schemas)
|
@@ -111,6 +121,7 @@ module ActiveRecord
|
|
111
121
|
AND n.nspname = #{name.schema ? "'#{name.schema}'" : 'ANY (current_schemas(false))'}
|
112
122
|
SQL
|
113
123
|
end
|
124
|
+
alias data_source_exists? table_exists?
|
114
125
|
|
115
126
|
def drop_table(table_name, options = {})
|
116
127
|
execute "DROP TABLE #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}"
|
@@ -375,10 +375,12 @@ module ActiveRecord
|
|
375
375
|
row['name']
|
376
376
|
end
|
377
377
|
end
|
378
|
+
alias data_sources tables
|
378
379
|
|
379
380
|
def table_exists?(table_name)
|
380
381
|
table_name && tables(nil, table_name).any?
|
381
382
|
end
|
383
|
+
alias data_source_exists? table_exists?
|
382
384
|
|
383
385
|
# Returns an array of +Column+ objects for the table specified by +table_name+.
|
384
386
|
def columns(table_name) #:nodoc:
|
@@ -12,6 +12,7 @@ module ActiveRecord
|
|
12
12
|
|
13
13
|
# Merges in the conditions from <tt>other</tt>, if <tt>other</tt> is an <tt>ActiveRecord::Relation</tt>.
|
14
14
|
# Returns an array representing the intersection of the resulting records with <tt>other</tt>, if <tt>other</tt> is an array.
|
15
|
+
#
|
15
16
|
# Post.where(published: true).joins(:comments).merge( Comment.where(spam: false) )
|
16
17
|
# # Performs a single join query with both where conditions.
|
17
18
|
#
|
@@ -37,11 +38,14 @@ module ActiveRecord
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def merge!(other) # :nodoc:
|
40
|
-
if
|
41
|
+
if other.is_a?(Hash)
|
42
|
+
Relation::HashMerger.new(self, other).merge
|
43
|
+
elsif other.is_a?(Relation)
|
44
|
+
Relation::Merger.new(self, other).merge
|
45
|
+
elsif other.respond_to?(:to_proc)
|
41
46
|
instance_exec(&other)
|
42
47
|
else
|
43
|
-
|
44
|
-
klass.new(self, other).merge
|
48
|
+
raise ArgumentError, "#{other.inspect} is not an ActiveRecord::Relation"
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
@@ -47,9 +47,9 @@ module ActiveRecord
|
|
47
47
|
args = ['-s', '-x', '-O', '-f', filename]
|
48
48
|
search_path = configuration['schema_search_path']
|
49
49
|
unless search_path.blank?
|
50
|
-
args
|
50
|
+
args += search_path.split(',').map do |part|
|
51
51
|
"--schema=#{part.strip}"
|
52
|
-
end
|
52
|
+
end
|
53
53
|
end
|
54
54
|
args << configuration['database']
|
55
55
|
run_cmd('pg_dump', args, 'dumping')
|
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.2.
|
4
|
+
version: 4.2.6.rc1
|
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: 2016-
|
11
|
+
date: 2016-03-01 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.2.
|
19
|
+
version: 4.2.6.rc1
|
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.2.
|
26
|
+
version: 4.2.6.rc1
|
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.2.
|
33
|
+
version: 4.2.6.rc1
|
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.2.
|
40
|
+
version: 4.2.6.rc1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: arel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -299,9 +299,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
299
299
|
version: 1.9.3
|
300
300
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
301
301
|
requirements:
|
302
|
-
- - "
|
302
|
+
- - ">"
|
303
303
|
- !ruby/object:Gem::Version
|
304
|
-
version:
|
304
|
+
version: 1.3.1
|
305
305
|
requirements: []
|
306
306
|
rubyforge_project:
|
307
307
|
rubygems_version: 2.5.1
|