activerecord 4.2.0.rc3 → 4.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4eebcaeb54fa1c3d319396f193586f7e8f27a937
4
- data.tar.gz: a6385ce2b23243350456c81b6ab7c399efa239cf
3
+ metadata.gz: 255759d343183e4336a3b6262171fca30de612a5
4
+ data.tar.gz: 1dcb8b8793917f0b6e382fe0949b10181f53de54
5
5
  SHA512:
6
- metadata.gz: 90b3fbfb30d4c7854112da41d68e4f09dddff20eeb85b0c464d34916d5b0532645c7ad359a02527c88f7f29b1eec04f4241af642f58db836f56a3943099226a2
7
- data.tar.gz: 3fca47c68e6dba5ce6fc8addcf8eff8a678f16be26f51ea9ae8dbfdc7009ab54b0a82e69480c506b9d2e422f7ae3bca41d6620842b20f0f7d2a120526be93f2c
6
+ metadata.gz: 6d60768a4a480308e1dbf734ca128c2016dac4503f7f090d2ae47931e5f6a6fcb2daf7c4c984bdd870656c732bd976289cc647ef23ffa33738322539b72b51f3
7
+ data.tar.gz: e9bd572c50583b55611e1ad470f6879600a67f1110a60e6ad09e608885a59c0878f7bd6612ee33fa9c73a89ccebed864827d5a559c22986a1835f88f6ecb0a66
@@ -1,3 +1,18 @@
1
+ * Introduce `force: :cascade` option for `create_table`. Using this option
2
+ will recreate tables even if they have dependent objects (like foreign keys).
3
+ `db/schema.rb` now uses `force: :cascade`. This makes it possible to
4
+ reload the schema when foreign keys are in place.
5
+
6
+ *Matthew Draper*, *Yves Senn*
7
+
8
+ * `db:schema:load` and `db:structure:load` no longer purge the database
9
+ before loading the schema. This is left for the user to do.
10
+ `db:test:prepare` will still purge the database.
11
+
12
+ Closes #17945.
13
+
14
+ *Yves Senn*
15
+
1
16
  * Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.
2
17
 
3
18
  *Ryuta Kamizono*
@@ -283,6 +298,12 @@
283
298
 
284
299
  *Yves Senn*, *Matthew Draper*
285
300
 
301
+ * `add_timestamps` and `t.timestamps` now require you to pass the `:null` option.
302
+ Not passing the option is deprecated but the default is still `null: true`.
303
+ With Rails 5 this will change to `null: false`.
304
+
305
+ *Sean Griffin*
306
+
286
307
  * When calling `update_columns` on a record that is not persisted, the error
287
308
  message now reflects whether that object is a new record or has been
288
309
  destroyed.
@@ -9,6 +9,10 @@ module ActiveRecord
9
9
  FromUser.new(name, value, type)
10
10
  end
11
11
 
12
+ def with_cast_value(name, value, type)
13
+ WithCastValue.new(name, value, type)
14
+ end
15
+
12
16
  def null(name)
13
17
  Null.new(name)
14
18
  end
@@ -58,6 +62,10 @@ module ActiveRecord
58
62
  self.class.from_database(name, value, type)
59
63
  end
60
64
 
65
+ def with_cast_value(value)
66
+ self.class.with_cast_value(name, value, type)
67
+ end
68
+
61
69
  def type_cast(*)
62
70
  raise NotImplementedError
63
71
  end
@@ -93,6 +101,16 @@ module ActiveRecord
93
101
  end
94
102
  end
95
103
 
104
+ class WithCastValue < Attribute # :nodoc:
105
+ def type_cast(value)
106
+ value
107
+ end
108
+
109
+ def changed_in_place_from?(old_value)
110
+ false
111
+ end
112
+ end
113
+
96
114
  class Null < Attribute # :nodoc:
97
115
  def initialize(name)
98
116
  super(name, nil, Type::Value.new)
@@ -73,7 +73,7 @@ module ActiveRecord
73
73
  if should_type_cast
74
74
  @attributes.write_from_user(attr_name, value)
75
75
  else
76
- @attributes.write_from_database(attr_name, value)
76
+ @attributes.write_cast_value(attr_name, value)
77
77
  end
78
78
 
79
79
  value
@@ -39,6 +39,10 @@ module ActiveRecord
39
39
  attributes[name] = self[name].with_value_from_user(value)
40
40
  end
41
41
 
42
+ def write_cast_value(name, value)
43
+ attributes[name] = self[name].with_cast_value(value)
44
+ end
45
+
42
46
  def freeze
43
47
  @attributes.freeze
44
48
  super
@@ -132,6 +132,7 @@ module ActiveRecord
132
132
  # Make a temporary table.
133
133
  # [<tt>:force</tt>]
134
134
  # Set to true to drop the table before creating it.
135
+ # Set to +:cascade+ to drop dependent objects as well.
135
136
  # Defaults to false.
136
137
  # [<tt>:as</tt>]
137
138
  # SQL to use to generate the table. When this option is used, the block is
@@ -361,8 +362,12 @@ module ActiveRecord
361
362
 
362
363
  # Drops a table from the database.
363
364
  #
