activerecord 6.0.0 → 6.1.4

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.

Files changed (270) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1178 -600
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +4 -4
  5. data/lib/active_record/aggregations.rb +5 -6
  6. data/lib/active_record/association_relation.rb +30 -10
  7. data/lib/active_record/associations/alias_tracker.rb +19 -16
  8. data/lib/active_record/associations/association.rb +55 -29
  9. data/lib/active_record/associations/association_scope.rb +19 -15
  10. data/lib/active_record/associations/belongs_to_association.rb +23 -10
  11. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +8 -3
  12. data/lib/active_record/associations/builder/association.rb +32 -5
  13. data/lib/active_record/associations/builder/belongs_to.rb +10 -7
  14. data/lib/active_record/associations/builder/collection_association.rb +5 -4
  15. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +0 -3
  16. data/lib/active_record/associations/builder/has_many.rb +6 -2
  17. data/lib/active_record/associations/builder/has_one.rb +11 -14
  18. data/lib/active_record/associations/builder/singular_association.rb +1 -1
  19. data/lib/active_record/associations/collection_association.rb +25 -8
  20. data/lib/active_record/associations/collection_proxy.rb +14 -7
  21. data/lib/active_record/associations/foreign_association.rb +13 -0
  22. data/lib/active_record/associations/has_many_association.rb +24 -3
  23. data/lib/active_record/associations/has_many_through_association.rb +10 -4
  24. data/lib/active_record/associations/has_one_association.rb +15 -1
  25. data/lib/active_record/associations/join_dependency/join_association.rb +39 -16
  26. data/lib/active_record/associations/join_dependency/join_part.rb +3 -3
  27. data/lib/active_record/associations/join_dependency.rb +77 -42
  28. data/lib/active_record/associations/preloader/association.rb +51 -25
  29. data/lib/active_record/associations/preloader/through_association.rb +2 -2
  30. data/lib/active_record/associations/preloader.rb +13 -8
  31. data/lib/active_record/associations/singular_association.rb +1 -1
  32. data/lib/active_record/associations/through_association.rb +1 -1
  33. data/lib/active_record/associations.rb +120 -13
  34. data/lib/active_record/attribute_assignment.rb +10 -9
  35. data/lib/active_record/attribute_methods/before_type_cast.rb +13 -10
  36. data/lib/active_record/attribute_methods/dirty.rb +3 -13
  37. data/lib/active_record/attribute_methods/primary_key.rb +6 -4
  38. data/lib/active_record/attribute_methods/query.rb +3 -6
  39. data/lib/active_record/attribute_methods/read.rb +8 -12
  40. data/lib/active_record/attribute_methods/serialization.rb +11 -6
  41. data/lib/active_record/attribute_methods/time_zone_conversion.rb +12 -15
  42. data/lib/active_record/attribute_methods/write.rb +12 -21
  43. data/lib/active_record/attribute_methods.rb +64 -54
  44. data/lib/active_record/attributes.rb +33 -9
  45. data/lib/active_record/autosave_association.rb +63 -44
  46. data/lib/active_record/base.rb +2 -14
  47. data/lib/active_record/callbacks.rb +153 -24
  48. data/lib/active_record/coders/yaml_column.rb +12 -3
  49. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +202 -138
  50. data/lib/active_record/connection_adapters/abstract/database_limits.rb +2 -44
  51. data/lib/active_record/connection_adapters/abstract/database_statements.rb +87 -38
  52. data/lib/active_record/connection_adapters/abstract/query_cache.rb +5 -10
  53. data/lib/active_record/connection_adapters/abstract/quoting.rb +34 -34
  54. data/lib/active_record/connection_adapters/abstract/savepoints.rb +3 -3
  55. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +152 -116
  56. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +141 -52
  57. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +3 -3
  58. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +267 -105
  59. data/lib/active_record/connection_adapters/abstract/transaction.rb +94 -36
  60. data/lib/active_record/connection_adapters/abstract_adapter.rb +76 -79
  61. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +149 -115
  62. data/lib/active_record/connection_adapters/column.rb +15 -1
  63. data/lib/active_record/connection_adapters/deduplicable.rb +29 -0
  64. data/lib/active_record/connection_adapters/legacy_pool_manager.rb +35 -0
  65. data/lib/active_record/connection_adapters/mysql/column.rb +1 -1
  66. data/lib/active_record/connection_adapters/mysql/database_statements.rb +30 -36
  67. data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +1 -2
  68. data/lib/active_record/connection_adapters/mysql/quoting.rb +18 -3
  69. data/lib/active_record/connection_adapters/mysql/schema_creation.rb +32 -7
  70. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +8 -0
  71. data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +5 -2
  72. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +17 -13
  73. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +10 -1
  74. data/lib/active_record/connection_adapters/mysql2_adapter.rb +31 -13
  75. data/lib/active_record/connection_adapters/pool_config.rb +73 -0
  76. data/lib/active_record/connection_adapters/pool_manager.rb +47 -0
  77. data/lib/active_record/connection_adapters/postgresql/column.rb +24 -1
  78. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +21 -56
  79. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +0 -1
  80. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +3 -5
  81. data/lib/active_record/connection_adapters/postgresql/oid/date.rb +2 -2
  82. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +10 -2
  83. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +0 -1
  84. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +0 -1
  85. data/lib/active_record/connection_adapters/postgresql/oid/interval.rb +49 -0
  86. data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +2 -3
  87. data/lib/active_record/connection_adapters/postgresql/oid/macaddr.rb +25 -0
  88. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
  89. data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +1 -1
  90. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +2 -3
  91. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +24 -6
  92. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +1 -1
  93. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +11 -2
  94. data/lib/active_record/connection_adapters/postgresql/oid.rb +2 -0
  95. data/lib/active_record/connection_adapters/postgresql/quoting.rb +4 -4
  96. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +2 -2
  97. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +7 -3
  98. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +1 -1
  99. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +0 -1
  100. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +72 -54
  101. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +8 -0
  102. data/lib/active_record/connection_adapters/postgresql/utils.rb +0 -1
  103. data/lib/active_record/connection_adapters/postgresql_adapter.rb +83 -65
  104. data/lib/active_record/connection_adapters/schema_cache.rb +106 -15
  105. data/lib/active_record/connection_adapters/sql_type_metadata.rb +8 -0
  106. data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +38 -12
  107. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +1 -2
  108. data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +5 -1
  109. data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +38 -5
  110. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +61 -57
  111. data/lib/active_record/connection_adapters/statement_pool.rb +0 -1
  112. data/lib/active_record/connection_adapters.rb +52 -0
  113. data/lib/active_record/connection_handling.rb +219 -81
  114. data/lib/active_record/core.rb +268 -71
  115. data/lib/active_record/counter_cache.rb +4 -1
  116. data/lib/active_record/database_configurations/connection_url_resolver.rb +98 -0
  117. data/lib/active_record/database_configurations/database_config.rb +52 -9
  118. data/lib/active_record/database_configurations/hash_config.rb +54 -8
  119. data/lib/active_record/database_configurations/url_config.rb +15 -41
  120. data/lib/active_record/database_configurations.rb +124 -85
  121. data/lib/active_record/delegated_type.rb +209 -0
  122. data/lib/active_record/destroy_association_async_job.rb +36 -0
  123. data/lib/active_record/dynamic_matchers.rb +2 -3
  124. data/lib/active_record/enum.rb +80 -38
  125. data/lib/active_record/errors.rb +47 -12
  126. data/lib/active_record/explain.rb +9 -5
  127. data/lib/active_record/explain_subscriber.rb +1 -1
  128. data/lib/active_record/fixture_set/file.rb +10 -17
  129. data/lib/active_record/fixture_set/model_metadata.rb +1 -2
  130. data/lib/active_record/fixture_set/render_context.rb +1 -1
  131. data/lib/active_record/fixture_set/table_row.rb +2 -3
  132. data/lib/active_record/fixture_set/table_rows.rb +0 -1
  133. data/lib/active_record/fixtures.rb +58 -12
  134. data/lib/active_record/gem_version.rb +2 -2
  135. data/lib/active_record/inheritance.rb +40 -21
  136. data/lib/active_record/insert_all.rb +43 -10
  137. data/lib/active_record/integration.rb +3 -5
  138. data/lib/active_record/internal_metadata.rb +16 -7
  139. data/lib/active_record/legacy_yaml_adapter.rb +7 -3
  140. data/lib/active_record/locking/optimistic.rb +33 -18
  141. data/lib/active_record/locking/pessimistic.rb +6 -2
  142. data/lib/active_record/log_subscriber.rb +28 -9
  143. data/lib/active_record/middleware/database_selector/resolver/session.rb +3 -0
  144. data/lib/active_record/middleware/database_selector/resolver.rb +14 -14
  145. data/lib/active_record/middleware/database_selector.rb +4 -2
  146. data/lib/active_record/migration/command_recorder.rb +53 -45
  147. data/lib/active_record/migration/compatibility.rb +71 -20
  148. data/lib/active_record/migration/join_table.rb +0 -1
  149. data/lib/active_record/migration.rb +115 -85
  150. data/lib/active_record/model_schema.rb +120 -15
  151. data/lib/active_record/nested_attributes.rb +2 -5
  152. data/lib/active_record/no_touching.rb +1 -1
  153. data/lib/active_record/null_relation.rb +0 -1
  154. data/lib/active_record/persistence.rb +50 -46
  155. data/lib/active_record/query_cache.rb +15 -5
  156. data/lib/active_record/querying.rb +12 -7
  157. data/lib/active_record/railtie.rb +65 -45
  158. data/lib/active_record/railties/console_sandbox.rb +2 -4
  159. data/lib/active_record/railties/databases.rake +280 -99
  160. data/lib/active_record/readonly_attributes.rb +4 -0
  161. data/lib/active_record/reflection.rb +77 -63
  162. data/lib/active_record/relation/batches/batch_enumerator.rb +25 -9
  163. data/lib/active_record/relation/batches.rb +38 -32
  164. data/lib/active_record/relation/calculations.rb +106 -45
  165. data/lib/active_record/relation/delegation.rb +9 -7
  166. data/lib/active_record/relation/finder_methods.rb +55 -17
  167. data/lib/active_record/relation/from_clause.rb +5 -1
  168. data/lib/active_record/relation/merger.rb +27 -26
  169. data/lib/active_record/relation/predicate_builder/array_handler.rb +8 -9
  170. data/lib/active_record/relation/predicate_builder/association_query_value.rb +4 -5
  171. data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +10 -6
  172. data/lib/active_record/relation/predicate_builder/relation_handler.rb +1 -1
  173. data/lib/active_record/relation/predicate_builder.rb +59 -40
  174. data/lib/active_record/relation/query_methods.rb +344 -181
  175. data/lib/active_record/relation/record_fetch_warning.rb +3 -3
  176. data/lib/active_record/relation/spawn_methods.rb +8 -8
  177. data/lib/active_record/relation/where_clause.rb +111 -62
  178. data/lib/active_record/relation.rb +116 -82
  179. data/lib/active_record/result.rb +41 -34
  180. data/lib/active_record/runtime_registry.rb +2 -2
  181. data/lib/active_record/sanitization.rb +6 -17
  182. data/lib/active_record/schema_dumper.rb +34 -4
  183. data/lib/active_record/schema_migration.rb +2 -8
  184. data/lib/active_record/scoping/default.rb +1 -4
  185. data/lib/active_record/scoping/named.rb +7 -18
  186. data/lib/active_record/scoping.rb +0 -1
  187. data/lib/active_record/secure_token.rb +16 -8
  188. data/lib/active_record/serialization.rb +5 -3
  189. data/lib/active_record/signed_id.rb +116 -0
  190. data/lib/active_record/statement_cache.rb +20 -4
  191. data/lib/active_record/store.rb +3 -3
  192. data/lib/active_record/suppressor.rb +2 -2
  193. data/lib/active_record/table_metadata.rb +42 -36
  194. data/lib/active_record/tasks/database_tasks.rb +140 -113
  195. data/lib/active_record/tasks/mysql_database_tasks.rb +34 -36
  196. data/lib/active_record/tasks/postgresql_database_tasks.rb +24 -27
  197. data/lib/active_record/tasks/sqlite_database_tasks.rb +13 -10
  198. data/lib/active_record/test_databases.rb +5 -4
  199. data/lib/active_record/test_fixtures.rb +79 -16
  200. data/lib/active_record/timestamp.rb +4 -7
  201. data/lib/active_record/touch_later.rb +20 -21
  202. data/lib/active_record/transactions.rb +26 -73
  203. data/lib/active_record/type/adapter_specific_registry.rb +2 -5
  204. data/lib/active_record/type/hash_lookup_type_map.rb +0 -1
  205. data/lib/active_record/type/serialized.rb +6 -3
  206. data/lib/active_record/type/time.rb +10 -0
  207. data/lib/active_record/type/type_map.rb +0 -1
  208. data/lib/active_record/type/unsigned_integer.rb +0 -1
  209. data/lib/active_record/type.rb +8 -2
  210. data/lib/active_record/type_caster/connection.rb +0 -1
  211. data/lib/active_record/type_caster/map.rb +8 -5
  212. data/lib/active_record/validations/associated.rb +1 -2
  213. data/lib/active_record/validations/numericality.rb +35 -0
  214. data/lib/active_record/validations/uniqueness.rb +24 -4
  215. data/lib/active_record/validations.rb +3 -3
  216. data/lib/active_record.rb +7 -13
  217. data/lib/arel/attributes/attribute.rb +4 -0
  218. data/lib/arel/collectors/bind.rb +5 -0
  219. data/lib/arel/collectors/composite.rb +8 -0
  220. data/lib/arel/collectors/sql_string.rb +7 -0
  221. data/lib/arel/collectors/substitute_binds.rb +7 -0
  222. data/lib/arel/nodes/binary.rb +82 -8
  223. data/lib/arel/nodes/bind_param.rb +8 -0
  224. data/lib/arel/nodes/casted.rb +21 -9
  225. data/lib/arel/nodes/equality.rb +6 -9
  226. data/lib/arel/nodes/grouping.rb +3 -0
  227. data/lib/arel/nodes/homogeneous_in.rb +76 -0
  228. data/lib/arel/nodes/in.rb +8 -1
  229. data/lib/arel/nodes/infix_operation.rb +13 -1
  230. data/lib/arel/nodes/join_source.rb +1 -1
  231. data/lib/arel/nodes/node.rb +7 -6
  232. data/lib/arel/nodes/ordering.rb +27 -0
  233. data/lib/arel/nodes/sql_literal.rb +3 -0
  234. data/lib/arel/nodes/table_alias.rb +7 -3
  235. data/lib/arel/nodes/unary.rb +0 -1
  236. data/lib/arel/nodes.rb +3 -1
  237. data/lib/arel/predications.rb +17 -24
  238. data/lib/arel/select_manager.rb +1 -2
  239. data/lib/arel/table.rb +13 -5
  240. data/lib/arel/visitors/dot.rb +14 -3
  241. data/lib/arel/visitors/mysql.rb +11 -1
  242. data/lib/arel/visitors/postgresql.rb +15 -5
  243. data/lib/arel/visitors/sqlite.rb +0 -1
  244. data/lib/arel/visitors/to_sql.rb +89 -79
  245. data/lib/arel/visitors/visitor.rb +0 -1
  246. data/lib/arel/visitors.rb +0 -7
  247. data/lib/arel.rb +15 -12
  248. data/lib/rails/generators/active_record/application_record/application_record_generator.rb +0 -1
  249. data/lib/rails/generators/active_record/migration/migration_generator.rb +1 -0
  250. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +2 -0
  251. data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +4 -4
  252. data/lib/rails/generators/active_record/migration.rb +6 -2
  253. data/lib/rails/generators/active_record/model/model_generator.rb +38 -2
  254. data/lib/rails/generators/active_record/model/templates/abstract_base_class.rb.tt +7 -0
  255. metadata +27 -24
  256. data/lib/active_record/attribute_decorators.rb +0 -90
  257. data/lib/active_record/connection_adapters/connection_specification.rb +0 -297
  258. data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +0 -29
  259. data/lib/active_record/define_callbacks.rb +0 -22
  260. data/lib/active_record/railties/collection_cache_association_loading.rb +0 -34
  261. data/lib/active_record/relation/predicate_builder/base_handler.rb +0 -18
  262. data/lib/active_record/relation/where_clause_factory.rb +0 -33
  263. data/lib/arel/attributes.rb +0 -22
  264. data/lib/arel/visitors/depth_first.rb +0 -204
  265. data/lib/arel/visitors/ibm_db.rb +0 -34
  266. data/lib/arel/visitors/informix.rb +0 -62
  267. data/lib/arel/visitors/mssql.rb +0 -157
  268. data/lib/arel/visitors/oracle.rb +0 -159
  269. data/lib/arel/visitors/oracle12.rb +0 -66
  270. data/lib/arel/visitors/where_sql.rb +0 -23
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: 6.0.0
4
+ version: 6.1.4
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: 2019-08-16 00:00:00.000000000 Z
11
+ date: 2021-06-24 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: 6.0.0
19
+ version: 6.1.4
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: 6.0.0
26
+ version: 6.1.4
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: 6.0.0
33
+ version: 6.1.4
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: 6.0.0
40
+ version: 6.1.4
41
41
  description: Databases on Rails. Build a persistent domain model by mapping database
