activerecord 3.2.19 → 5.0.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.

Files changed (264) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +1715 -604
  3. data/MIT-LICENSE +2 -2
  4. data/README.rdoc +40 -45
  5. data/examples/performance.rb +33 -22
  6. data/examples/simple.rb +3 -4
  7. data/lib/active_record/aggregations.rb +76 -51
  8. data/lib/active_record/association_relation.rb +35 -0
  9. data/lib/active_record/associations/alias_tracker.rb +54 -40
  10. data/lib/active_record/associations/association.rb +76 -56
  11. data/lib/active_record/associations/association_scope.rb +125 -93
  12. data/lib/active_record/associations/belongs_to_association.rb +57 -28
  13. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +7 -2
  14. data/lib/active_record/associations/builder/association.rb +120 -32
  15. data/lib/active_record/associations/builder/belongs_to.rb +115 -62
  16. data/lib/active_record/associations/builder/collection_association.rb +61 -53
  17. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +117 -43
  18. data/lib/active_record/associations/builder/has_many.rb +9 -65
  19. data/lib/active_record/associations/builder/has_one.rb +18 -52
  20. data/lib/active_record/associations/builder/singular_association.rb +18 -19
  21. data/lib/active_record/associations/collection_association.rb +268 -186
  22. data/lib/active_record/associations/collection_proxy.rb +1003 -63
  23. data/lib/active_record/associations/foreign_association.rb +11 -0
  24. data/lib/active_record/associations/has_many_association.rb +81 -41
  25. data/lib/active_record/associations/has_many_through_association.rb +76 -55
  26. data/lib/active_record/associations/has_one_association.rb +51 -21
  27. data/lib/active_record/associations/has_one_through_association.rb +1 -1
  28. data/lib/active_record/associations/join_dependency/join_association.rb +83 -108
  29. data/lib/active_record/associations/join_dependency/join_base.rb +7 -9
  30. data/lib/active_record/associations/join_dependency/join_part.rb +30 -37
  31. data/lib/active_record/associations/join_dependency.rb +239 -155
  32. data/lib/active_record/associations/preloader/association.rb +97 -62
  33. data/lib/active_record/associations/preloader/collection_association.rb +2 -8
  34. data/lib/active_record/associations/preloader/has_many_through.rb +7 -3
  35. data/lib/active_record/associations/preloader/has_one.rb +0 -8
  36. data/lib/active_record/associations/preloader/singular_association.rb +3 -3
  37. data/lib/active_record/associations/preloader/through_association.rb +75 -33
  38. data/lib/active_record/associations/preloader.rb +111 -79
  39. data/lib/active_record/associations/singular_association.rb +35 -13
  40. data/lib/active_record/associations/through_association.rb +41 -19
  41. data/lib/active_record/associations.rb +727 -501
  42. data/lib/active_record/attribute/user_provided_default.rb +28 -0
  43. data/lib/active_record/attribute.rb +213 -0
  44. data/lib/active_record/attribute_assignment.rb +32 -162
  45. data/lib/active_record/attribute_decorators.rb +67 -0
  46. data/lib/active_record/attribute_methods/before_type_cast.rb +52 -7
  47. data/lib/active_record/attribute_methods/dirty.rb +101 -61
  48. data/lib/active_record/attribute_methods/primary_key.rb +50 -36
  49. data/lib/active_record/attribute_methods/query.rb +7 -6
  50. data/lib/active_record/attribute_methods/read.rb +56 -117
  51. data/lib/active_record/attribute_methods/serialization.rb +43 -96
  52. data/lib/active_record/attribute_methods/time_zone_conversion.rb +93 -42
  53. data/lib/active_record/attribute_methods/write.rb +34 -45
  54. data/lib/active_record/attribute_methods.rb +333 -144
  55. data/lib/active_record/attribute_mutation_tracker.rb +70 -0
  56. data/lib/active_record/attribute_set/builder.rb +108 -0
  57. data/lib/active_record/attribute_set.rb +108 -0
  58. data/lib/active_record/attributes.rb +265 -0
  59. data/lib/active_record/autosave_association.rb +285 -223
  60. data/lib/active_record/base.rb +95 -490
  61. data/lib/active_record/callbacks.rb +95 -61
  62. data/lib/active_record/coders/json.rb +13 -0
  63. data/lib/active_record/coders/yaml_column.rb +28 -19
  64. data/lib/active_record/collection_cache_key.rb +40 -0
  65. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +724 -277
  66. data/lib/active_record/connection_adapters/abstract/database_limits.rb +9 -0
  67. data/lib/active_record/connection_adapters/abstract/database_statements.rb +199 -192
  68. data/lib/active_record/connection_adapters/abstract/query_cache.rb +31 -26
  69. data/lib/active_record/connection_adapters/abstract/quoting.rb +140 -57
  70. data/lib/active_record/connection_adapters/abstract/savepoints.rb +21 -0
  71. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +147 -0
  72. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +419 -276
  73. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +105 -0
  74. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +963 -276
  75. data/lib/active_record/connection_adapters/abstract/transaction.rb +232 -0
  76. data/lib/active_record/connection_adapters/abstract_adapter.rb +397 -106
  77. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +643 -342
  78. data/lib/active_record/connection_adapters/column.rb +30 -259
  79. data/lib/active_record/connection_adapters/connection_specification.rb +263 -0
  80. data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +22 -0
  81. data/lib/active_record/connection_adapters/mysql/column.rb +50 -0
  82. data/lib/active_record/connection_adapters/mysql/database_statements.rb +125 -0
  83. data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +70 -0
  84. data/lib/active_record/connection_adapters/mysql/quoting.rb +51 -0
  85. data/lib/active_record/connection_adapters/mysql/schema_creation.rb +67 -0
  86. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +93 -0
  87. data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +54 -0
  88. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +32 -0
  89. data/lib/active_record/connection_adapters/mysql2_adapter.rb +47 -196
  90. data/lib/active_record/connection_adapters/postgresql/column.rb +15 -0
  91. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +170 -0
  92. data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +42 -0
  93. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +70 -0
  94. data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +52 -0
  95. data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +13 -0
  96. data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +15 -0
  97. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +48 -0
  98. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +21 -0
  99. data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +13 -0
  100. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +19 -0
  101. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +59 -0
  102. data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +13 -0
  103. data/lib/active_record/connection_adapters/postgresql/oid/json.rb +10 -0
  104. data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +23 -0
  105. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +39 -0
  106. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +43 -0
  107. data/lib/active_record/connection_adapters/postgresql/oid/rails_5_1_point.rb +50 -0
  108. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +93 -0
  109. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +15 -0
  110. data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +109 -0
  111. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +21 -0
  112. data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +26 -0
  113. data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +28 -0
  114. data/lib/active_record/connection_adapters/postgresql/oid.rb +31 -0
  115. data/lib/active_record/connection_adapters/postgresql/quoting.rb +116 -0
  116. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +49 -0
  117. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +180 -0
  118. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +47 -0
  119. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +682 -0
  120. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +35 -0
  121. data/lib/active_record/connection_adapters/postgresql/utils.rb +77 -0
  122. data/lib/active_record/connection_adapters/postgresql_adapter.rb +558 -1039
  123. data/lib/active_record/connection_adapters/schema_cache.rb +74 -36
  124. data/lib/active_record/connection_adapters/sql_type_metadata.rb +32 -0
  125. data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +19 -0
  126. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +48 -0
  127. data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +22 -0
  128. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +538 -24
  129. data/lib/active_record/connection_adapters/statement_pool.rb +31 -12
  130. data/lib/active_record/connection_handling.rb +155 -0
  131. data/lib/active_record/core.rb +561 -0
  132. data/lib/active_record/counter_cache.rb +146 -105
  133. data/lib/active_record/dynamic_matchers.rb +101 -64
  134. data/lib/active_record/enum.rb +234 -0
  135. data/lib/active_record/errors.rb +153 -56
  136. data/lib/active_record/explain.rb +15 -63
  137. data/lib/active_record/explain_registry.rb +30 -0
  138. data/lib/active_record/explain_subscriber.rb +10 -6
  139. data/lib/active_record/fixture_set/file.rb +77 -0
  140. data/lib/active_record/fixtures.rb +355 -232
  141. data/lib/active_record/gem_version.rb +15 -0
  142. data/lib/active_record/inheritance.rb +144 -79
  143. data/lib/active_record/integration.rb +66 -13
  144. data/lib/active_record/internal_metadata.rb +56 -0
  145. data/lib/active_record/legacy_yaml_adapter.rb +46 -0
  146. data/lib/active_record/locale/en.yml +9 -1
  147. data/lib/active_record/locking/optimistic.rb +77 -56
  148. data/lib/active_record/locking/pessimistic.rb +6 -6
  149. data/lib/active_record/log_subscriber.rb +53 -28
  150. data/lib/active_record/migration/command_recorder.rb +166 -33
  151. data/lib/active_record/migration/compatibility.rb +126 -0
  152. data/lib/active_record/migration/join_table.rb +15 -0
  153. data/lib/active_record/migration.rb +792 -264
  154. data/lib/active_record/model_schema.rb +192 -130
  155. data/lib/active_record/nested_attributes.rb +238 -145
  156. data/lib/active_record/no_touching.rb +52 -0
  157. data/lib/active_record/null_relation.rb +89 -0
  158. data/lib/active_record/persistence.rb +357 -157
  159. data/lib/active_record/query_cache.rb +22 -43
  160. data/lib/active_record/querying.rb +34 -23
  161. data/lib/active_record/railtie.rb +88 -48
  162. data/lib/active_record/railties/console_sandbox.rb +3 -4
  163. data/lib/active_record/railties/controller_runtime.rb +5 -4
  164. data/lib/active_record/railties/databases.rake +170 -422
  165. data/lib/active_record/railties/jdbcmysql_error.rb +1 -1
  166. data/lib/active_record/readonly_attributes.rb +2 -5
  167. data/lib/active_record/reflection.rb +715 -189
  168. data/lib/active_record/relation/batches/batch_enumerator.rb +67 -0
  169. data/lib/active_record/relation/batches.rb +203 -50
  170. data/lib/active_record/relation/calculations.rb +203 -194
  171. data/lib/active_record/relation/delegation.rb +103 -25
  172. data/lib/active_record/relation/finder_methods.rb +457 -261
  173. data/lib/active_record/relation/from_clause.rb +32 -0
  174. data/lib/active_record/relation/merger.rb +167 -0
  175. data/lib/active_record/relation/predicate_builder/array_handler.rb +43 -0
  176. data/lib/active_record/relation/predicate_builder/association_query_handler.rb +88 -0
  177. data/lib/active_record/relation/predicate_builder/base_handler.rb +17 -0
  178. data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +17 -0
  179. data/lib/active_record/relation/predicate_builder/class_handler.rb +27 -0
  180. data/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb +57 -0
  181. data/lib/active_record/relation/predicate_builder/range_handler.rb +33 -0
  182. data/lib/active_record/relation/predicate_builder/relation_handler.rb +13 -0
  183. data/lib/active_record/relation/predicate_builder.rb +153 -48
  184. data/lib/active_record/relation/query_attribute.rb +19 -0
  185. data/lib/active_record/relation/query_methods.rb +1019 -194
  186. data/lib/active_record/relation/record_fetch_warning.rb +49 -0
  187. data/lib/active_record/relation/spawn_methods.rb +46 -150
  188. data/lib/active_record/relation/where_clause.rb +174 -0
  189. data/lib/active_record/relation/where_clause_factory.rb +38 -0
  190. data/lib/active_record/relation.rb +450 -245
  191. data/lib/active_record/result.rb +104 -12
  192. data/lib/active_record/runtime_registry.rb +22 -0
  193. data/lib/active_record/sanitization.rb +120 -94
  194. data/lib/active_record/schema.rb +28 -18
  195. data/lib/active_record/schema_dumper.rb +141 -74
  196. data/lib/active_record/schema_migration.rb +50 -0
  197. data/lib/active_record/scoping/default.rb +64 -57
  198. data/lib/active_record/scoping/named.rb +93 -108
  199. data/lib/active_record/scoping.rb +73 -121
  200. data/lib/active_record/secure_token.rb +38 -0
  201. data/lib/active_record/serialization.rb +7 -5
  202. data/lib/active_record/statement_cache.rb +113 -0
  203. data/lib/active_record/store.rb +173 -15
  204. data/lib/active_record/suppressor.rb +58 -0
  205. data/lib/active_record/table_metadata.rb +68 -0
  206. data/lib/active_record/tasks/database_tasks.rb +313 -0
  207. data/lib/active_record/tasks/mysql_database_tasks.rb +151 -0
  208. data/lib/active_record/tasks/postgresql_database_tasks.rb +110 -0
  209. data/lib/active_record/tasks/sqlite_database_tasks.rb +59 -0
  210. data/lib/active_record/timestamp.rb +42 -24
  211. data/lib/active_record/touch_later.rb +58 -0
  212. data/lib/active_record/transactions.rb +233 -105
  213. data/lib/active_record/type/adapter_specific_registry.rb +130 -0
  214. data/lib/active_record/type/date.rb +7 -0
  215. data/lib/active_record/type/date_time.rb +7 -0
  216. data/lib/active_record/type/hash_lookup_type_map.rb +23 -0
  217. data/lib/active_record/type/internal/abstract_json.rb +29 -0
  218. data/lib/active_record/type/internal/timezone.rb +15 -0
  219. data/lib/active_record/type/serialized.rb +63 -0
  220. data/lib/active_record/type/time.rb +20 -0
  221. data/lib/active_record/type/type_map.rb +64 -0
  222. data/lib/active_record/type.rb +72 -0
  223. data/lib/active_record/type_caster/connection.rb +29 -0
  224. data/lib/active_record/type_caster/map.rb +19 -0
  225. data/lib/active_record/type_caster.rb +7 -0
  226. data/lib/active_record/validations/absence.rb +23 -0
  227. data/lib/active_record/validations/associated.rb +33 -18
  228. data/lib/active_record/validations/length.rb +24 -0
  229. data/lib/active_record/validations/presence.rb +66 -0
  230. data/lib/active_record/validations/uniqueness.rb +128 -68
  231. data/lib/active_record/validations.rb +48 -40
  232. data/lib/active_record/version.rb +5 -7
  233. data/lib/active_record.rb +71 -47
  234. data/lib/rails/generators/active_record/migration/migration_generator.rb +56 -8
  235. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +24 -0
  236. data/lib/rails/generators/active_record/migration/templates/migration.rb +28 -16
  237. data/lib/rails/generators/active_record/migration.rb +18 -8
  238. data/lib/rails/generators/active_record/model/model_generator.rb +38 -16
  239. data/lib/rails/generators/active_record/model/templates/application_record.rb +5 -0
  240. data/lib/rails/generators/active_record/model/templates/model.rb +7 -6
  241. data/lib/rails/generators/active_record/model/templates/module.rb +1 -1
  242. data/lib/rails/generators/active_record.rb +3 -11
  243. metadata +188 -134
  244. data/examples/associations.png +0 -0
  245. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +0 -63
  246. data/lib/active_record/associations/join_helper.rb +0 -55
  247. data/lib/active_record/associations/preloader/has_and_belongs_to_many.rb +0 -60
  248. data/lib/active_record/attribute_methods/deprecated_underscore_read.rb +0 -32
  249. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +0 -191
  250. data/lib/active_record/connection_adapters/mysql_adapter.rb +0 -441
  251. data/lib/active_record/connection_adapters/sqlite_adapter.rb +0 -583
  252. data/lib/active_record/dynamic_finder_match.rb +0 -68
  253. data/lib/active_record/dynamic_scope_match.rb +0 -23
  254. data/lib/active_record/fixtures/file.rb +0 -65
  255. data/lib/active_record/identity_map.rb +0 -162
  256. data/lib/active_record/observer.rb +0 -121
  257. data/lib/active_record/serializers/xml_serializer.rb +0 -203
  258. data/lib/active_record/session_store.rb +0 -360
  259. data/lib/active_record/test_case.rb +0 -73
  260. data/lib/rails/generators/active_record/model/templates/migration.rb +0 -15
  261. data/lib/rails/generators/active_record/observer/observer_generator.rb +0 -15
  262. data/lib/rails/generators/active_record/observer/templates/observer.rb +0 -4
  263. data/lib/rails/generators/active_record/session_migration/session_migration_generator.rb +0 -25
  264. data/lib/rails/generators/active_record/session_migration/templates/migration.rb +0 -12
