activerecord 5.0.6 → 6.0.1
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 +5 -5
- data/CHANGELOG.md +638 -2023
- data/MIT-LICENSE +3 -1
- data/README.rdoc +8 -6
- data/examples/performance.rb +31 -29
- data/examples/simple.rb +5 -3
- data/lib/active_record/aggregations.rb +249 -246
- data/lib/active_record/association_relation.rb +24 -13
- data/lib/active_record/associations/alias_tracker.rb +24 -33
- data/lib/active_record/associations/association.rb +119 -56
- data/lib/active_record/associations/association_scope.rb +94 -94
- data/lib/active_record/associations/belongs_to_association.rb +58 -42
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +8 -12
- data/lib/active_record/associations/builder/association.rb +18 -25
- data/lib/active_record/associations/builder/belongs_to.rb +43 -54
- data/lib/active_record/associations/builder/collection_association.rb +7 -18
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +42 -61
- data/lib/active_record/associations/builder/has_many.rb +4 -0
- data/lib/active_record/associations/builder/has_one.rb +37 -1
- data/lib/active_record/associations/builder/singular_association.rb +4 -0
- data/lib/active_record/associations/collection_association.rb +80 -252
- data/lib/active_record/associations/collection_proxy.rb +158 -121
- data/lib/active_record/associations/foreign_association.rb +9 -0
- data/lib/active_record/associations/has_many_association.rb +23 -29
- data/lib/active_record/associations/has_many_through_association.rb +58 -44
- data/lib/active_record/associations/has_one_association.rb +59 -54
- data/lib/active_record/associations/has_one_through_association.rb +20 -11
- data/lib/active_record/associations/join_dependency/join_association.rb +38 -90
- data/lib/active_record/associations/join_dependency/join_base.rb +10 -9
- data/lib/active_record/associations/join_dependency/join_part.rb +12 -12
- data/lib/active_record/associations/join_dependency.rb +134 -176
- data/lib/active_record/associations/preloader/association.rb +84 -125
- data/lib/active_record/associations/preloader/through_association.rb +82 -75
- data/lib/active_record/associations/preloader.rb +90 -102
- data/lib/active_record/associations/singular_association.rb +12 -45
- data/lib/active_record/associations/through_association.rb +26 -14
- data/lib/active_record/associations.rb +1603 -1592
- data/lib/active_record/attribute_assignment.rb +54 -60
- data/lib/active_record/attribute_decorators.rb +38 -15
- data/lib/active_record/attribute_methods/before_type_cast.rb +12 -7
- data/lib/active_record/attribute_methods/dirty.rb +179 -109
- data/lib/active_record/attribute_methods/primary_key.rb +86 -91
- data/lib/active_record/attribute_methods/query.rb +4 -3
- data/lib/active_record/attribute_methods/read.rb +21 -49
- data/lib/active_record/attribute_methods/serialization.rb +30 -7
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +39 -64
- data/lib/active_record/attribute_methods/write.rb +35 -33
- data/lib/active_record/attribute_methods.rb +66 -106
- data/lib/active_record/attributes.rb +38 -24
- data/lib/active_record/autosave_association.rb +53 -32
- data/lib/active_record/base.rb +27 -24
- data/lib/active_record/callbacks.rb +63 -33
- data/lib/active_record/coders/json.rb +2 -0
- data/lib/active_record/coders/yaml_column.rb +11 -11
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +553 -321
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +23 -5
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +213 -94
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +59 -28
- data/lib/active_record/connection_adapters/abstract/quoting.rb +119 -75
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +2 -0
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +33 -27
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +207 -126
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +68 -80
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +369 -199
- data/lib/active_record/connection_adapters/abstract/transaction.rb +169 -78
- data/lib/active_record/connection_adapters/abstract_adapter.rb +363 -202
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +405 -551
- data/lib/active_record/connection_adapters/column.rb +41 -13
- data/lib/active_record/connection_adapters/connection_specification.rb +172 -138
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +11 -4
- data/lib/active_record/connection_adapters/mysql/column.rb +8 -31
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +143 -49
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +24 -22
- data/lib/active_record/connection_adapters/mysql/quoting.rb +50 -20
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +50 -45
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +58 -56
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +70 -36
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +264 -0
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +12 -13
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +49 -30
- data/lib/active_record/connection_adapters/postgresql/column.rb +22 -7
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +60 -54
- data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +5 -3
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +22 -10
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +6 -5
- data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +23 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +4 -2
- data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +5 -3
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +19 -17
- data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +3 -11
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +45 -0
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +7 -5
- data/lib/active_record/connection_adapters/postgresql/oid/{json.rb → oid.rb} +6 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +31 -9
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +34 -30
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +4 -1
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +58 -54
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +9 -4
- data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid.rb +24 -21
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +95 -35
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +19 -25
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +76 -0
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +147 -105
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +35 -32
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +380 -300
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +26 -25
- data/lib/active_record/connection_adapters/postgresql/utils.rb +10 -6
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +382 -275
- data/lib/active_record/connection_adapters/schema_cache.rb +46 -12
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +13 -8
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +120 -0
- data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +3 -1
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +74 -19
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +3 -8
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +19 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +18 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +137 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +254 -262
- data/lib/active_record/connection_adapters/statement_pool.rb +9 -7
- data/lib/active_record/connection_handling.rb +159 -40
- data/lib/active_record/core.rb +202 -162
- data/lib/active_record/counter_cache.rb +57 -28
- data/lib/active_record/database_configurations/database_config.rb +37 -0
- data/lib/active_record/database_configurations/hash_config.rb +50 -0
- data/lib/active_record/database_configurations/url_config.rb +79 -0
- data/lib/active_record/database_configurations.rb +233 -0
- data/lib/active_record/define_callbacks.rb +22 -0
- data/lib/active_record/dynamic_matchers.rb +87 -86
- data/lib/active_record/enum.rb +60 -23
- data/lib/active_record/errors.rb +114 -18
- data/lib/active_record/explain.rb +4 -3
- data/lib/active_record/explain_registry.rb +3 -1
- data/lib/active_record/explain_subscriber.rb +9 -4
- data/lib/active_record/fixture_set/file.rb +13 -8
- data/lib/active_record/fixture_set/model_metadata.rb +33 -0
- data/lib/active_record/fixture_set/render_context.rb +17 -0
- data/lib/active_record/fixture_set/table_row.rb +153 -0
- data/lib/active_record/fixture_set/table_rows.rb +47 -0
- data/lib/active_record/fixtures.rb +195 -502
- data/lib/active_record/gem_version.rb +4 -2
- data/lib/active_record/inheritance.rb +151 -97
- data/lib/active_record/insert_all.rb +179 -0
- data/lib/active_record/integration.rb +116 -25
- data/lib/active_record/internal_metadata.rb +15 -18
- data/lib/active_record/legacy_yaml_adapter.rb +4 -2
- data/lib/active_record/locking/optimistic.rb +78 -87
- data/lib/active_record/locking/pessimistic.rb +18 -6
- data/lib/active_record/log_subscriber.rb +48 -29
- data/lib/active_record/middleware/database_selector/resolver/session.rb +45 -0
- data/lib/active_record/middleware/database_selector/resolver.rb +88 -0
- data/lib/active_record/middleware/database_selector.rb +75 -0
- data/lib/active_record/migration/command_recorder.rb +143 -97
- data/lib/active_record/migration/compatibility.rb +174 -56
- data/lib/active_record/migration/join_table.rb +8 -6
- data/lib/active_record/migration.rb +367 -300
- data/lib/active_record/model_schema.rb +145 -139
- data/lib/active_record/nested_attributes.rb +214 -201
- data/lib/active_record/no_touching.rb +10 -1
- data/lib/active_record/null_relation.rb +13 -34
- data/lib/active_record/persistence.rb +442 -72
- data/lib/active_record/query_cache.rb +15 -14
- data/lib/active_record/querying.rb +36 -23
- data/lib/active_record/railtie.rb +128 -36
- data/lib/active_record/railties/collection_cache_association_loading.rb +34 -0
- data/lib/active_record/railties/console_sandbox.rb +2 -0
- data/lib/active_record/railties/controller_runtime.rb +34 -33
- data/lib/active_record/railties/databases.rake +309 -177
- data/lib/active_record/readonly_attributes.rb +5 -4
- data/lib/active_record/reflection.rb +211 -249
- data/lib/active_record/relation/batches/batch_enumerator.rb +3 -1
- data/lib/active_record/relation/batches.rb +99 -52
- data/lib/active_record/relation/calculations.rb +211 -172
- data/lib/active_record/relation/delegation.rb +67 -65
- data/lib/active_record/relation/finder_methods.rb +208 -247
- data/lib/active_record/relation/from_clause.rb +2 -8
- data/lib/active_record/relation/merger.rb +78 -61
- data/lib/active_record/relation/predicate_builder/array_handler.rb +20 -14
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +43 -0
- data/lib/active_record/relation/predicate_builder/base_handler.rb +4 -3
- data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +6 -4
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +53 -0
- data/lib/active_record/relation/predicate_builder/range_handler.rb +7 -18
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +6 -0
- data/lib/active_record/relation/predicate_builder.rb +86 -104
- data/lib/active_record/relation/query_attribute.rb +33 -2
- data/lib/active_record/relation/query_methods.rb +458 -329
- data/lib/active_record/relation/record_fetch_warning.rb +5 -3
- data/lib/active_record/relation/spawn_methods.rb +8 -7
- data/lib/active_record/relation/where_clause.rb +111 -95
- data/lib/active_record/relation/where_clause_factory.rb +6 -11
- data/lib/active_record/relation.rb +429 -318
- data/lib/active_record/result.rb +69 -39
- data/lib/active_record/runtime_registry.rb +5 -3
- data/lib/active_record/sanitization.rb +83 -99
- data/lib/active_record/schema.rb +7 -14
- data/lib/active_record/schema_dumper.rb +71 -69
- data/lib/active_record/schema_migration.rb +15 -5
- data/lib/active_record/scoping/default.rb +93 -95
- data/lib/active_record/scoping/named.rb +45 -25
- data/lib/active_record/scoping.rb +20 -19
- data/lib/active_record/secure_token.rb +4 -2
- data/lib/active_record/serialization.rb +2 -0
- data/lib/active_record/statement_cache.rb +63 -28
- data/lib/active_record/store.rb +121 -41
- data/lib/active_record/suppressor.rb +4 -1
- data/lib/active_record/table_metadata.rb +26 -20
- data/lib/active_record/tasks/database_tasks.rb +276 -85
- data/lib/active_record/tasks/mysql_database_tasks.rb +54 -90
- data/lib/active_record/tasks/postgresql_database_tasks.rb +78 -47
- data/lib/active_record/tasks/sqlite_database_tasks.rb +34 -16
- data/lib/active_record/test_databases.rb +23 -0
- data/lib/active_record/test_fixtures.rb +224 -0
- data/lib/active_record/timestamp.rb +70 -35
- data/lib/active_record/touch_later.rb +7 -4
- data/lib/active_record/transactions.rb +133 -149
- data/lib/active_record/translation.rb +3 -1
- data/lib/active_record/type/adapter_specific_registry.rb +44 -45
- data/lib/active_record/type/date.rb +2 -0
- data/lib/active_record/type/date_time.rb +2 -0
- data/lib/active_record/type/decimal_without_scale.rb +15 -0
- data/lib/active_record/type/hash_lookup_type_map.rb +5 -3
- data/lib/active_record/type/internal/timezone.rb +2 -0
- data/lib/active_record/type/json.rb +30 -0
- data/lib/active_record/type/serialized.rb +16 -8
- data/lib/active_record/type/text.rb +11 -0
- data/lib/active_record/type/time.rb +2 -1
- data/lib/active_record/type/type_map.rb +13 -15
- data/lib/active_record/type/unsigned_integer.rb +17 -0
- data/lib/active_record/type.rb +23 -17
- data/lib/active_record/type_caster/connection.rb +17 -12
- data/lib/active_record/type_caster/map.rb +5 -4
- data/lib/active_record/type_caster.rb +4 -2
- data/lib/active_record/validations/absence.rb +2 -0
- data/lib/active_record/validations/associated.rb +3 -1
- data/lib/active_record/validations/length.rb +2 -0
- data/lib/active_record/validations/presence.rb +4 -2
- data/lib/active_record/validations/uniqueness.rb +29 -42
- data/lib/active_record/validations.rb +7 -4
- data/lib/active_record/version.rb +3 -1
- data/lib/active_record.rb +36 -22
- data/lib/arel/alias_predication.rb +9 -0
- data/lib/arel/attributes/attribute.rb +37 -0
- data/lib/arel/attributes.rb +22 -0
- data/lib/arel/collectors/bind.rb +24 -0
- data/lib/arel/collectors/composite.rb +31 -0
- data/lib/arel/collectors/plain_string.rb +20 -0
- data/lib/arel/collectors/sql_string.rb +20 -0
- data/lib/arel/collectors/substitute_binds.rb +28 -0
- data/lib/arel/crud.rb +42 -0
- data/lib/arel/delete_manager.rb +18 -0
- data/lib/arel/errors.rb +9 -0
- data/lib/arel/expressions.rb +29 -0
- data/lib/arel/factory_methods.rb +49 -0
- data/lib/arel/insert_manager.rb +49 -0
- data/lib/arel/math.rb +45 -0
- data/lib/arel/nodes/and.rb +32 -0
- data/lib/arel/nodes/ascending.rb +23 -0
- data/lib/arel/nodes/binary.rb +52 -0
- data/lib/arel/nodes/bind_param.rb +36 -0
- data/lib/arel/nodes/case.rb +55 -0
- data/lib/arel/nodes/casted.rb +50 -0
- data/lib/arel/nodes/comment.rb +29 -0
- data/lib/arel/nodes/count.rb +12 -0
- data/lib/arel/nodes/delete_statement.rb +45 -0
- data/lib/arel/nodes/descending.rb +23 -0
- data/lib/arel/nodes/equality.rb +18 -0
- data/lib/arel/nodes/extract.rb +24 -0
- data/lib/arel/nodes/false.rb +16 -0
- data/lib/arel/nodes/full_outer_join.rb +8 -0
- data/lib/arel/nodes/function.rb +44 -0
- data/lib/arel/nodes/grouping.rb +8 -0
- data/lib/arel/nodes/in.rb +8 -0
- data/lib/arel/nodes/infix_operation.rb +80 -0
- data/lib/arel/nodes/inner_join.rb +8 -0
- data/lib/arel/nodes/insert_statement.rb +37 -0
- data/lib/arel/nodes/join_source.rb +20 -0
- data/lib/arel/nodes/matches.rb +18 -0
- data/lib/arel/nodes/named_function.rb +23 -0
- data/lib/arel/nodes/node.rb +50 -0
- data/lib/arel/nodes/node_expression.rb +13 -0
- data/lib/arel/nodes/outer_join.rb +8 -0
- data/lib/arel/nodes/over.rb +15 -0
- data/lib/arel/nodes/regexp.rb +16 -0
- data/lib/arel/nodes/right_outer_join.rb +8 -0
- data/lib/arel/nodes/select_core.rb +67 -0
- data/lib/arel/nodes/select_statement.rb +41 -0
- data/lib/arel/nodes/sql_literal.rb +16 -0
- data/lib/arel/nodes/string_join.rb +11 -0
- data/lib/arel/nodes/table_alias.rb +27 -0
- data/lib/arel/nodes/terminal.rb +16 -0
- data/lib/arel/nodes/true.rb +16 -0
- data/lib/arel/nodes/unary.rb +45 -0
- data/lib/arel/nodes/unary_operation.rb +20 -0
- data/lib/arel/nodes/unqualified_column.rb +22 -0
- data/lib/arel/nodes/update_statement.rb +41 -0
- data/lib/arel/nodes/values_list.rb +9 -0
- data/lib/arel/nodes/window.rb +126 -0
- data/lib/arel/nodes/with.rb +11 -0
- data/lib/arel/nodes.rb +68 -0
- data/lib/arel/order_predications.rb +13 -0
- data/lib/arel/predications.rb +257 -0
- data/lib/arel/select_manager.rb +271 -0
- data/lib/arel/table.rb +110 -0
- data/lib/arel/tree_manager.rb +72 -0
- data/lib/arel/update_manager.rb +34 -0
- data/lib/arel/visitors/depth_first.rb +204 -0
- data/lib/arel/visitors/dot.rb +297 -0
- data/lib/arel/visitors/ibm_db.rb +34 -0
- data/lib/arel/visitors/informix.rb +62 -0
- data/lib/arel/visitors/mssql.rb +157 -0
- data/lib/arel/visitors/mysql.rb +83 -0
- data/lib/arel/visitors/oracle.rb +159 -0
- data/lib/arel/visitors/oracle12.rb +66 -0
- data/lib/arel/visitors/postgresql.rb +110 -0
- data/lib/arel/visitors/sqlite.rb +39 -0
- data/lib/arel/visitors/to_sql.rb +889 -0
- data/lib/arel/visitors/visitor.rb +46 -0
- data/lib/arel/visitors/where_sql.rb +23 -0
- data/lib/arel/visitors.rb +20 -0
- data/lib/arel/window_predications.rb +9 -0
- data/lib/arel.rb +58 -0
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +27 -0
- data/lib/rails/generators/active_record/{model/templates/application_record.rb → application_record/templates/application_record.rb.tt} +0 -0
- data/lib/rails/generators/active_record/migration/migration_generator.rb +37 -35
- data/lib/rails/generators/active_record/migration/templates/{create_table_migration.rb → create_table_migration.rb.tt} +1 -1
- data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt} +4 -2
- data/lib/rails/generators/active_record/migration.rb +17 -2
- data/lib/rails/generators/active_record/model/model_generator.rb +9 -29
- data/lib/rails/generators/active_record/model/templates/{model.rb → model.rb.tt} +10 -1
- data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +0 -0
- data/lib/rails/generators/active_record.rb +7 -5
- metadata +133 -50
- data/lib/active_record/associations/preloader/belongs_to.rb +0 -17
- data/lib/active_record/associations/preloader/collection_association.rb +0 -17
- data/lib/active_record/associations/preloader/has_many.rb +0 -17
- data/lib/active_record/associations/preloader/has_many_through.rb +0 -19
- data/lib/active_record/associations/preloader/has_one.rb +0 -15
- data/lib/active_record/associations/preloader/has_one_through.rb +0 -9
- data/lib/active_record/associations/preloader/singular_association.rb +0 -20
- data/lib/active_record/attribute/user_provided_default.rb +0 -28
- data/lib/active_record/attribute.rb +0 -213
- data/lib/active_record/attribute_mutation_tracker.rb +0 -70
- data/lib/active_record/attribute_set/builder.rb +0 -130
- data/lib/active_record/attribute_set.rb +0 -110
- data/lib/active_record/collection_cache_key.rb +0 -50
- data/lib/active_record/connection_adapters/postgresql/oid/rails_5_1_point.rb +0 -50
- data/lib/active_record/railties/jdbcmysql_error.rb +0 -16
- data/lib/active_record/relation/predicate_builder/association_query_handler.rb +0 -88
- data/lib/active_record/relation/predicate_builder/class_handler.rb +0 -27
- data/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb +0 -57
- data/lib/active_record/type/internal/abstract_json.rb +0 -33
@@ -1,14 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
|
-
# = Active Record Has Many Through Association
|
3
4
|
module Associations
|
5
|
+
# = Active Record Has Many Through Association
|
4
6
|
class HasManyThroughAssociation < HasManyAssociation #:nodoc:
|
5
7
|
include ThroughAssociation
|
6
8
|
|
7
9
|
def initialize(owner, reflection)
|
8
10
|
super
|
9
|
-
|
10
|
-
@through_records = {}
|
11
|
-
@through_association = nil
|
11
|
+
@through_records = {}
|
12
12
|
end
|
13
13
|
|
14
14
|
def concat(*records)
|
@@ -21,24 +21,10 @@ module ActiveRecord
|
|
21
21
|
super
|
22
22
|
end
|
23
23
|
|
24
|
-
def concat_records(records)
|
25
|
-
ensure_not_nested
|
26
|
-
|
27
|
-
records = super(records, true)
|
28
|
-
|
29
|
-
if owner.new_record? && records
|
30
|
-
records.flatten.each do |record|
|
31
|
-
build_through_record(record)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
records
|
36
|
-
end
|
37
|
-
|
38
24
|
def insert_record(record, validate = true, raise = false)
|
39
25
|
ensure_not_nested
|
40
26
|
|
41
|
-
if record.new_record? || record.
|
27
|
+
if record.new_record? || record.has_changes_to_save?
|
42
28
|
return unless super
|
43
29
|
end
|
44
30
|
|
@@ -48,9 +34,18 @@ module ActiveRecord
|
|
48
34
|
end
|
49
35
|
|
50
36
|
private
|
37
|
+
def concat_records(records)
|
38
|
+
ensure_not_nested
|
39
|
+
|
40
|
+
records = super(records, true)
|
41
|
+
|
42
|
+
if owner.new_record? && records
|
43
|
+
records.flatten.each do |record|
|
44
|
+
build_through_record(record)
|
45
|
+
end
|
46
|
+
end
|
51
47
|
|
52
|
-
|
53
|
-
@through_association ||= owner.association(through_reflection.name)
|
48
|
+
records
|
54
49
|
end
|
55
50
|
|
56
51
|
# The through record (built with build_record) is temporarily cached
|
@@ -62,21 +57,14 @@ module ActiveRecord
|
|
62
57
|
@through_records[record.object_id] ||= begin
|
63
58
|
ensure_mutable
|
64
59
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
if options[:source_type]
|
69
|
-
through_record.send("#{source_reflection.foreign_type}=", options[:source_type])
|
70
|
-
end
|
60
|
+
attributes = through_scope_attributes
|
61
|
+
attributes[source_reflection.name] = record
|
62
|
+
attributes[source_reflection.foreign_type] = options[:source_type] if options[:source_type]
|
71
63
|
|
72
|
-
|
64
|
+
through_association.build(attributes)
|
73
65
|
end
|
74
66
|
end
|
75
67
|
|
76
|
-
def options_for_through_record
|
77
|
-
[through_scope_attributes]
|
78
|
-
end
|
79
|
-
|
80
68
|
def through_scope_attributes
|
81
69
|
scope.where_values_hash(through_association.reflection.name.to_s).
|
82
70
|
except!(through_association.reflection.foreign_key,
|
@@ -84,7 +72,10 @@ module ActiveRecord
|
|
84
72
|
end
|
85
73
|
|
86
74
|
def save_through_record(record)
|
87
|
-
build_through_record(record)
|
75
|
+
association = build_through_record(record)
|
76
|
+
if association.changed?
|
77
|
+
association.save!
|
78
|
+
end
|
88
79
|
ensure
|
89
80
|
@through_records.delete(record.object_id)
|
90
81
|
end
|
@@ -92,7 +83,7 @@ module ActiveRecord
|
|
92
83
|
def build_record(attributes)
|
93
84
|
ensure_not_nested
|
94
85
|
|
95
|
-
record = super
|
86
|
+
record = super
|
96
87
|
|
97
88
|
inverse = source_reflection.inverse_of
|
98
89
|
if inverse
|
@@ -106,6 +97,11 @@ module ActiveRecord
|
|
106
97
|
record
|
107
98
|
end
|
108
99
|
|
100
|
+
def remove_records(existing_records, records, method)
|
101
|
+
super
|
102
|
+
delete_through_records(records)
|
103
|
+
end
|
104
|
+
|
109
105
|
def target_reflection_has_associated_record?
|
110
106
|
!(through_reflection.belongs_to? && owner[through_reflection.foreign_key].blank?)
|
111
107
|
end
|
@@ -130,21 +126,15 @@ module ActiveRecord
|
|
130
126
|
|
131
127
|
scope = through_association.scope
|
132
128
|
scope.where! construct_join_attributes(*records)
|
129
|
+
scope = scope.where(through_scope_attributes)
|
133
130
|
|
134
131
|
case method
|
135
132
|
when :destroy
|
136
133
|
if scope.klass.primary_key
|
137
|
-
count = scope.destroy_all.
|
134
|
+
count = scope.destroy_all.count(&:destroyed?)
|
138
135
|
else
|
139
136
|
scope.each(&:_run_destroy_callbacks)
|
140
|
-
|
141
|
-
arel = scope.arel
|
142
|
-
|
143
|
-
stmt = Arel::DeleteManager.new
|
144
|
-
stmt.from scope.klass.arel_table
|
145
|
-
stmt.wheres = arel.constraints
|
146
|
-
|
147
|
-
count = scope.klass.connection.delete(stmt, 'SQL', scope.bound_attributes)
|
137
|
+
count = scope.delete_all
|
148
138
|
end
|
149
139
|
when :nullify
|
150
140
|
count = scope.update_all(source_reflection.foreign_key => nil)
|
@@ -164,6 +154,30 @@ module ActiveRecord
|
|
164
154
|
else
|
165
155
|
update_counter(-count)
|
166
156
|
end
|
157
|
+
|
158
|
+
count
|
159
|
+
end
|
160
|
+
|
161
|
+
def difference(a, b)
|
162
|
+
distribution = distribution(b)
|
163
|
+
|
164
|
+
a.reject { |record| mark_occurrence(distribution, record) }
|
165
|
+
end
|
166
|
+
|
167
|
+
def intersection(a, b)
|
168
|
+
distribution = distribution(b)
|
169
|
+
|
170
|
+
a.select { |record| mark_occurrence(distribution, record) }
|
171
|
+
end
|
172
|
+
|
173
|
+
def mark_occurrence(distribution, record)
|
174
|
+
distribution[record] > 0 && distribution[record] -= 1
|
175
|
+
end
|
176
|
+
|
177
|
+
def distribution(array)
|
178
|
+
array.each_with_object(Hash.new(0)) do |record, distribution|
|
179
|
+
distribution[record] += 1
|
180
|
+
end
|
167
181
|
end
|
168
182
|
|
169
183
|
def through_records_for(record)
|
@@ -194,7 +208,7 @@ module ActiveRecord
|
|
194
208
|
|
195
209
|
def find_target
|
196
210
|
return [] unless target_reflection_has_associated_record?
|
197
|
-
|
211
|
+
super
|
198
212
|
end
|
199
213
|
|
200
214
|
# NOTE - not sure that we can actually cope with inverses here
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
|
-
# = Active Record Has One Association
|
3
4
|
module Associations
|
5
|
+
# = Active Record Has One Association
|
4
6
|
class HasOneAssociation < SingularAssociation #:nodoc:
|
5
7
|
include ForeignAssociation
|
6
8
|
|
@@ -12,14 +14,7 @@ module ActiveRecord
|
|
12
14
|
when :restrict_with_error
|
13
15
|
if load_target
|
14
16
|
record = owner.class.human_attribute_name(reflection.name).downcase
|
15
|
-
|
16
|
-
if message
|
17
|
-
ActiveSupport::Deprecation.warn(<<-MESSAGE.squish)
|
18
|
-
The error key `:'restrict_dependent_destroy.one'` has been deprecated and will be removed in Rails 5.1.
|
19
|
-
Please use `:'restrict_dependent_destroy.has_one'` instead.
|
20
|
-
MESSAGE
|
21
|
-
end
|
22
|
-
owner.errors.add(:base, message || :'restrict_dependent_destroy.has_one', record: record)
|
17
|
+
owner.errors.add(:base, :'restrict_dependent_destroy.has_one', record: record)
|
23
18
|
throw(:abort)
|
24
19
|
end
|
25
20
|
|
@@ -28,49 +23,49 @@ module ActiveRecord
|
|
28
23
|
end
|
29
24
|
end
|
30
25
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
26
|
+
def delete(method = options[:dependent])
|
27
|
+
if load_target
|
28
|
+
case method
|
29
|
+
when :delete
|
30
|
+
target.delete
|
31
|
+
when :destroy
|
32
|
+
target.destroyed_by_association = reflection
|
33
|
+
target.destroy
|
34
|
+
throw(:abort) unless target.destroyed?
|
35
|
+
when :nullify
|
36
|
+
target.update_columns(nullified_owner_attributes) if target.persisted?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def replace(record, save = true)
|
43
|
+
raise_on_type_mismatch!(record) if record
|
34
44
|
|
35
|
-
|
45
|
+
return target unless load_target || record
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
47
|
+
assigning_another_record = target != record
|
48
|
+
if assigning_another_record || record.has_changes_to_save?
|
49
|
+
save &&= owner.persisted?
|
40
50
|
|
41
|
-
|
42
|
-
|
51
|
+
transaction_if(save) do
|
52
|
+
remove_target!(options[:dependent]) if target && !target.destroyed? && assigning_another_record
|
43
53
|
|
44
|
-
|
45
|
-
|
46
|
-
|
54
|
+
if record
|
55
|
+
set_owner_attributes(record)
|
56
|
+
set_inverse_instance(record)
|
47
57
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
58
|
+
if save && !record.save
|
59
|
+
nullify_owner_attributes(record)
|
60
|
+
set_owner_attributes(target) if target
|
61
|
+
raise RecordNotSaved, "Failed to save the new associated #{reflection.name}."
|
62
|
+
end
|
52
63
|
end
|
53
64
|
end
|
54
65
|
end
|
55
|
-
end
|
56
66
|
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
def delete(method = options[:dependent])
|
61
|
-
if load_target
|
62
|
-
case method
|
63
|
-
when :delete
|
64
|
-
target.delete
|
65
|
-
when :destroy
|
66
|
-
target.destroy
|
67
|
-
when :nullify
|
68
|
-
target.update_columns(reflection.foreign_key => nil) if target.persisted?
|
69
|
-
end
|
67
|
+
self.target = record
|
70
68
|
end
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
69
|
|
75
70
|
# The reason that the save param for replace is false, if for create (not just build),
|
76
71
|
# is because the setting of the foreign keys is actually handled by the scoping when
|
@@ -82,18 +77,20 @@ module ActiveRecord
|
|
82
77
|
|
83
78
|
def remove_target!(method)
|
84
79
|
case method
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
80
|
+
when :delete
|
81
|
+
target.delete
|
82
|
+
when :destroy
|
83
|
+
target.destroyed_by_association = reflection
|
84
|
+
target.destroy
|
85
|
+
else
|
86
|
+
nullify_owner_attributes(target)
|
87
|
+
remove_inverse_instance(target)
|
88
|
+
|
89
|
+
if target.persisted? && owner.persisted? && !target.save
|
90
|
+
set_owner_attributes(target)
|
91
|
+
raise RecordNotSaved, "Failed to remove the existing associated #{reflection.name}. " \
|
92
|
+
"The record failed to save after its foreign key was set to nil."
|
93
|
+
end
|
97
94
|
end
|
98
95
|
end
|
99
96
|
|
@@ -108,6 +105,14 @@ module ActiveRecord
|
|
108
105
|
yield
|
109
106
|
end
|
110
107
|
end
|
108
|
+
|
109
|
+
def _create_record(attributes, raise_error = false, &block)
|
110
|
+
unless owner.persisted?
|
111
|
+
raise ActiveRecord::RecordNotSaved, "You cannot call create unless the parent is saved"
|
112
|
+
end
|
113
|
+
|
114
|
+
super
|
115
|
+
end
|
111
116
|
end
|
112
117
|
end
|
113
118
|
end
|
@@ -1,30 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
|
-
# = Active Record Has One Through Association
|
3
4
|
module Associations
|
5
|
+
# = Active Record Has One Through Association
|
4
6
|
class HasOneThroughAssociation < HasOneAssociation #:nodoc:
|
5
7
|
include ThroughAssociation
|
6
8
|
|
7
|
-
def replace(record)
|
8
|
-
create_through_record(record)
|
9
|
-
self.target = record
|
10
|
-
end
|
11
|
-
|
12
9
|
private
|
10
|
+
def replace(record, save = true)
|
11
|
+
create_through_record(record, save)
|
12
|
+
self.target = record
|
13
|
+
end
|
13
14
|
|
14
|
-
def create_through_record(record)
|
15
|
+
def create_through_record(record, save)
|
15
16
|
ensure_not_nested
|
16
17
|
|
17
|
-
through_proxy =
|
18
|
-
through_record = through_proxy.
|
18
|
+
through_proxy = through_association
|
19
|
+
through_record = through_proxy.load_target
|
19
20
|
|
20
21
|
if through_record && !record
|
21
22
|
through_record.destroy
|
22
23
|
elsif record
|
23
24
|
attributes = construct_join_attributes(record)
|
24
25
|
|
26
|
+
if through_record && through_record.destroyed?
|
27
|
+
through_record = through_proxy.tap(&:reload).target
|
28
|
+
end
|
29
|
+
|
25
30
|
if through_record
|
26
|
-
through_record.
|
27
|
-
|
31
|
+
if through_record.new_record?
|
32
|
+
through_record.assign_attributes(attributes)
|
33
|
+
else
|
34
|
+
through_record.update(attributes)
|
35
|
+
end
|
36
|
+
elsif owner.new_record? || !save
|
28
37
|
through_proxy.build(attributes)
|
29
38
|
else
|
30
39
|
through_proxy.create(attributes)
|
@@ -1,19 +1,20 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_record/associations/join_dependency/join_part"
|
4
|
+
require "active_support/core_ext/array/extract"
|
2
5
|
|
3
6
|
module ActiveRecord
|
4
7
|
module Associations
|
5
8
|
class JoinDependency # :nodoc:
|
6
9
|
class JoinAssociation < JoinPart # :nodoc:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
attr_accessor :tables
|
10
|
+
attr_reader :reflection, :tables
|
11
|
+
attr_accessor :table
|
11
12
|
|
12
13
|
def initialize(reflection, children)
|
13
14
|
super(reflection.klass, children)
|
14
15
|
|
15
|
-
@reflection
|
16
|
-
@tables
|
16
|
+
@reflection = reflection
|
17
|
+
@tables = nil
|
17
18
|
end
|
18
19
|
|
19
20
|
def match?(other)
|
@@ -21,111 +22,58 @@ module ActiveRecord
|
|
21
22
|
super && reflection == other.reflection
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
def join_constraints(foreign_table, foreign_klass, node, join_type, tables, scope_chain, chain)
|
27
|
-
joins = []
|
28
|
-
binds = []
|
29
|
-
tables = tables.reverse
|
30
|
-
|
31
|
-
scope_chain_index = 0
|
32
|
-
scope_chain = scope_chain.reverse
|
25
|
+
def join_constraints(foreign_table, foreign_klass, join_type, alias_tracker)
|
26
|
+
joins = []
|
33
27
|
|
34
28
|
# The chain starts with the target table, but we want to end with it here (makes
|
35
29
|
# more sense in this context), so we reverse
|
36
|
-
chain.reverse_each do |reflection|
|
37
|
-
table = tables
|
30
|
+
reflection.chain.reverse_each.with_index(1) do |reflection, i|
|
31
|
+
table = tables[-i]
|
38
32
|
klass = reflection.klass
|
39
33
|
|
40
|
-
|
41
|
-
key = join_keys.key
|
42
|
-
foreign_key = join_keys.foreign_key
|
34
|
+
join_scope = reflection.join_scope(table, foreign_table, foreign_klass)
|
43
35
|
|
44
|
-
|
36
|
+
arel = join_scope.arel(alias_tracker.aliases)
|
37
|
+
nodes = arel.constraints.first
|
45
38
|
|
46
|
-
|
47
|
-
|
48
|
-
if item.is_a?(Relation)
|
49
|
-
item
|
50
|
-
else
|
51
|
-
ActiveRecord::Relation.create(klass, table, predicate_builder)
|
52
|
-
.instance_exec(node, &item)
|
53
|
-
end
|
39
|
+
others = nodes.children.extract! do |node|
|
40
|
+
!Arel.fetch_attribute(node) { |attr| attr.relation.name == table.name }
|
54
41
|
end
|
55
|
-
scope_chain_index += 1
|
56
|
-
|
57
|
-
relation = ActiveRecord::Relation.create(klass, table, predicate_builder)
|
58
|
-
current_scope = klass.current_scope
|
59
42
|
|
60
|
-
|
61
|
-
if current_scope && current_scope.empty_scope?
|
62
|
-
relation
|
63
|
-
else
|
64
|
-
klass.send(:build_default_scope, relation)
|
65
|
-
end
|
66
|
-
scope_chain_items.concat [klass_scope].compact
|
43
|
+
joins << table.create_join(table, table.create_on(nodes), join_type)
|
67
44
|
|
68
|
-
|
69
|
-
|
45
|
+
unless others.empty?
|
46
|
+
joins.concat arel.join_sources
|
47
|
+
append_constraints(joins.last, others)
|
70
48
|
end
|
71
49
|
|
72
|
-
if rel && !rel.arel.constraints.empty?
|
73
|
-
binds += rel.bound_attributes
|
74
|
-
constraint = constraint.and rel.arel.constraints
|
75
|
-
end
|
76
|
-
|
77
|
-
if reflection.type
|
78
|
-
value = foreign_klass.base_class.name
|
79
|
-
column = klass.columns_hash[reflection.type.to_s]
|
80
|
-
|
81
|
-
binds << Relation::QueryAttribute.new(column.name, value, klass.type_for_attribute(column.name))
|
82
|
-
constraint = constraint.and klass.arel_attribute(reflection.type, table).eq(Arel::Nodes::BindParam.new)
|
83
|
-
end
|
84
|
-
|
85
|
-
joins << table.create_join(table, table.create_on(constraint), join_type)
|
86
|
-
|
87
50
|
# The current table in this iteration becomes the foreign table in the next
|
88
51
|
foreign_table, foreign_klass = table, klass
|
89
52
|
end
|
90
53
|
|
91
|
-
|
54
|
+
joins
|
92
55
|
end
|
93
56
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
#
|
98
|
-
# class Physician < ActiveRecord::Base
|
99
|
-
# has_many :appointments
|
100
|
-
# end
|
101
|
-
#
|
102
|
-
# If I execute `Physician.joins(:appointments).to_a` then
|
103
|
-
# klass # => Physician
|
104
|
-
# table # => #<Arel::Table @name="appointments" ...>
|
105
|
-
# key # => physician_id
|
106
|
-
# foreign_table # => #<Arel::Table @name="physicians" ...>
|
107
|
-
# foreign_key # => id
|
108
|
-
#
|
109
|
-
def build_constraint(klass, table, key, foreign_table, foreign_key)
|
110
|
-
constraint = table[key].eq(foreign_table[foreign_key])
|
111
|
-
|
112
|
-
if klass.finder_needs_type_condition?
|
113
|
-
constraint = table.create_and([
|
114
|
-
constraint,
|
115
|
-
klass.send(:type_condition, table)
|
116
|
-
])
|
117
|
-
end
|
118
|
-
|
119
|
-
constraint
|
57
|
+
def tables=(tables)
|
58
|
+
@tables = tables
|
59
|
+
@table = tables.first
|
120
60
|
end
|
121
61
|
|
122
|
-
def
|
123
|
-
|
124
|
-
end
|
62
|
+
def readonly?
|
63
|
+
return @readonly if defined?(@readonly)
|
125
64
|
|
126
|
-
|
127
|
-
table.table_alias || table.name
|
65
|
+
@readonly = reflection.scope && reflection.scope_for(base_klass.unscoped).readonly_value
|
128
66
|
end
|
67
|
+
|
68
|
+
private
|
69
|
+
def append_constraints(join, constraints)
|
70
|
+
if join.is_a?(Arel::Nodes::StringJoin)
|
71
|
+
join_string = table.create_and(constraints.unshift(join.left))
|
72
|
+
join.left = Arel.sql(base_klass.connection.visitor.compile(join_string))
|
73
|
+
else
|
74
|
+
join.right.expr.children.concat(constraints)
|
75
|
+
end
|
76
|
+
end
|
129
77
|
end
|
130
78
|
end
|
131
79
|
end
|
@@ -1,20 +1,21 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_record/associations/join_dependency/join_part"
|
2
4
|
|
3
5
|
module ActiveRecord
|
4
6
|
module Associations
|
5
7
|
class JoinDependency # :nodoc:
|
6
8
|
class JoinBase < JoinPart # :nodoc:
|
7
|
-
|
8
|
-
return true if self == other
|
9
|
-
super && base_klass == other.base_klass
|
10
|
-
end
|
9
|
+
attr_reader :table
|
11
10
|
|
12
|
-
def table
|
13
|
-
base_klass
|
11
|
+
def initialize(base_klass, table, children)
|
12
|
+
super(base_klass, children)
|
13
|
+
@table = table
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
16
|
+
def match?(other)
|
17
|
+
return true if self == other
|
18
|
+
super && base_klass == other.base_klass
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module Associations
|
3
5
|
class JoinDependency # :nodoc:
|
@@ -15,17 +17,13 @@ module ActiveRecord
|
|
15
17
|
# association.
|
16
18
|
attr_reader :base_klass, :children
|
17
19
|
|
18
|
-
delegate :table_name, :column_names, :primary_key, :
|
20
|
+
delegate :table_name, :column_names, :primary_key, to: :base_klass
|
19
21
|
|
20
22
|
def initialize(base_klass, children)
|
21
23
|
@base_klass = base_klass
|
22
24
|
@children = children
|
23
25
|
end
|
24
26
|
|
25
|
-
def name
|
26
|
-
reflection.name
|
27
|
-
end
|
28
|
-
|
29
27
|
def match?(other)
|
30
28
|
self.class == other.class
|
31
29
|
end
|
@@ -35,13 +33,15 @@ module ActiveRecord
|
|
35
33
|
children.each { |child| child.each(&block) }
|
36
34
|
end
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
def each_children(&block)
|
37
|
+
children.each do |child|
|
38
|
+
yield self, child
|
39
|
+
child.each_children(&block)
|
40
|
+
end
|
41
41
|
end
|
42
42
|
|
43
|
-
#
|
44
|
-
def
|
43
|
+
# An Arel::Table for the active_record
|
44
|
+
def table
|
45
45
|
raise NotImplementedError
|
46
46
|
end
|
47
47
|
|
@@ -54,8 +54,8 @@ module ActiveRecord
|
|
54
54
|
length = column_names_with_alias.length
|
55
55
|
|
56
56
|
while index < length
|
57
|
-
|
58
|
-
hash[
|
57
|
+
column = column_names_with_alias[index]
|
58
|
+
hash[column.name] = row[column.alias]
|
59
59
|
index += 1
|
60
60
|
end
|
61
61
|
|