42
42
  tables to Ruby classes. Strong conventions for associations, validations, aggregations,
43
43
  migrations, and testing come baked-in.
@@ -85,7 +85,6 @@ files:
85
85
  - lib/active_record/associations/singular_association.rb
86
86
  - lib/active_record/associations/through_association.rb
87
87
  - lib/active_record/attribute_assignment.rb
88
- - lib/active_record/attribute_decorators.rb
89
88
  - lib/active_record/attribute_methods.rb
90
89
  - lib/active_record/attribute_methods/before_type_cast.rb
91
90
  - lib/active_record/attribute_methods/dirty.rb
@@ -101,6 +100,7 @@ files:
101
100
  - lib/active_record/callbacks.rb
102
101
  - lib/active_record/coders/json.rb
103
102
  - lib/active_record/coders/yaml_column.rb
103
+ - lib/active_record/connection_adapters.rb
104
104
  - lib/active_record/connection_adapters/abstract/connection_pool.rb
105
105
  - lib/active_record/connection_adapters/abstract/database_limits.rb
106
106
  - lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -115,8 +115,8 @@ files:
115
115
  - lib/active_record/connection_adapters/abstract_adapter.rb
116
116
  - lib/active_record/connection_adapters/abstract_mysql_adapter.rb
117
117
  - lib/active_record/connection_adapters/column.rb