metadata CHANGED
@@ -1,103 +1,75 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: activerecord
3
- version: !ruby/object:Gem::Version
4
- hash: 41
5
- prerelease:
6
- segments:
7
- - 3
8
- - 2
9
- - 19
10
- version: 3.2.19
3
+ version: !ruby/object:Gem::Version
4
+ version: 5.0.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - David Heinemeier Hansson
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2014-07-02 00:00:00 -03:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - "="
26
- - !ruby/object:Gem::Version
27
- hash: 41
28
- segments:
29
- - 3
30
- - 2
31
- - 19
32
- version: 3.2.19
33
- type: :runtime
34
- version_requirements: *id001
35
- prerelease: false
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
36
14
  name: activesupport
37
- - !ruby/object:Gem::Dependency
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - "="
42
- - !ruby/object:Gem::Version
43
- hash: 41
44
- segments:
45
- - 3
46
- - 2
47
- - 19
48
- version: 3.2.19
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
49
20
  type: :runtime
50
- version_requirements: *id002
51
21
  prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 5.0.0
27
+ - !ruby/object:Gem::Dependency
52
28
  name: activemodel
53
- - !ruby/object:Gem::Dependency
54
- requirement: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
57
- - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 3
62
- - 0
63
- - 2
64
- version: 3.0.2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 5.0.0
65
34
  type: :runtime