364
- # Although this command ignores +options+ and the block if one is given, it can be helpful
365
- # to provide these in a migration's +change+ method so it can be reverted.
365
+ # [<tt>:force</tt>]
366
+ # Set to +:cascade+ to drop dependent objects as well.
367
+ # Defaults to false.
368
+ #
369
+ # Although this command ignores most +options+ and the block if one is given,
370
+ # it can be helpful to provide these in a migration's +change+ method so it can be reverted.
366
371
  # In that case, +options+ and the block will be used by create_table.
367
372
  def drop_table(table_name, options = {})
368
373
  execute "DROP TABLE #{quote_table_name(table_name)}"
@@ -487,7 +487,7 @@ module ActiveRecord
487
487
  end
488
488
 
489
489
  def drop_table(table_name, options = {})
490
- execute "DROP#{' TEMPORARY' if options[:temporary]} TABLE #{quote_table_name(table_name)}"
490
+ execute "DROP#{' TEMPORARY' if options[:temporary]} TABLE #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}"
491
491
  end
492
492
 
493
493
  def rename_index(table_name, old_name, new_name)
@@ -3,14 +3,7 @@ module ActiveRecord
3
3
  module PostgreSQL
4
4
  module OID # :nodoc:
5
5
  class Uuid < Type::Value # :nodoc:
6
- RFC_4122 = %r{\A\{?[a-fA-F0-9]{4}-?
7
- [a-fA-F0-9]{4}-?
8
- [a-fA-F0-9]{4}-?
9
- [1-5][a-fA-F0-9]{3}-?
10
- [8-Bab][a-fA-F0-9]{3}-?
11
- [a-fA-F0-9]{4}-?
12
- [a-fA-F0-9]{4}-?
13
- [a-fA-F0-9]{4}-?\}?\z}x
6
+ ACCEPTABLE_UUID = %r{\A\{?([a-fA-F0-9]{4}-?){8}\}?\z}x
14
7
 
15
8
  alias_method :type_cast_for_database, :type_cast_from_database
16
9
 
@@ -19,7 +12,7 @@ module ActiveRecord
19
12
  end
20
13
 
21
14
  def type_cast(value)
22
- value.to_s[RFC_4122, 0]
15
+ value.to_s[ACCEPTABLE_UUID, 0]
23
16
  end
24
17
  end
25
18
  end
@@ -112,6 +112,10 @@ module ActiveRecord
112
112
  SQL
113
113
  end
114
114
 
115
+ def drop_table(table_name, options = {})
116
+ execute "DROP TABLE #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}"
117
+ end
118
+
115
119
  # Returns true if schema exists.
116
120
  def schema_exists?(name)
117
121
  exec_query(<<-SQL, 'SCHEMA').rows.first[0].to_i > 0
@@ -8,7 +8,7 @@ module ActiveRecord
8
8
  MAJOR = 4
9
9
  MINOR = 2
10
10
  TINY = 0
11
- PRE = "rc3"
11
+ PRE = nil
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -127,7 +127,7 @@ HEADER
127
127
  else
128
128
  tbl.print ", id: false"
129
129
  end
130
- tbl.print ", force: true"
130
+ tbl.print ", force: :cascade"
131
131
  tbl.puts " do |t|"
132
132
 
133
133
  # then dump all non-primary key columns
@@ -214,12 +214,10 @@ module ActiveRecord
214
214
  case format
215
215
  when :ruby
216
216
  check_schema_file(file)
217
- purge(configuration)
218
217
  ActiveRecord::Base.establish_connection(configuration)
219
218
  load(file)
220
219
  when :sql
221
220
  check_schema_file(file)
222
- purge(configuration)
223
221
  structure_load(configuration, file)
224
222
  else
225
223
  raise ArgumentError, "unknown format #{format.inspect}"
@@ -2,7 +2,9 @@ module ActiveRecord
2
2
  # See ActiveRecord::Transactions::ClassMethods for documentation.
3
3
  module Transactions
4
4
  extend ActiveSupport::Concern
5
+ #:nodoc:
5
6
  ACTIONS = [:create, :destroy, :update]
7
+ #:nodoc:
6
8
  CALLBACK_WARN_MESSAGE = "Currently, Active Record suppresses errors raised " \
7
9
  "within `after_rollback`/`after_commit` callbacks and only print them to " \
8
10
  "the logs. In the next version, these errors will no longer be suppressed. " \
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.0.rc3
4
+ version: 4.2.0
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-12-13 00:00:00.000000000 Z
11
+ date: 2014-12-20 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.0.rc3
19
+ version: 4.2.0
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.0.rc3
26
+ version: 4.2.0
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.0.rc3
33
+ version: 4.2.0
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.0.rc3
40
+ version: 4.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: arel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -297,9 +297,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
297
297
  version: 1.9.3
298
298
  required_rubygems_version: !ruby/object:Gem::Requirement
299
299
  requirements:
300
- - - ">"
300
+ - - ">="
301
301
  - !ruby/object:Gem::Version
302
- version: 1.3.1
302
+ version: '0'
303
303
  requirements: []
304
304
  rubyforge_project:
305
305
  rubygems_version: 2.2.2