118
- - lib/active_record/connection_adapters/connection_specification.rb
119
- - lib/active_record/connection_adapters/determine_if_preparable_visitor.rb
118
+ - lib/active_record/connection_adapters/deduplicable.rb
119
+ - lib/active_record/connection_adapters/legacy_pool_manager.rb
120
120
  - lib/active_record/connection_adapters/mysql/column.rb
121
121
  - lib/active_record/connection_adapters/mysql/database_statements.rb
122
122
  - lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb
@@ -127,6 +127,8 @@ files:
127
127
  - lib/active_record/connection_adapters/mysql/schema_statements.rb
128
128
  - lib/active_record/connection_adapters/mysql/type_metadata.rb
129
129
  - lib/active_record/connection_adapters/mysql2_adapter.rb
130
+ - lib/active_record/connection_adapters/pool_config.rb
131
+ - lib/active_record/connection_adapters/pool_manager.rb
130
132
  - lib/active_record/connection_adapters/postgresql/column.rb
131
133
  - lib/active_record/connection_adapters/postgresql/database_statements.rb
132
134
  - lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb
@@ -142,8 +144,10 @@ files:
142
144
  - lib/active_record/connection_adapters/postgresql/oid/enum.rb
143
145
  - lib/active_record/connection_adapters/postgresql/oid/hstore.rb