66
- version_requirements: *id003
67
35
  prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 5.0.0
41
+ - !ruby/object:Gem::Dependency
68
42
  name: arel
69
- - !ruby/object:Gem::Dependency
70
- requirement: &id004 !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- hash: 41
76
- segments:
77
- - 0
78
- - 3
79
- - 29
80
- version: 0.3.29
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '7.0'
81
48
  type: :runtime
82
- version_requirements: *id004
83
49
  prerelease: false
84
- name: tzinfo
85
- description: Databases on Rails. Build a persistent domain model by mapping database tables to Ruby classes. Strong conventions for associations, validations, aggregations, migrations, and testing come baked-in.
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '7.0'
55
+ description: Databases on Rails. Build a persistent domain model by mapping database
56
+ tables to Ruby classes. Strong conventions for associations, validations, aggregations,
57
+ migrations, and testing come baked-in.
86
58
  email: david@loudthinking.com
87
59
  executables: []
88
-
89
60
  extensions: []
90
-
91
- extra_rdoc_files:
61
+ extra_rdoc_files:
92
62
  - README.rdoc
93
- files:
63
+ files:
94
64
  - CHANGELOG.md
95
65
  - MIT-LICENSE
96
66
  - README.rdoc
97
- - examples/associations.png
98
67
  - examples/performance.rb