144
146
  - lib/active_record/connection_adapters/postgresql/oid/inet.rb
147
+ - lib/active_record/connection_adapters/postgresql/oid/interval.rb
145
148
  - lib/active_record/connection_adapters/postgresql/oid/jsonb.rb
146
149
  - lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb
150
+ - lib/active_record/connection_adapters/postgresql/oid/macaddr.rb
147
151
  - lib/active_record/connection_adapters/postgresql/oid/money.rb
148
152
  - lib/active_record/connection_adapters/postgresql/oid/oid.rb
149
153
  - lib/active_record/connection_adapters/postgresql/oid/point.rb
@@ -177,10 +181,12 @@ files:
177
181
  - lib/active_record/core.rb
178
182
  - lib/active_record/counter_cache.rb
179
183
  - lib/active_record/database_configurations.rb
184
+ - lib/active_record/database_configurations/connection_url_resolver.rb
180
185
  - lib/active_record/database_configurations/database_config.rb
181
186
  - lib/active_record/database_configurations/hash_config.rb
182
187
  - lib/active_record/database_configurations/url_config.rb
183
- - lib/active_record/define_callbacks.rb
188
+ - lib/active_record/delegated_type.rb
189
+ - lib/active_record/destroy_association_async_job.rb
184
190
  - lib/active_record/dynamic_matchers.rb