99
68
  - examples/simple.rb
69
+ - lib/active_record.rb
100
70
  - lib/active_record/aggregations.rb
71
+ - lib/active_record/association_relation.rb
72
+ - lib/active_record/associations.rb
101
73
  - lib/active_record/associations/alias_tracker.rb
102
74
  - lib/active_record/associations/association.rb
103
75
  - lib/active_record/associations/association_scope.rb
@@ -112,33 +84,33 @@ files:
112
84
  - lib/active_record/associations/builder/singular_association.rb
113
85
  - lib/active_record/associations/collection_association.rb
114
86
  - lib/active_record/associations/collection_proxy.rb
115
- - lib/active_record/associations/has_and_belongs_to_many_association.rb
87
+ - lib/active_record/associations/foreign_association.rb
116
88
  - lib/active_record/associations/has_many_association.rb
117
89
  - lib/active_record/associations/has_many_through_association.rb
118
90
  - lib/active_record/associations/has_one_association.rb
119
91
  - lib/active_record/associations/has_one_through_association.rb
92
+ - lib/active_record/associations/join_dependency.rb
120
93
  - lib/active_record/associations/join_dependency/join_association.rb
121
94
  - lib/active_record/associations/join_dependency/join_base.rb
122
95
  - lib/active_record/associations/join_dependency/join_part.rb
123
- - lib/active_record/associations/join_dependency.rb
124
- - lib/active_record/associations/join_helper.rb
96
+ - lib/active_record/associations/preloader.rb
125
97
  - lib/active_record/associations/preloader/association.rb
126
98
  - lib/active_record/associations/preloader/belongs_to.rb
127
99
  - lib/active_record/associations/preloader/collection_association.rb
128
- - lib/active_record/associations/preloader/has_and_belongs_to_many.rb
129
100
  - lib/active_record/associations/preloader/has_many.rb
130
101
  - lib/active_record/associations/preloader/has_many_through.rb
131
102
  - lib/active_record/associations/preloader/has_one.rb
132
103
  - lib/active_record/associations/preloader/has_one_through.rb
133
104
  - lib/active_record/associations/preloader/singular_association.rb
134
105
  - lib/active_record/associations/preloader/through_association.rb
135
- - lib/active_record/associations/preloader.rb
136
106
  - lib/active_record/associations/singular_association.rb
137
107
  - lib/active_record/associations/through_association.rb
138
- - lib/active_record/associations.rb
108
+ - lib/active_record/attribute.rb
109
+ - lib/active_record/attribute/user_provided_default.rb
139
110
  - lib/active_record/attribute_assignment.rb
111
+ - lib/active_record/attribute_decorators.rb
112
+ - lib/active_record/attribute_methods.rb
140
113
  - lib/active_record/attribute_methods/before_type_cast.rb
141
- - lib/active_record/attribute_methods/deprecated_underscore_read.rb
142
114
  - lib/active_record/attribute_methods/dirty.rb
143
115
  - lib/active_record/attribute_methods/primary_key.rb
144
116
  - lib/active_record/attribute_methods/query.rb
@@ -146,50 +118,109 @@ files:
146
118
  - lib/active_record/attribute_methods/serialization.rb
147
119
  - lib/active_record/attribute_methods/time_zone_conversion.rb
148
120
  - lib/active_record/attribute_methods/write.rb
149
- - lib/active_record/attribute_methods.rb
121
+ - lib/active_record/attribute_mutation_tracker.rb
122
+ - lib/active_record/attribute_set.rb
123
+ - lib/active_record/attribute_set/builder.rb
124
+ - lib/active_record/attributes.rb
150
125
  - lib/active_record/autosave_association.rb
151
126
  - lib/active_record/base.rb
152
127
  - lib/active_record/callbacks.rb
128
+ - lib/active_record/coders/json.rb
153
129
  - lib/active_record/coders/yaml_column.rb
130
+ - lib/active_record/collection_cache_key.rb
154
131
  - lib/active_record/connection_adapters/abstract/connection_pool.rb
155
- - lib/active_record/connection_adapters/abstract/connection_specification.rb
156
132
  - lib/active_record/connection_adapters/abstract/database_limits.rb
157
133
  - lib/active_record/connection_adapters/abstract/database_statements.rb
158
134
  - lib/active_record/connection_adapters/abstract/query_cache.rb
159
135
  - lib/active_record/connection_adapters/abstract/quoting.rb
136
+ - lib/active_record/connection_adapters/abstract/savepoints.rb
137
+ - lib/active_record/connection_adapters/abstract/schema_creation.rb
160
138
  - lib/active_record/connection_adapters/abstract/schema_definitions.rb
139
+ - lib/active_record/connection_adapters/abstract/schema_dumper.rb
161
140
  - lib/active_record/connection_adapters/abstract/schema_statements.rb
141
+ - lib/active_record/connection_adapters/abstract/transaction.rb
162
142
  - lib/active_record/connection_adapters/abstract_adapter.rb
163
143
  - lib/active_record/connection_adapters/abstract_mysql_adapter.rb
164
144
  - lib/active_record/connection_adapters/column.rb
145
+ - lib/active_record/connection_adapters/connection_specification.rb
146
+ - lib/active_record/connection_adapters/determine_if_preparable_visitor.rb
147
+ - lib/active_record/connection_adapters/mysql/column.rb
148
+ - lib/active_record/connection_adapters/mysql/database_statements.rb
149
+ - lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb
150
+ - lib/active_record/connection_adapters/mysql/quoting.rb
151
+ - lib/active_record/connection_adapters/mysql/schema_creation.rb
152
+ - lib/active_record/connection_adapters/mysql/schema_definitions.rb
153
+ - lib/active_record/connection_adapters/mysql/schema_dumper.rb
154
+ - lib/active_record/connection_adapters/mysql/type_metadata.rb
165
155
  - lib/active_record/connection_adapters/mysql2_adapter.rb
166
- - lib/active_record/connection_adapters/mysql_adapter.rb
156
+ - lib/active_record/connection_adapters/postgresql/column.rb
157
+ - lib/active_record/connection_adapters/postgresql/database_statements.rb
158
+ - lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb
159
+ - lib/active_record/connection_adapters/postgresql/oid.rb
160
+ - lib/active_record/connection_adapters/postgresql/oid/array.rb
161
+ - lib/active_record/connection_adapters/postgresql/oid/bit.rb
162
+ - lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb
163
+ - lib/active_record/connection_adapters/postgresql/oid/bytea.rb
164
+ - lib/active_record/connection_adapters/postgresql/oid/cidr.rb
165
+ - lib/active_record/connection_adapters/postgresql/oid/date_time.rb
166
+ - lib/active_record/connection_adapters/postgresql/oid/decimal.rb
167
+ - lib/active_record/connection_adapters/postgresql/oid/enum.rb
168
+ - lib/active_record/connection_adapters/postgresql/oid/hstore.rb
169
+ - lib/active_record/connection_adapters/postgresql/oid/inet.rb
170
+ - lib/active_record/connection_adapters/postgresql/oid/json.rb
171
+ - lib/active_record/connection_adapters/postgresql/oid/jsonb.rb
172
+ - lib/active_record/connection_adapters/postgresql/oid/money.rb
173
+ - lib/active_record/connection_adapters/postgresql/oid/point.rb
174
+ - lib/active_record/connection_adapters/postgresql/oid/rails_5_1_point.rb
175
+ - lib/active_record/connection_adapters/postgresql/oid/range.rb
176
+ - lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb
177
+ - lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb
178
+ - lib/active_record/connection_adapters/postgresql/oid/uuid.rb
179
+ - lib/active_record/connection_adapters/postgresql/oid/vector.rb
180
+ - lib/active_record/connection_adapters/postgresql/oid/xml.rb
181
+ - lib/active_record/connection_adapters/postgresql/quoting.rb
182
+ - lib/active_record/connection_adapters/postgresql/referential_integrity.rb
183
+ - lib/active_record/connection_adapters/postgresql/schema_definitions.rb
184
+ - lib/active_record/connection_adapters/postgresql/schema_dumper.rb
185
+ - lib/active_record/connection_adapters/postgresql/schema_statements.rb
186
+ - lib/active_record/connection_adapters/postgresql/type_metadata.rb
187
+ - lib/active_record/connection_adapters/postgresql/utils.rb
167
188
  - lib/active_record/connection_adapters/postgresql_adapter.rb