185
191
  - lib/active_record/enum.rb
186
192
  - lib/active_record/errors.rb
@@ -218,7 +224,6 @@ files:
218
224
  - lib/active_record/query_cache.rb
219
225
  - lib/active_record/querying.rb
220
226
  - lib/active_record/railtie.rb
221
- - lib/active_record/railties/collection_cache_association_loading.rb
222
227
  - lib/active_record/railties/console_sandbox.rb
223
228
  - lib/active_record/railties/controller_runtime.rb
224
229
  - lib/active_record/railties/databases.rake
@@ -235,7 +240,6 @@ files:
235
240
  - lib/active_record/relation/predicate_builder.rb
236
241
  - lib/active_record/relation/predicate_builder/array_handler.rb
237
242
  - lib/active_record/relation/predicate_builder/association_query_value.rb
238
- - lib/active_record/relation/predicate_builder/base_handler.rb
239
243
  - lib/active_record/relation/predicate_builder/basic_object_handler.rb
240
244
  - lib/active_record/relation/predicate_builder/polymorphic_array_value.rb
241
245
  - lib/active_record/relation/predicate_builder/range_handler.rb
@@ -245,7 +249,6 @@ files:
245
249
  - lib/active_record/relation/record_fetch_warning.rb
246
250
  - lib/active_record/relation/spawn_methods.rb
247
251
  - lib/active_record/relation/where_clause.rb
248
- - lib/active_record/relation/where_clause_factory.rb
249
252
  - lib/active_record/result.rb
250
253
  - lib/active_record/runtime_registry.rb
251
254
  - lib/active_record/sanitization.rb
@@ -257,6 +260,7 @@ files:
257
260
  - lib/active_record/scoping/named.rb
258
261
  - lib/active_record/secure_token.rb
259
262
  - lib/active_record/serialization.rb
263
+ - lib/active_record/signed_id.rb
260
264
  - lib/active_record/statement_cache.rb
261
265
  - lib/active_record/store.rb
262
266
  - lib/active_record/suppressor.rb
@@ -291,12 +295,12 @@ files:
291
295
  - lib/active_record/validations/absence.rb
292
296
  - lib/active_record/validations/associated.rb
293
297
  - lib/active_record/validations/length.rb
298
+ - lib/active_record/validations/numericality.rb
294
299
  - lib/active_record/validations/presence.rb
295
300
  - lib/active_record/validations/uniqueness.rb
296
301
  - lib/active_record/version.rb
297
302
  - lib/arel.rb
298
303
  - lib/arel/alias_predication.rb
299
- - lib/arel/attributes.rb
300
304
  - lib/arel/attributes/attribute.rb
301
305
  - lib/arel/collectors/bind.rb
302
306
  - lib/arel/collectors/composite.rb
@@ -327,6 +331,7 @@ files:
327
331
  - lib/arel/nodes/full_outer_join.rb
328
332
  - lib/arel/nodes/function.rb
329
333
  - lib/arel/nodes/grouping.rb
334
+ - lib/arel/nodes/homogeneous_in.rb
330
335
  - lib/arel/nodes/in.rb
331
336
  - lib/arel/nodes/infix_operation.rb
332
337
  - lib/arel/nodes/inner_join.rb
@@ -336,6 +341,7 @@ files:
336
341
  - lib/arel/nodes/named_function.rb
337
342
  - lib/arel/nodes/node.rb
338
343
  - lib/arel/nodes/node_expression.rb
344
+ - lib/arel/nodes/ordering.rb
339
345
  - lib/arel/nodes/outer_join.rb
340
346
  - lib/arel/nodes/over.rb
341
347
  - lib/arel/nodes/regexp.rb
@@ -361,19 +367,12 @@ files:
361
367
  - lib/arel/tree_manager.rb
362
368
  - lib/arel/update_manager.rb
363
369
  - lib/arel/visitors.rb
364
- - lib/arel/visitors/depth_first.rb
365
370
  - lib/arel/visitors/dot.rb
366
- - lib/arel/visitors/ibm_db.rb
367
- - lib/arel/visitors/informix.rb
368
- - lib/arel/visitors/mssql.rb
369
371
  - lib/arel/visitors/mysql.rb
370
- - lib/arel/visitors/oracle.rb
371
- - lib/arel/visitors/oracle12.rb
372
372
  - lib/arel/visitors/postgresql.rb
373
373
  - lib/arel/visitors/sqlite.rb
374
374
  - lib/arel/visitors/to_sql.rb
375
375
  - lib/arel/visitors/visitor.rb
376
- - lib/arel/visitors/where_sql.rb
377
376
  - lib/arel/window_predications.rb
378
377
  - lib/rails/generators/active_record.rb
379
378
  - lib/rails/generators/active_record/application_record/application_record_generator.rb
@@ -383,14 +382,18 @@ files:
383
382
  - lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt
384
383
  - lib/rails/generators/active_record/migration/templates/migration.rb.tt
385
384
  - lib/rails/generators/active_record/model/model_generator.rb
385
+ - lib/rails/generators/active_record/model/templates/abstract_base_class.rb.tt
386
386
  - lib/rails/generators/active_record/model/templates/model.rb.tt
387
387
  - lib/rails/generators/active_record/model/templates/module.rb.tt
388
388
  homepage: https://rubyonrails.org
389
389
  licenses:
390
390
  - MIT
391
391
  metadata:
392
- source_code_uri: https://github.com/rails/rails/tree/v6.0.0/activerecord
393
- changelog_uri: https://github.com/rails/rails/blob/v6.0.0/activerecord/CHANGELOG.md
392
+ bug_tracker_uri: https://github.com/rails/rails/issues
393
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.4/activerecord/CHANGELOG.md
394
+ documentation_uri: https://api.rubyonrails.org/v6.1.4/
395
+ mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
396
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.4/activerecord
394
397
  post_install_message:
395
398
  rdoc_options:
396
399
  - "--main"
@@ -408,7 +411,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
408
411
  - !ruby/object:Gem::Version
409
412
  version: '0'
410
413
  requirements: []
411
- rubygems_version: 3.0.1
414
+ rubygems_version: 3.1.2
412
415
  signing_key:
413
416
  specification_version: 4
414
417
  summary: Object-relational mapper framework (part of Rails).
@@ -1,90 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveRecord
4
- module AttributeDecorators # :nodoc:
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- class_attribute :attribute_type_decorations, instance_accessor: false, default: TypeDecorator.new # :internal:
9
- end
10
-
11
- module ClassMethods # :nodoc:
12
- # This method is an internal API used to create class macros such as
13
- # +serialize+, and features like time zone aware attributes.
14
- #
15
- # Used to wrap the type of an attribute in a new type.
16
- # When the schema for a model is loaded, attributes with the same name as
17
- # +column_name+ will have their type yielded to the given block. The
18
- # return value of that block will be used instead.
19
- #
20
- # Subsequent calls where +column_name+ and +decorator_name+ are the same
21
- # will override the previous decorator, not decorate twice. This can be
22
- # used to create idempotent class macros like +serialize+
23
- def decorate_attribute_type(column_name, decorator_name, &block)
24
- matcher = ->(name, _) { name == column_name.to_s }
25
- key = "_#{column_name}_#{decorator_name}"
26
- decorate_matching_attribute_types(matcher, key, &block)
27
- end
28
-
29
- # This method is an internal API used to create higher level features like
30
- # time zone aware attributes.
31
- #
32
- # When the schema for a model is loaded, +matcher+ will be called for each
33
- # attribute with its name and type. If the matcher returns a truthy value,
34
- # the type will then be yielded to the given block, and the return value
35
- # of that block will replace the type.
36
- #
37
- # Subsequent calls to this method with the same value for +decorator_name+
38
- # will replace the previous decorator, not decorate twice. This can be
39
- # used to ensure that class macros are idempotent.
40
- def decorate_matching_attribute_types(matcher, decorator_name, &block)
41
- reload_schema_from_cache
42
- decorator_name = decorator_name.to_s
43
-
44
- # Create new hashes so we don't modify parent classes
45
- self.attribute_type_decorations = attribute_type_decorations.merge(decorator_name => [matcher, block])
46
- end
47
-
48
- private
49
-
50
- def load_schema!
51
- super
52
- attribute_types.each do |name, type|
53
- decorated_type = attribute_type_decorations.apply(name, type)
54
- define_attribute(name, decorated_type)
55
- end
56
- end
57
- end
58
-
59
- class TypeDecorator # :nodoc:
60
- delegate :clear, to: :@decorations
61
-
62
- def initialize(decorations = {})
63
- @decorations = decorations
64
- end
65
-
66
- def merge(*args)
67
- TypeDecorator.new(@decorations.merge(*args))
68
- end
69
-
70
- def apply(name, type)
71
- decorations = decorators_for(name, type)
72
- decorations.inject(type) do |new_type, block|
73
- block.call(new_type)
74
- end
75
- end
76
-
77
- private
78
-
79
- def decorators_for(name, type)
80
- matching(name, type).map(&:last)
81
- end
82
-
83
- def matching(name, type)
84
- @decorations.values.select do |(matcher, _)|
85
- matcher.call(name, type)
86
- end
87
- end
88
- end
89
- end
90
- end
@@ -1,297 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "uri"
4
-
5
- module ActiveRecord
6
- module ConnectionAdapters
7
- class ConnectionSpecification #:nodoc:
8
- attr_reader :name, :config, :adapter_method
9
-
10
- def initialize(name, config, adapter_method)
11
- @name, @config, @adapter_method = name, config, adapter_method
12
- end
13
-
14
- def initialize_dup(original)
15
- @config = original.config.dup
16
- end
17
-
18
- def to_hash
19
- @config.merge(name: @name)
20
- end
21
-
22
- # Expands a connection string into a hash.
23
- class ConnectionUrlResolver # :nodoc:
24
- # == Example
25
- #
26
- # url = "postgresql://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000"
27
- # ConnectionUrlResolver.new(url).to_hash
28
- # # => {
29
- # "adapter" => "postgresql",
30
- # "host" => "localhost",
31
- # "port" => 9000,
32
- # "database" => "foo_test",
33
- # "username" => "foo",
34
- # "password" => "bar",
35
- # "pool" => "5",
36
- # "timeout" => "3000"
37
- # }
38
- def initialize(url)
39
- raise "Database URL cannot be empty" if url.blank?
40
- @uri = uri_parser.parse(url)
41
- @adapter = @uri.scheme && @uri.scheme.tr("-", "_")
42
- @adapter = "postgresql" if @adapter == "postgres"
43
-
44
- if @uri.opaque
45
- @uri.opaque, @query = @uri.opaque.split("?", 2)
46
- else
47
- @query = @uri.query
48
- end
49
- end
50
-
51
- # Converts the given URL to a full connection hash.
52
- def to_hash
53
- config = raw_config.reject { |_, value| value.blank? }
54
- config.map { |key, value| config[key] = uri_parser.unescape(value) if value.is_a? String }
55
- config
56
- end
57
-
58
- private
59
-
60
- attr_reader :uri
61
-
62
- def uri_parser
63
- @uri_parser ||= URI::Parser.new
64
- end
65
-
66
- # Converts the query parameters of the URI into a hash.
67
- #
68
- # "localhost?pool=5&reaping_frequency=2"
69
- # # => { "pool" => "5", "reaping_frequency" => "2" }
70
- #
71
- # returns empty hash if no query present.
72
- #
73
- # "localhost"
74
- # # => {}
75
- def query_hash
76
- Hash[(@query || "").split("&").map { |pair| pair.split("=") }]
77
- end
78
-
79
- def raw_config
80
- if uri.opaque
81
- query_hash.merge(
82
- "adapter" => @adapter,
83
- "database" => uri.opaque)
84
- else
85
- query_hash.merge(
86
- "adapter" => @adapter,
87
- "username" => uri.user,
88
- "password" => uri.password,
89
- "port" => uri.port,
90
- "database" => database_from_path,
91
- "host" => uri.hostname)
92
- end
93
- end
94
-
95
- # Returns name of the database.
96
- def database_from_path
97
- if @adapter == "sqlite3"
98
- # 'sqlite3:/foo' is absolute, because that makes sense. The
99
- # corresponding relative version, 'sqlite3:foo', is handled
100
- # elsewhere, as an "opaque".
101
-
102
- uri.path
103
- else
104
- # Only SQLite uses a filename as the "database" name; for
105
- # anything else, a leading slash would be silly.
106
-
107
- uri.path.sub(%r{^/}, "")
108
- end
109
- end
110
- end
111
-
112
- ##
113
- # Builds a ConnectionSpecification from user input.
114
- class Resolver # :nodoc:
115
- attr_reader :configurations
116
-
117
- # Accepts a list of db config objects.
118
- def initialize(configurations)
119
- @configurations = configurations
120
- end
121
-
122
- # Returns a hash with database connection information.
123
- #
124
- # == Examples
125
- #
126
- # Full hash Configuration.
127
- #
128
- # configurations = { "production" => { "host" => "localhost", "database" => "foo", "adapter" => "sqlite3" } }
129
- # Resolver.new(configurations).resolve(:production)
130
- # # => { "host" => "localhost", "database" => "foo", "adapter" => "sqlite3"}
131
- #
132
- # Initialized with URL configuration strings.
133
- #
134
- # configurations = { "production" => "postgresql://localhost/foo" }
135
- # Resolver.new(configurations).resolve(:production)
136
- # # => { "host" => "localhost", "database" => "foo", "adapter" => "postgresql" }
137
- #
138
- def resolve(config_or_env, pool_name = nil)
139
- if config_or_env
140
- resolve_connection config_or_env, pool_name
141
- else
142
- raise AdapterNotSpecified
143
- end
144
- end
145
-
146
- # Returns an instance of ConnectionSpecification for a given adapter.
147
- # Accepts a hash one layer deep that contains all connection information.
148
- #
149
- # == Example
150
- #
151
- # config = { "production" => { "host" => "localhost", "database" => "foo", "adapter" => "sqlite3" } }
152
- # spec = Resolver.new(config).spec(:production)
153
- # spec.adapter_method
154
- # # => "sqlite3_connection"
155
- # spec.config
156
- # # => { "host" => "localhost", "database" => "foo", "adapter" => "sqlite3" }
157
- #
158
- def spec(config)
159
- pool_name = config if config.is_a?(Symbol)
160
-
161
- spec = resolve(config, pool_name).symbolize_keys
162
-
163
- raise(AdapterNotSpecified, "database configuration does not specify adapter") unless spec.key?(:adapter)
164
-
165
- # Require the adapter itself and give useful feedback about
166
- # 1. Missing adapter gems and
167
- # 2. Adapter gems' missing dependencies.
168
- path_to_adapter = "active_record/connection_adapters/#{spec[:adapter]}_adapter"
169
- begin
170
- require path_to_adapter
171
- rescue LoadError => e
172
- # We couldn't require the adapter itself. Raise an exception that
173
- # points out config typos and missing gems.
174
- if e.path == path_to_adapter
175
- # We can assume that a non-builtin adapter was specified, so it's
176
- # either misspelled or missing from Gemfile.
177
- raise LoadError, "Could not load the '#{spec[:adapter]}' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile.", e.backtrace
178
-
179
- # Bubbled up from the adapter require. Prefix the exception message
180
- # with some guidance about how to address it and reraise.
181
- else
182
- raise LoadError, "Error loading the '#{spec[:adapter]}' Active Record adapter. Missing a gem it depends on? #{e.message}", e.backtrace
183
- end
184
- end
185
-
186
- adapter_method = "#{spec[:adapter]}_connection"
187
-
188
- unless ActiveRecord::Base.respond_to?(adapter_method)
189
- raise AdapterNotFound, "database configuration specifies nonexistent #{spec.config[:adapter]} adapter"
190
- end
191
-
192
- ConnectionSpecification.new(spec.delete(:name) || "primary", spec, adapter_method)
193
- end
194
-
195
- private
196
- # Returns fully resolved connection, accepts hash, string or symbol.
197
- # Always returns a hash.
198
- #
199
- # == Examples
200
- #
201
- # Symbol representing current environment.
202
- #
203
- # Resolver.new("production" => {}).resolve_connection(:production)
204
- # # => {}
205
- #
206
- # One layer deep hash of connection values.
207
- #
208
- # Resolver.new({}).resolve_connection("adapter" => "sqlite3")
209
- # # => { "adapter" => "sqlite3" }
210
- #
211
- # Connection URL.
212
- #
213
- # Resolver.new({}).resolve_connection("postgresql://localhost/foo")
214
- # # => { "host" => "localhost", "database" => "foo", "adapter" => "postgresql" }
215
- #
216
- def resolve_connection(config_or_env, pool_name = nil)
217
- case config_or_env
218
- when Symbol
219
- resolve_symbol_connection config_or_env, pool_name
220
- when String
221
- resolve_url_connection config_or_env
222
- when Hash
223
- resolve_hash_connection config_or_env
224
- else
225
- raise TypeError, "Invalid type for configuration. Expected Symbol, String, or Hash. Got #{config_or_env.inspect}"
226
- end
227
- end
228
-
229
- # Takes the environment such as +:production+ or +:development+ and a
230
- # pool name the corresponds to the name given by the connection pool
231
- # to the connection. That pool name is merged into the hash with the
232
- # name key.
233
- #
234
- # This requires that the @configurations was initialized with a key that
235
- # matches.
236
- #
237
- # configurations = #<ActiveRecord::DatabaseConfigurations:0x00007fd9fdace3e0
238
- # @configurations=[
239
- # #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd9fdace250
240
- # @env_name="production", @spec_name="primary", @config={"database"=>"my_db"}>
241
- # ]>
242
- #
243
- # Resolver.new(configurations).resolve_symbol_connection(:production, "primary")
244
- # # => { "database" => "my_db" }
245
- def resolve_symbol_connection(env_name, pool_name)
246
- db_config = configurations.find_db_config(env_name)
247
-
248
- if db_config
249
- resolve_connection(db_config.config).merge("name" => pool_name.to_s)
250
- else
251
- raise AdapterNotSpecified, <<~MSG
252
- The `#{env_name}` database is not configured for the `#{ActiveRecord::ConnectionHandling::DEFAULT_ENV.call}` environment.
253
-
254
- Available databases configurations are:
255
-
256
- #{build_configuration_sentence}
257
- MSG
258
- end
259
- end
260
-
261
- def build_configuration_sentence # :nodoc:
262
- configs = configurations.configs_for(include_replicas: true)
263
-
264
- configs.group_by(&:env_name).map do |env, config|
265
- namespaces = config.map(&:spec_name)
266
- if namespaces.size > 1
267
- "#{env}: #{namespaces.join(", ")}"
268
- else
269
- env
270
- end
271
- end.join("\n")
272
- end
273
-
274
- # Accepts a hash. Expands the "url" key that contains a
275
- # URL database connection to a full connection
276
- # hash and merges with the rest of the hash.
277
- # Connection details inside of the "url" key win any merge conflicts
278
- def resolve_hash_connection(spec)
279
- if spec["url"] && spec["url"] !~ /^jdbc:/
280
- connection_hash = resolve_url_connection(spec.delete("url"))
281
- spec.merge!(connection_hash)
282
- end
283
- spec
284
- end
285
-
286
- # Takes a connection URL.
287
- #
288
- # Resolver.new({}).resolve_url_connection("postgresql://localhost/foo")
289
- # # => { "host" => "localhost", "database" => "foo", "adapter" => "postgresql" }
290
- #
291
- def resolve_url_connection(url)
292
- ConnectionUrlResolver.new(url).to_hash
293
- end
294
- end
295
- end
296
- end
297
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveRecord
4
- module ConnectionAdapters
5
- module DetermineIfPreparableVisitor
6
- attr_accessor :preparable
7
-
8
- def accept(object, collector)
9
- @preparable = true
10
- super
11
- end
12
-
13
- def visit_Arel_Nodes_In(o, collector)
14
- @preparable = false
15
- super
16
- end
17
-
18
- def visit_Arel_Nodes_NotIn(o, collector)
19
- @preparable = false
20
- super
21
- end
22
-
23
- def visit_Arel_Nodes_SqlLiteral(o, collector)
24
- @preparable = false
25
- super
26
- end
27
- end
28
- end
29
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveRecord
4
- # This module exists because ActiveRecord::AttributeMethods::Dirty needs to
5
- # define callbacks, but continue to have its version of +save+ be the super
6
- # method of ActiveRecord::Callbacks. This will be removed when the removal
7
- # of deprecated code removes this need.
8
- module DefineCallbacks
9
- extend ActiveSupport::Concern
10
-
11
- module ClassMethods # :nodoc:
12
- include ActiveModel::Callbacks
13
- end
14
-
15
- included do
16
- include ActiveModel::Validations::Callbacks
17
-
18
- define_model_callbacks :initialize, :find, :touch, only: :after
19
- define_model_callbacks :save, :create, :update, :destroy
20
- end
21
- end
22
- end