168
189
  - lib/active_record/connection_adapters/schema_cache.rb
190
+ - lib/active_record/connection_adapters/sql_type_metadata.rb
191
+ - lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb
192
+ - lib/active_record/connection_adapters/sqlite3/quoting.rb
193
+ - lib/active_record/connection_adapters/sqlite3/schema_creation.rb
169
194
  - lib/active_record/connection_adapters/sqlite3_adapter.rb
170
- - lib/active_record/connection_adapters/sqlite_adapter.rb
171
195
  - lib/active_record/connection_adapters/statement_pool.rb
196
+ - lib/active_record/connection_handling.rb
197
+ - lib/active_record/core.rb
172
198
  - lib/active_record/counter_cache.rb
173
- - lib/active_record/dynamic_finder_match.rb
174
199
  - lib/active_record/dynamic_matchers.rb
175
- - lib/active_record/dynamic_scope_match.rb
200
+ - lib/active_record/enum.rb
176
201
  - lib/active_record/errors.rb
177
202
  - lib/active_record/explain.rb
203
+ - lib/active_record/explain_registry.rb
178
204
  - lib/active_record/explain_subscriber.rb
179
- - lib/active_record/fixtures/file.rb
205
+ - lib/active_record/fixture_set/file.rb
180
206
  - lib/active_record/fixtures.rb
181
- - lib/active_record/identity_map.rb
207
+ - lib/active_record/gem_version.rb
182
208
  - lib/active_record/inheritance.rb
183
209
  - lib/active_record/integration.rb
210
+ - lib/active_record/internal_metadata.rb
211
+ - lib/active_record/legacy_yaml_adapter.rb
184
212
  - lib/active_record/locale/en.yml
185
213
  - lib/active_record/locking/optimistic.rb
186
214
  - lib/active_record/locking/pessimistic.rb
187
215
  - lib/active_record/log_subscriber.rb
188
- - lib/active_record/migration/command_recorder.rb
189
216
  - lib/active_record/migration.rb
217
+ - lib/active_record/migration/command_recorder.rb
218
+ - lib/active_record/migration/compatibility.rb
219
+ - lib/active_record/migration/join_table.rb
190
220
  - lib/active_record/model_schema.rb
191
221
  - lib/active_record/nested_attributes.rb
192
- - lib/active_record/observer.rb
222
+ - lib/active_record/no_touching.rb
223
+ - lib/active_record/null_relation.rb
193
224
  - lib/active_record/persistence.rb
194
225
  - lib/active_record/query_cache.rb
195
226
  - lib/active_record/querying.rb
@@ -200,82 +231,105 @@ files:
200
231
  - lib/active_record/railties/jdbcmysql_error.rb
201
232
  - lib/active_record/readonly_attributes.rb
202
233
  - lib/active_record/reflection.rb
234
+ - lib/active_record/relation.rb
203
235
  - lib/active_record/relation/batches.rb
236
+ - lib/active_record/relation/batches/batch_enumerator.rb
204
237
  - lib/active_record/relation/calculations.rb
205
238
  - lib/active_record/relation/delegation.rb
206
239
  - lib/active_record/relation/finder_methods.rb
240
+ - lib/active_record/relation/from_clause.rb
241
+ - lib/active_record/relation/merger.rb
207
242
  - lib/active_record/relation/predicate_builder.rb
243
+ - lib/active_record/relation/predicate_builder/array_handler.rb
244
+ - lib/active_record/relation/predicate_builder/association_query_handler.rb
245
+ - lib/active_record/relation/predicate_builder/base_handler.rb
246
+ - lib/active_record/relation/predicate_builder/basic_object_handler.rb
247
+ - lib/active_record/relation/predicate_builder/class_handler.rb
248
+ - lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb
249
+ - lib/active_record/relation/predicate_builder/range_handler.rb
250
+ - lib/active_record/relation/predicate_builder/relation_handler.rb
251
+ - lib/active_record/relation/query_attribute.rb
208
252
  - lib/active_record/relation/query_methods.rb
253
+ - lib/active_record/relation/record_fetch_warning.rb
209
254
  - lib/active_record/relation/spawn_methods.rb
210
- - lib/active_record/relation.rb
255
+ - lib/active_record/relation/where_clause.rb
256
+ - lib/active_record/relation/where_clause_factory.rb
211
257
  - lib/active_record/result.rb
258
+ - lib/active_record/runtime_registry.rb
212
259
  - lib/active_record/sanitization.rb
213
260
  - lib/active_record/schema.rb
214
261
  - lib/active_record/schema_dumper.rb
262
+ - lib/active_record/schema_migration.rb
263
+ - lib/active_record/scoping.rb
215
264
  - lib/active_record/scoping/default.rb
216
265
  - lib/active_record/scoping/named.rb
217
- - lib/active_record/scoping.rb
266
+ - lib/active_record/secure_token.rb
218
267
  - lib/active_record/serialization.rb
219
- - lib/active_record/serializers/xml_serializer.rb
220
- - lib/active_record/session_store.rb
268
+ - lib/active_record/statement_cache.rb
221
269
  - lib/active_record/store.rb
222
- - lib/active_record/test_case.rb
270
+ - lib/active_record/suppressor.rb
271
+ - lib/active_record/table_metadata.rb
272
+ - lib/active_record/tasks/database_tasks.rb
273
+ - lib/active_record/tasks/mysql_database_tasks.rb
274
+ - lib/active_record/tasks/postgresql_database_tasks.rb
275
+ - lib/active_record/tasks/sqlite_database_tasks.rb
223
276
  - lib/active_record/timestamp.rb
277
+ - lib/active_record/touch_later.rb
224
278
  - lib/active_record/transactions.rb
225
279
  - lib/active_record/translation.rb
280
+ - lib/active_record/type.rb
281
+ - lib/active_record/type/adapter_specific_registry.rb
282
+ - lib/active_record/type/date.rb
283
+ - lib/active_record/type/date_time.rb
284
+ - lib/active_record/type/hash_lookup_type_map.rb
285
+ - lib/active_record/type/internal/abstract_json.rb
286
+ - lib/active_record/type/internal/timezone.rb
287
+ - lib/active_record/type/serialized.rb
288
+ - lib/active_record/type/time.rb
289
+ - lib/active_record/type/type_map.rb
290
+ - lib/active_record/type_caster.rb
291
+ - lib/active_record/type_caster/connection.rb
292
+ - lib/active_record/type_caster/map.rb
293
+ - lib/active_record/validations.rb
294
+ - lib/active_record/validations/absence.rb
226
295
  - lib/active_record/validations/associated.rb
296
+ - lib/active_record/validations/length.rb
297
+ - lib/active_record/validations/presence.rb
227
298
  - lib/active_record/validations/uniqueness.rb
228
- - lib/active_record/validations.rb
229
299
  - lib/active_record/version.rb
230
- - lib/active_record.rb
300
+ - lib/rails/generators/active_record.rb
301
+ - lib/rails/generators/active_record/migration.rb
231
302
  - lib/rails/generators/active_record/migration/migration_generator.rb
303
+ - lib/rails/generators/active_record/migration/templates/create_table_migration.rb
232
304
  - lib/rails/generators/active_record/migration/templates/migration.rb
233
- - lib/rails/generators/active_record/migration.rb
234
305
  - lib/rails/generators/active_record/model/model_generator.rb
235
- - lib/rails/generators/active_record/model/templates/migration.rb
306
+ - lib/rails/generators/active_record/model/templates/application_record.rb
236
307
  - lib/rails/generators/active_record/model/templates/model.rb
237
308
  - lib/rails/generators/active_record/model/templates/module.rb
238
- - lib/rails/generators/active_record/observer/observer_generator.rb
239
- - lib/rails/generators/active_record/observer/templates/observer.rb
240
- - lib/rails/generators/active_record/session_migration/session_migration_generator.rb
241
- - lib/rails/generators/active_record/session_migration/templates/migration.rb
242
- - lib/rails/generators/active_record.rb
243
- has_rdoc: true
244
- homepage: http://www.rubyonrails.org
245
- licenses:
309
+ homepage: http://rubyonrails.org
310
+ licenses:
246
311
  - MIT
312
+ metadata: {}
247
313
  post_install_message:
248
- rdoc_options:
249
- - --main
314
+ rdoc_options:
315
+ - "--main"
250
316
  - README.rdoc
251
- require_paths:
317
+ require_paths:
252
318
  - lib
253
- required_ruby_version: !ruby/object:Gem::Requirement
254
- none: false
255
- requirements:
319
+ required_ruby_version: !ruby/object:Gem::Requirement
320
+ requirements:
256
321
  - - ">="
257
- - !ruby/object:Gem::Version
258
- hash: 57
259
- segments:
260
- - 1
261
- - 8
262
- - 7
263
- version: 1.8.7
264
- required_rubygems_version: !ruby/object:Gem::Requirement
265
- none: false
266
- requirements:
322
+ - !ruby/object:Gem::Version
323
+ version: 2.2.2
324
+ required_rubygems_version: !ruby/object:Gem::Requirement
325
+ requirements:
267
326
  - - ">="
268
- - !ruby/object:Gem::Version
269
- hash: 3
270
- segments:
271
- - 0
272
- version: "0"
327
+ - !ruby/object:Gem::Version
328
+ version: '0'
273
329
  requirements: []
274
-
275
330
  rubyforge_project:
276
- rubygems_version: 1.6.2
331
+ rubygems_version: 2.6.4
277
332
  signing_key:
278
- specification_version: 3
333
+ specification_version: 4
279
334
  summary: Object-relational mapper framework (part of Rails).
280
335
  test_files: []
281
-
Binary file
@@ -1,63 +0,0 @@
1
- module ActiveRecord
2
- # = Active Record Has And Belongs To Many Association
3
- module Associations
4
- class HasAndBelongsToManyAssociation < CollectionAssociation #:nodoc:
5
- attr_reader :join_table
6
-
7
- def initialize(owner, reflection)
8
- @join_table = Arel::Table.new(reflection.options[:join_table])
9
- super
10
- end
11
-
12
- def insert_record(record, validate = true, raise = false)
13
- if record.new_record?
14
- if raise
15
- record.save!(:validate => validate)
16
- else
17
- return unless record.save(:validate => validate)
18
- end
19
- end
20
-
21
- if options[:insert_sql]
22
- owner.connection.insert(interpolate(options[:insert_sql], record))
23
- else
24
- stmt = join_table.compile_insert(
25
- join_table[reflection.foreign_key] => owner.id,
26
- join_table[reflection.association_foreign_key] => record.id
27
- )
28
-
29
- owner.connection.insert stmt
30
- end
31
-
32
- record
33
- end
34
-
35
- # ActiveRecord::Relation#delete_all needs to support joins before we can use a
36
- # SQL-only implementation.
37
- alias delete_all_on_destroy delete_all
38
-
39
- private
40
-
41
- def count_records
42
- load_target.size
43
- end
44
-
45
- def delete_records(records, method)
46
- if sql = options[:delete_sql]
47
- records = load_target if records == :all
48
- records.each { |record| owner.connection.delete(interpolate(sql, record)) }
49
- else
50
- relation = join_table
51
- stmt = relation.where(relation[reflection.foreign_key].eq(owner.id).
52
- and(relation[reflection.association_foreign_key].in(records.map { |x| x.id }.compact))
53
- ).compile_delete
54
- owner.connection.delete stmt
55
- end
56
- end
57
-
58
- def invertible_for?(record)
59
- false
60
- end
61
- end
62
- end
63
- end
@@ -1,55 +0,0 @@
1
- module ActiveRecord
2
- module Associations
3
- # Helper class module which gets mixed into JoinDependency::JoinAssociation and AssociationScope
4
- module JoinHelper #:nodoc:
5
-
6
- def join_type
7
- Arel::InnerJoin
8
- end
9
-
10
- private
11
-
12
- def construct_tables
13
- tables = []
14
- chain.each do |reflection|
15
- tables << alias_tracker.aliased_table_for(
16
- table_name_for(reflection),
17
- table_alias_for(reflection, reflection != self.reflection)
18
- )
19
-
20
- if reflection.source_macro == :has_and_belongs_to_many
21
- tables << alias_tracker.aliased_table_for(
22
- (reflection.source_reflection || reflection).options[:join_table],
23
- table_alias_for(reflection, true)
24
- )
25
- end
26
- end
27
- tables
28
- end
29
-
30
- def table_name_for(reflection)
31
- reflection.table_name
32
- end
33
-
34
- def table_alias_for(reflection, join = false)
35
- name = "#{reflection.plural_name}_#{alias_suffix}"
36
- name << "_join" if join
37
- name
38
- end
39
-
40
- def join(table, constraint)
41
- table.create_join(table, table.create_on(constraint), join_type)
42
- end
43
-
44
- def sanitize(conditions, table)
45
- conditions = conditions.map do |condition|
46
- condition = active_record.send(:sanitize_sql, interpolate(condition), table.table_alias || table.name)
47
- condition = Arel.sql(condition) unless condition.is_a?(Arel::Node)
48
- condition
49
- end
50
-
51
- conditions.length == 1 ? conditions.first : Arel::Nodes::And.new(conditions)
52
- end
53
- end
54
- end
55
- end
@@ -1,60 +0,0 @@
1
- module ActiveRecord
2
- module Associations
3
- class Preloader
4
- class HasAndBelongsToMany < CollectionAssociation #:nodoc:
5
- attr_reader :join_table
6
-
7
- def initialize(klass, records, reflection, preload_options)
8
- super
9
- @join_table = Arel::Table.new(options[:join_table]).alias('t0')
10
- end
11
-
12
- # Unlike the other associations, we want to get a raw array of rows so that we can
13
- # access the aliased column on the join table
14
- def records_for(ids)
15
- scope = super
16
- klass.connection.select_all(scope.arel, 'SQL', scope.bind_values)
17
- end
18
-
19
- def owner_key_name
20
- reflection.active_record_primary_key
21
- end
22
-
23
- def association_key_name
24
- 'ar_association_key_name'
25
- end
26
-
27
- def association_key
28
- join_table[reflection.foreign_key]
29
- end
30
-
31
- private
32
-
33
- # Once we have used the join table column (in super), we manually instantiate the
34
- # actual records, ensuring that we don't create more than one instances of the same
35
- # record
36
- def associated_records_by_owner
37
- records = {}
38
- super.each do |owner_key, rows|
39
- rows.map! { |row| records[row[klass.primary_key]] ||= klass.instantiate(row) }
40
- end
41
- end
42
-
43
- def build_scope
44
- super.joins(join).select(join_select)
45
- end
46
-
47
- def join_select
48
- association_key.as(Arel.sql(association_key_name))
49
- end
50
-
51
- def join
52
- condition = table[reflection.association_primary_key].eq(
53
- join_table[reflection.association_foreign_key])
54
-
55
- table.create_join(join_table, table.create_on(condition))
56
- end
57
- end
58
- end
59
- end
60
- end
@@ -1,32 +0,0 @@
1
- require 'active_support/concern'
2
- require 'active_support/deprecation'
3
-
4
- module ActiveRecord
5
- module AttributeMethods
6
- module DeprecatedUnderscoreRead
7
- extend ActiveSupport::Concern
8
-
9
- included do
10
- attribute_method_prefix "_"
11
- end
12
-
13
- module ClassMethods
14
- protected
15
-
16
- def define_method__attribute(attr_name)
17
- # Do nothing, let it hit method missing instead.
18
- end
19
- end
20
-
21
- protected
22
-
23
- def _attribute(attr_name)
24
- ActiveSupport::Deprecation.warn(
25
- "You have called '_#{attr_name}'. This is deprecated. Please use " \
26
- "either '#{attr_name}' or read_attribute('#{attr_name}')."
27
- )
28
- read_attribute(attr_name)
29
- end
30
- end
31
- end
32
- end