activerecord-nuodb-adapter 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/.travis.yml +26 -2
- data/{CONTRIBUTION.rdoc → CONTRIBUTION.md} +16 -15
- data/Gemfile +1 -1
- data/README.md +48 -0
- data/active_setup_linux.sh +97 -0
- data/activerecord-nuodb-adapter.gemspec +1 -1
- data/lib/active_record/connection_adapters/nuodb/version.rb +1 -1
- data/lib/active_record/connection_adapters/nuodb_adapter.rb +45 -9
- data/test/.DS_Store +0 -0
- data/test/.gitignore +1 -0
- data/test/active_record/connection_adapters/fake_adapter.rb +45 -0
- data/test/ar_schema_test.rb +70 -0
- data/test/assets/example.log +1 -0
- data/test/assets/flowers.jpg +0 -0
- data/test/assets/test.txt +1 -0
- data/test/base_test.rb +1481 -0
- data/test/cases/.DS_Store +0 -0
- data/test/cases/adapter_test.rb +211 -0
- data/test/cases/adapters/firebird/connection_test.rb +8 -0
- data/test/cases/adapters/firebird/default_test.rb +16 -0
- data/test/cases/adapters/firebird/migration_test.rb +124 -0
- data/test/cases/adapters/mysql/active_schema_test.rb +143 -0
- data/test/cases/adapters/mysql/case_sensitivity_test.rb +35 -0
- data/test/cases/adapters/mysql/connection_test.rb +172 -0
- data/test/cases/adapters/mysql/enum_test.rb +10 -0
- data/test/cases/adapters/mysql/mysql_adapter_test.rb +125 -0
- data/test/cases/adapters/mysql/quoting_test.rb +25 -0
- data/test/cases/adapters/mysql/reserved_word_test.rb +153 -0
- data/test/cases/adapters/mysql/schema_test.rb +62 -0
- data/test/cases/adapters/mysql/sp_test.rb +15 -0
- data/test/cases/adapters/mysql/sql_types_test.rb +14 -0
- data/test/cases/adapters/mysql/statement_pool_test.rb +23 -0
- data/test/cases/adapters/mysql2/active_schema_test.rb +143 -0
- data/test/cases/adapters/mysql2/bind_parameter_test.rb +50 -0
- data/test/cases/adapters/mysql2/case_sensitivity_test.rb +35 -0
- data/test/cases/adapters/mysql2/connection_test.rb +97 -0
- data/test/cases/adapters/mysql2/enum_test.rb +10 -0
- data/test/cases/adapters/mysql2/explain_test.rb +26 -0
- data/test/cases/adapters/mysql2/reserved_word_test.rb +152 -0
- data/test/cases/adapters/mysql2/schema_migrations_test.rb +26 -0
- data/test/cases/adapters/mysql2/schema_test.rb +70 -0
- data/test/cases/adapters/mysql2/sql_types_test.rb +14 -0
- data/test/cases/adapters/oracle/synonym_test.rb +17 -0
- data/test/cases/adapters/postgresql/active_schema_test.rb +58 -0
- data/test/cases/adapters/postgresql/array_test.rb +104 -0
- data/test/cases/adapters/postgresql/bytea_test.rb +104 -0
- data/test/cases/adapters/postgresql/connection_test.rb +163 -0
- data/test/cases/adapters/postgresql/datatype_test.rb +604 -0
- data/test/cases/adapters/postgresql/explain_test.rb +28 -0
- data/test/cases/adapters/postgresql/hstore_test.rb +200 -0
- data/test/cases/adapters/postgresql/json_test.rb +99 -0
- data/test/cases/adapters/postgresql/ltree_test.rb +41 -0
- data/test/cases/adapters/postgresql/postgresql_adapter_test.rb +288 -0
- data/test/cases/adapters/postgresql/quoting_test.rb +58 -0
- data/test/cases/adapters/postgresql/schema_authorization_test.rb +114 -0
- data/test/cases/adapters/postgresql/schema_test.rb +376 -0
- data/test/cases/adapters/postgresql/sql_types_test.rb +18 -0
- data/test/cases/adapters/postgresql/statement_pool_test.rb +39 -0
- data/test/cases/adapters/postgresql/timestamp_test.rb +113 -0
- data/test/cases/adapters/postgresql/utils_test.rb +20 -0
- data/test/cases/adapters/postgresql/uuid_test.rb +95 -0
- data/test/cases/adapters/postgresql/view_test.rb +49 -0
- data/test/cases/adapters/sqlite3/copy_table_test.rb +99 -0
- data/test/cases/adapters/sqlite3/explain_test.rb +26 -0
- data/test/cases/adapters/sqlite3/quoting_test.rb +102 -0
- data/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +366 -0
- data/test/cases/adapters/sqlite3/statement_pool_test.rb +24 -0
- data/test/cases/aggregations_test.rb +158 -0
- data/test/cases/ar_schema_test.rb +70 -0
- data/test/cases/associations/association_scope_test.rb +15 -0
- data/test/cases/associations/belongs_to_associations_test.rb +831 -0
- data/test/cases/associations/callbacks_test.rb +168 -0
- data/test/cases/associations/cascaded_eager_loading_test.rb +179 -0
- data/test/cases/associations/eager_load_includes_full_sti_class_test.rb +36 -0
- data/test/cases/associations/eager_load_nested_include_test.rb +128 -0
- data/test/cases/associations/eager_singularization_test.rb +145 -0
- data/test/cases/associations/eager_test.rb +1179 -0
- data/test/cases/associations/extension_test.rb +80 -0
- data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +779 -0
- data/test/cases/associations/has_many_associations_test.rb +1699 -0
- data/test/cases/associations/has_many_through_associations_test.rb +950 -0
- data/test/cases/associations/has_one_associations_test.rb +525 -0
- data/test/cases/associations/has_one_through_associations_test.rb +317 -0
- data/test/cases/associations/inner_join_association_test.rb +115 -0
- data/test/cases/associations/inverse_associations_test.rb +631 -0
- data/test/cases/associations/join_dependency_test.rb +8 -0
- data/test/cases/associations/join_model_test.rb +750 -0
- data/test/cases/associations/nested_through_associations_test.rb +575 -0
- data/test/cases/associations_test.rb +344 -0
- data/test/cases/attribute_methods/read_test.rb +58 -0
- data/test/cases/attribute_methods/serialization_test.rb +29 -0
- data/test/cases/attribute_methods_test.rb +819 -0
- data/test/cases/autosave_association_test.rb +1447 -0
- data/test/cases/base_test.rb +1481 -0
- data/test/cases/batches_test.rb +173 -0
- data/test/cases/binary_test.rb +49 -0
- data/test/cases/bind_parameter_test.rb +89 -0
- data/test/cases/calculations_test.rb +589 -0
- data/test/cases/callbacks_test.rb +535 -0
- data/test/cases/clone_test.rb +40 -0
- data/test/cases/coders/yaml_column_test.rb +63 -0
- data/test/cases/column_alias_test.rb +17 -0
- data/test/cases/column_definition_test.rb +143 -0
- data/test/cases/column_test.rb +115 -0
- data/test/cases/connection_adapters/abstract_adapter_test.rb +62 -0
- data/test/cases/connection_adapters/connection_handler_test.rb +53 -0
- data/test/cases/connection_adapters/connection_specification_test.rb +12 -0
- data/test/cases/connection_adapters/quoting_test.rb +13 -0
- data/test/cases/connection_adapters/schema_cache_test.rb +56 -0
- data/test/cases/connection_management_test.rb +112 -0
- data/test/cases/connection_pool_test.rb +344 -0
- data/test/cases/connection_specification/resolver_test.rb +63 -0
- data/test/cases/core_test.rb +33 -0
- data/test/cases/counter_cache_test.rb +163 -0
- data/test/cases/custom_locking_test.rb +17 -0
- data/test/cases/database_statements_test.rb +19 -0
- data/test/cases/date_time_test.rb +43 -0
- data/test/cases/defaults_test.rb +214 -0
- data/test/cases/dirty_test.rb +626 -0
- data/test/cases/disconnected_test.rb +27 -0
- data/test/cases/dup_test.rb +136 -0
- data/test/cases/explain_subscriber_test.rb +59 -0
- data/test/cases/explain_test.rb +72 -0
- data/test/cases/finder_respond_to_test.rb +50 -0
- data/test/cases/finder_test.rb +886 -0
- data/test/cases/fixture_set/file_test.rb +83 -0
- data/test/cases/fixtures_test.rb +808 -0
- data/test/cases/forbidden_attributes_protection_test.rb +64 -0
- data/test/cases/habtm_destroy_order_test.rb +61 -0
- data/test/cases/helper.rb +151 -0
- data/test/cases/hot_compatibility_test.rb +54 -0
- data/test/cases/i18n_test.rb +45 -0
- data/test/cases/inheritance_test.rb +355 -0
- data/test/cases/integration_test.rb +87 -0
- data/test/cases/invalid_connection_test.rb +22 -0
- data/test/cases/invalid_date_test.rb +32 -0
- data/test/cases/invertible_migration_test.rb +259 -0
- data/test/cases/json_serialization_test.rb +300 -0
- data/test/cases/locking_test.rb +453 -0
- data/test/cases/log_subscriber_test.rb +129 -0
- data/test/cases/migration/change_schema_test.rb +379 -0
- data/test/cases/migration/change_table_test.rb +204 -0
- data/test/cases/migration/column_attributes_test.rb +186 -0
- data/test/cases/migration/column_positioning_test.rb +60 -0
- data/test/cases/migration/columns_test.rb +279 -0
- data/test/cases/migration/command_recorder_test.rb +247 -0
- data/test/cases/migration/create_join_table_test.rb +125 -0
- data/test/cases/migration/helper.rb +43 -0
- data/test/cases/migration/index_test.rb +209 -0
- data/test/cases/migration/logger_test.rb +37 -0
- data/test/cases/migration/references_index_test.rb +102 -0
- data/test/cases/migration/references_statements_test.rb +111 -0
- data/test/cases/migration/rename_table_test.rb +90 -0
- data/test/cases/migration/table_and_index_test.rb +24 -0
- data/test/cases/migration_test.rb +861 -0
- data/test/cases/migrator_test.rb +378 -0
- data/test/cases/mixin_test.rb +96 -0
- data/test/cases/modules_test.rb +143 -0
- data/test/cases/multiparameter_attributes_test.rb +350 -0
- data/test/cases/multiple_db_test.rb +108 -0
- data/test/cases/nested_attributes_test.rb +1056 -0
- data/test/cases/persistence_test.rb +802 -0
- data/test/cases/pooled_connections_test.rb +51 -0
- data/test/cases/primary_keys_test.rb +218 -0
- data/test/cases/query_cache_test.rb +276 -0
- data/test/cases/quoting_test.rb +229 -0
- data/test/cases/readonly_test.rb +111 -0
- data/test/cases/reaper_test.rb +81 -0
- data/test/cases/reflection_test.rb +386 -0
- data/test/cases/relation/where_chain_test.rb +80 -0
- data/test/cases/relation/where_test.rb +120 -0
- data/test/cases/relation_test.rb +315 -0
- data/test/cases/relations_test.rb +1559 -0
- data/test/cases/reload_models_test.rb +22 -0
- data/test/cases/result_test.rb +32 -0
- data/test/cases/sanitize_test.rb +34 -0
- data/test/cases/schema_dumper_test.rb +391 -0
- data/test/cases/scoping/default_scoping_test.rb +374 -0
- data/test/cases/scoping/named_scoping_test.rb +451 -0
- data/test/cases/scoping/relation_scoping_test.rb +331 -0
- data/test/cases/serialization_test.rb +68 -0
- data/test/cases/serialized_attribute_test.rb +252 -0
- data/test/cases/statement_cache_test.rb +64 -0
- data/test/cases/store_test.rb +153 -0
- data/test/cases/tasks/database_tasks_test.rb +315 -0
- data/test/cases/tasks/mysql_rake_test.rb +301 -0
- data/test/cases/tasks/postgresql_rake_test.rb +236 -0
- data/test/cases/tasks/sqlite_rake_test.rb +191 -0
- data/test/cases/test_case.rb +95 -0
- data/test/cases/test_simple.rb +194 -0
- data/test/cases/timestamp_test.rb +308 -0
- data/test/cases/transaction_callbacks_test.rb +317 -0
- data/test/cases/transaction_isolation_test.rb +114 -0
- data/test/cases/transactions_test.rb +595 -0
- data/test/cases/unconnected_test.rb +33 -0
- data/test/cases/validations/association_validation_test.rb +121 -0
- data/test/cases/validations/i18n_generate_message_validation_test.rb +76 -0
- data/test/cases/validations/i18n_validation_test.rb +89 -0
- data/test/cases/validations/presence_validation_test.rb +51 -0
- data/test/cases/validations/uniqueness_validation_test.rb +379 -0
- data/test/cases/validations_repair_helper.rb +23 -0
- data/test/cases/validations_test.rb +124 -0
- data/test/cases/xml_serialization_test.rb +455 -0
- data/test/cases/yaml_serialization_test.rb +52 -0
- data/test/config.example.yml +154 -0
- data/test/config.rb +5 -0
- data/test/database_statements_test.rb +19 -0
- data/test/fixtures/.gitignore +1 -0
- data/test/fixtures/accounts.yml +29 -0
- data/test/fixtures/admin/accounts.yml +2 -0
- data/test/fixtures/admin/randomly_named_a9.yml +7 -0
- data/test/fixtures/admin/randomly_named_b0.yml +7 -0
- data/test/fixtures/admin/users.yml +10 -0
- data/test/fixtures/all/developers.yml +0 -0
- data/test/fixtures/all/people.yml +0 -0
- data/test/fixtures/all/tasks.yml +0 -0
- data/test/fixtures/author_addresses.yml +5 -0
- data/test/fixtures/author_favorites.yml +4 -0
- data/test/fixtures/authors.yml +15 -0
- data/test/fixtures/binaries.yml +133 -0
- data/test/fixtures/books.yml +9 -0
- data/test/fixtures/cars.yml +9 -0
- data/test/fixtures/categories.yml +19 -0
- data/test/fixtures/categories/special_categories.yml +9 -0
- data/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
- data/test/fixtures/categories_ordered.yml +7 -0
- data/test/fixtures/categories_posts.yml +31 -0
- data/test/fixtures/categorizations.yml +23 -0
- data/test/fixtures/clubs.yml +8 -0
- data/test/fixtures/collections.yml +3 -0
- data/test/fixtures/colleges.yml +3 -0
- data/test/fixtures/comments.yml +65 -0
- data/test/fixtures/companies.yml +59 -0
- data/test/fixtures/computers.yml +4 -0
- data/test/fixtures/courses.yml +8 -0
- data/test/fixtures/customers.yml +26 -0
- data/test/fixtures/dashboards.yml +6 -0
- data/test/fixtures/developers.yml +21 -0
- data/test/fixtures/developers_projects.yml +17 -0
- data/test/fixtures/dog_lovers.yml +7 -0
- data/test/fixtures/dogs.yml +4 -0
- data/test/fixtures/edges.yml +5 -0
- data/test/fixtures/entrants.yml +14 -0
- data/test/fixtures/essays.yml +6 -0
- data/test/fixtures/faces.yml +11 -0
- data/test/fixtures/fk_test_has_fk.yml +3 -0
- data/test/fixtures/fk_test_has_pk.yml +2 -0
- data/test/fixtures/friendships.yml +4 -0
- data/test/fixtures/funny_jokes.yml +10 -0
- data/test/fixtures/interests.yml +33 -0
- data/test/fixtures/items.yml +3 -0
- data/test/fixtures/jobs.yml +7 -0
- data/test/fixtures/legacy_things.yml +3 -0
- data/test/fixtures/mateys.yml +4 -0
- data/test/fixtures/member_details.yml +8 -0
- data/test/fixtures/member_types.yml +6 -0
- data/test/fixtures/members.yml +11 -0
- data/test/fixtures/memberships.yml +34 -0
- data/test/fixtures/men.yml +5 -0
- data/test/fixtures/minimalistics.yml +2 -0
- data/test/fixtures/minivans.yml +5 -0
- data/test/fixtures/mixed_case_monkeys.yml +6 -0
- data/test/fixtures/mixins.yml +29 -0
- data/test/fixtures/movies.yml +7 -0
- data/test/fixtures/naked/csv/accounts.csv +1 -0
- data/test/fixtures/naked/yml/accounts.yml +1 -0
- data/test/fixtures/naked/yml/companies.yml +1 -0
- data/test/fixtures/naked/yml/courses.yml +1 -0
- data/test/fixtures/organizations.yml +5 -0
- data/test/fixtures/other_topics.yml +42 -0
- data/test/fixtures/owners.yml +8 -0
- data/test/fixtures/parrots.yml +27 -0
- data/test/fixtures/parrots_pirates.yml +7 -0
- data/test/fixtures/people.yml +24 -0
- data/test/fixtures/peoples_treasures.yml +3 -0
- data/test/fixtures/pets.yml +19 -0
- data/test/fixtures/pirates.yml +9 -0
- data/test/fixtures/posts.yml +82 -0
- data/test/fixtures/price_estimates.yml +7 -0
- data/test/fixtures/products.yml +4 -0
- data/test/fixtures/projects.yml +7 -0
- data/test/fixtures/randomly_named_a9.yml +7 -0
- data/test/fixtures/ratings.yml +14 -0
- data/test/fixtures/readers.yml +11 -0
- data/test/fixtures/references.yml +17 -0
- data/test/fixtures/reserved_words/distinct.yml +5 -0
- data/test/fixtures/reserved_words/distinct_select.yml +11 -0
- data/test/fixtures/reserved_words/group.yml +14 -0
- data/test/fixtures/reserved_words/select.yml +8 -0
- data/test/fixtures/reserved_words/values.yml +7 -0
- data/test/fixtures/ships.yml +6 -0
- data/test/fixtures/speedometers.yml +8 -0
- data/test/fixtures/sponsors.yml +12 -0
- data/test/fixtures/string_key_objects.yml +7 -0
- data/test/fixtures/subscribers.yml +11 -0
- data/test/fixtures/subscriptions.yml +12 -0
- data/test/fixtures/taggings.yml +78 -0
- data/test/fixtures/tags.yml +11 -0
- data/test/fixtures/tasks.yml +7 -0
- data/test/fixtures/teapots.yml +3 -0
- data/test/fixtures/topics.yml +42 -0
- data/test/fixtures/toys.yml +14 -0
- data/test/fixtures/traffic_lights.yml +10 -0
- data/test/fixtures/treasures.yml +10 -0
- data/test/fixtures/variants.yml +4 -0
- data/test/fixtures/vegetables.yml +20 -0
- data/test/fixtures/vertices.yml +4 -0
- data/test/fixtures/warehouse-things.yml +3 -0
- data/test/fixtures/zines.yml +5 -0
- data/test/migration_test.rb +861 -0
- data/test/migrations/10_urban/9_add_expressions.rb +11 -0
- data/test/migrations/decimal/1_give_me_big_numbers.rb +15 -0
- data/test/migrations/empty/.gitkeep +0 -0
- data/test/migrations/magic/1_currencies_have_symbols.rb +12 -0
- data/test/migrations/missing/1000_people_have_middle_names.rb +9 -0
- data/test/migrations/missing/1_people_have_last_names.rb +9 -0
- data/test/migrations/missing/3_we_need_reminders.rb +12 -0
- data/test/migrations/missing/4_innocent_jointable.rb +12 -0
- data/test/migrations/rename/1_we_need_things.rb +11 -0
- data/test/migrations/rename/2_rename_things.rb +9 -0
- data/test/migrations/to_copy/1_people_have_hobbies.rb +9 -0
- data/test/migrations/to_copy/2_people_have_descriptions.rb +9 -0
- data/test/migrations/to_copy2/1_create_articles.rb +7 -0
- data/test/migrations/to_copy2/2_create_comments.rb +7 -0
- data/test/migrations/to_copy_with_name_collision/1_people_have_hobbies.rb +9 -0
- data/test/migrations/to_copy_with_timestamps/20090101010101_people_have_hobbies.rb +9 -0
- data/test/migrations/to_copy_with_timestamps/20090101010202_people_have_descriptions.rb +9 -0
- data/test/migrations/to_copy_with_timestamps2/20090101010101_create_articles.rb +7 -0
- data/test/migrations/to_copy_with_timestamps2/20090101010202_create_comments.rb +7 -0
- data/test/migrations/valid/1_valid_people_have_last_names.rb +9 -0
- data/test/migrations/valid/2_we_need_reminders.rb +12 -0
- data/test/migrations/valid/3_innocent_jointable.rb +12 -0
- data/test/migrations/valid_with_subdirectories/1_valid_people_have_last_names.rb +9 -0
- data/test/migrations/valid_with_subdirectories/sub/2_we_need_reminders.rb +12 -0
- data/test/migrations/valid_with_subdirectories/sub1/3_innocent_jointable.rb +12 -0
- data/test/migrations/valid_with_timestamps/20100101010101_valid_with_timestamps_people_have_last_names.rb +9 -0
- data/test/migrations/valid_with_timestamps/20100201010101_valid_with_timestamps_we_need_reminders.rb +12 -0
- data/test/migrations/valid_with_timestamps/20100301010101_valid_with_timestamps_innocent_jointable.rb +12 -0
- data/test/models/admin.rb +5 -0
- data/test/models/admin/account.rb +3 -0
- data/test/models/admin/randomly_named_c1.rb +3 -0
- data/test/models/admin/user.rb +39 -0
- data/test/models/aircraft.rb +4 -0
- data/test/models/arunit2_model.rb +3 -0
- data/test/models/author.rb +196 -0
- data/test/models/auto_id.rb +4 -0
- data/test/models/autoloadable/extra_firm.rb +2 -0
- data/test/models/binary.rb +2 -0
- data/test/models/bird.rb +12 -0
- data/test/models/book.rb +9 -0
- data/test/models/boolean.rb +2 -0
- data/test/models/bulb.rb +45 -0
- data/test/models/car.rb +28 -0
- data/test/models/categorization.rb +19 -0
- data/test/models/category.rb +34 -0
- data/test/models/citation.rb +6 -0
- data/test/models/club.rb +15 -0
- data/test/models/college.rb +5 -0
- data/test/models/column_name.rb +3 -0
- data/test/models/comment.rb +38 -0
- data/test/models/company.rb +214 -0
- data/test/models/company_in_module.rb +80 -0
- data/test/models/computer.rb +3 -0
- data/test/models/contact.rb +40 -0
- data/test/models/contract.rb +19 -0
- data/test/models/country.rb +7 -0
- data/test/models/course.rb +6 -0
- data/test/models/customer.rb +77 -0
- data/test/models/dashboard.rb +3 -0
- data/test/models/default.rb +2 -0
- data/test/models/developer.rb +250 -0
- data/test/models/dog.rb +5 -0
- data/test/models/dog_lover.rb +5 -0
- data/test/models/edge.rb +5 -0
- data/test/models/electron.rb +3 -0
- data/test/models/engine.rb +4 -0
- data/test/models/entrant.rb +3 -0
- data/test/models/essay.rb +5 -0
- data/test/models/event.rb +3 -0
- data/test/models/eye.rb +37 -0
- data/test/models/face.rb +7 -0
- data/test/models/friendship.rb +6 -0
- data/test/models/guid.rb +2 -0
- data/test/models/interest.rb +5 -0
- data/test/models/invoice.rb +4 -0
- data/test/models/item.rb +7 -0
- data/test/models/job.rb +7 -0
- data/test/models/joke.rb +7 -0
- data/test/models/keyboard.rb +3 -0
- data/test/models/legacy_thing.rb +3 -0
- data/test/models/lesson.rb +11 -0
- data/test/models/line_item.rb +3 -0
- data/test/models/liquid.rb +4 -0
- data/test/models/man.rb +9 -0
- data/test/models/matey.rb +4 -0
- data/test/models/member.rb +36 -0
- data/test/models/member_detail.rb +7 -0
- data/test/models/member_type.rb +3 -0
- data/test/models/membership.rb +15 -0
- data/test/models/minimalistic.rb +2 -0
- data/test/models/minivan.rb +9 -0
- data/test/models/mixed_case_monkey.rb +3 -0
- data/test/models/molecule.rb +4 -0
- data/test/models/movie.rb +5 -0
- data/test/models/order.rb +4 -0
- data/test/models/organization.rb +12 -0
- data/test/models/owner.rb +5 -0
- data/test/models/parrot.rb +29 -0
- data/test/models/person.rb +128 -0
- data/test/models/pet.rb +15 -0
- data/test/models/pirate.rb +86 -0
- data/test/models/possession.rb +3 -0
- data/test/models/post.rb +194 -0
- data/test/models/price_estimate.rb +4 -0
- data/test/models/project.rb +30 -0
- data/test/models/randomly_named_c1.rb +3 -0
- data/test/models/rating.rb +4 -0
- data/test/models/reader.rb +21 -0
- data/test/models/reference.rb +22 -0
- data/test/models/reply.rb +61 -0
- data/test/models/ship.rb +19 -0
- data/test/models/ship_part.rb +7 -0
- data/test/models/shop.rb +12 -0
- data/test/models/speedometer.rb +6 -0
- data/test/models/sponsor.rb +7 -0
- data/test/models/string_key_object.rb +3 -0
- data/test/models/student.rb +3 -0
- data/test/models/subject.rb +16 -0
- data/test/models/subscriber.rb +8 -0
- data/test/models/subscription.rb +4 -0
- data/test/models/tag.rb +7 -0
- data/test/models/tagging.rb +13 -0
- data/test/models/task.rb +5 -0
- data/test/models/topic.rb +121 -0
- data/test/models/toy.rb +6 -0
- data/test/models/traffic_light.rb +4 -0
- data/test/models/treasure.rb +11 -0
- data/test/models/treaty.rb +7 -0
- data/test/models/tyre.rb +3 -0
- data/test/models/vegetables.rb +24 -0
- data/test/models/vertex.rb +9 -0
- data/test/models/warehouse_thing.rb +5 -0
- data/test/models/wheel.rb +3 -0
- data/test/models/without_table.rb +3 -0
- data/test/models/zine.rb +3 -0
- data/test/schema/mysql2_specific_schema.rb +58 -0
- data/test/schema/mysql_specific_schema.rb +70 -0
- data/test/schema/oracle_specific_schema.rb +46 -0
- data/test/schema/postgresql_specific_schema.rb +224 -0
- data/test/schema/schema.rb +809 -0
- data/test/schema/sqlite_specific_schema.rb +25 -0
- data/test/support/config.rb +43 -0
- data/test/support/connection.rb +21 -0
- metadata +898 -6
- data/README.rdoc +0 -42
@@ -0,0 +1,22 @@
|
|
1
|
+
require "cases/helper"
|
2
|
+
require 'models/owner'
|
3
|
+
require 'models/pet'
|
4
|
+
|
5
|
+
class ReloadModelsTest < ActiveRecord::TestCase
|
6
|
+
fixtures :pets
|
7
|
+
|
8
|
+
def test_has_one_with_reload
|
9
|
+
pet = Pet.find_by_name('parrot')
|
10
|
+
pet.owner = Owner.find_by_name('ashley')
|
11
|
+
|
12
|
+
# Reload the class Owner, simulating auto-reloading of model classes in a
|
13
|
+
# development environment. Note that meanwhile the class Pet is not
|
14
|
+
# reloaded, simulating a class that is present in a plugin.
|
15
|
+
Object.class_eval { remove_const :Owner }
|
16
|
+
Kernel.load(File.expand_path(File.join(File.dirname(__FILE__), "../models/owner.rb")))
|
17
|
+
|
18
|
+
pet = Pet.find_by_name('parrot')
|
19
|
+
pet.owner = Owner.find_by_name('ashley')
|
20
|
+
assert_equal pet.owner, Owner.find_by_name('ashley')
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "cases/helper"
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
class ResultTest < ActiveRecord::TestCase
|
5
|
+
def result
|
6
|
+
Result.new(['col_1', 'col_2'], [
|
7
|
+
['row 1 col 1', 'row 1 col 2'],
|
8
|
+
['row 2 col 1', 'row 2 col 2']
|
9
|
+
])
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_to_hash_returns_row_hashes
|
13
|
+
assert_equal [
|
14
|
+
{'col_1' => 'row 1 col 1', 'col_2' => 'row 1 col 2'},
|
15
|
+
{'col_1' => 'row 2 col 1', 'col_2' => 'row 2 col 2'}
|
16
|
+
], result.to_hash
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_each_with_block_returns_row_hashes
|
20
|
+
result.each do |row|
|
21
|
+
assert_equal ['col_1', 'col_2'], row.keys
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_each_without_block_returns_an_enumerator
|
26
|
+
result.each.with_index do |row, index|
|
27
|
+
assert_equal ['col_1', 'col_2'], row.keys
|
28
|
+
assert_kind_of Integer, index
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "cases/helper"
|
2
|
+
require 'models/binary'
|
3
|
+
|
4
|
+
class SanitizeTest < ActiveRecord::TestCase
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_sanitize_sql_hash_handles_associations
|
9
|
+
quoted_bambi = ActiveRecord::Base.connection.quote("Bambi")
|
10
|
+
quoted_column_name = ActiveRecord::Base.connection.quote_column_name("name")
|
11
|
+
quoted_table_name = ActiveRecord::Base.connection.quote_table_name("adorable_animals")
|
12
|
+
expected_value = "#{quoted_table_name}.#{quoted_column_name} = #{quoted_bambi}"
|
13
|
+
|
14
|
+
assert_equal expected_value, Binary.send(:sanitize_sql_hash, {adorable_animals: {name: 'Bambi'}})
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_sanitize_sql_array_handles_string_interpolation
|
18
|
+
quoted_bambi = ActiveRecord::Base.connection.quote_string("Bambi")
|
19
|
+
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi"])
|
20
|
+
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi".mb_chars])
|
21
|
+
quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote_string("Bambi\nand\nThumper")
|
22
|
+
assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper"])
|
23
|
+
assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper".mb_chars])
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_sanitize_sql_array_handles_bind_variables
|
27
|
+
quoted_bambi = ActiveRecord::Base.connection.quote("Bambi")
|
28
|
+
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi"])
|
29
|
+
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi".mb_chars])
|
30
|
+
quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote("Bambi\nand\nThumper")
|
31
|
+
assert_equal "name=#{quoted_bambi_and_thumper}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi\nand\nThumper"])
|
32
|
+
assert_equal "name=#{quoted_bambi_and_thumper}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi\nand\nThumper".mb_chars])
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,391 @@
|
|
1
|
+
require "cases/helper"
|
2
|
+
|
3
|
+
class SchemaDumperTest < ActiveRecord::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
ActiveRecord::SchemaMigration.create_table
|
7
|
+
@stream = StringIO.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def standard_dump
|
11
|
+
@stream = StringIO.new
|
12
|
+
ActiveRecord::SchemaDumper.ignore_tables = []
|
13
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, @stream)
|
14
|
+
@stream.string
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_dump_schema_information_outputs_lexically_ordered_versions
|
18
|
+
versions = %w{ 20100101010101 20100201010101 20100301010101 }
|
19
|
+
versions.reverse.each do |v|
|
20
|
+
ActiveRecord::SchemaMigration.create!(:version => v)
|
21
|
+
end
|
22
|
+
|
23
|
+
schema_info = ActiveRecord::Base.connection.dump_schema_information
|
24
|
+
assert_match(/20100201010101.*20100301010101/m, schema_info)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_magic_comment
|
28
|
+
assert_match "# encoding: #{@stream.external_encoding.name}", standard_dump
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_schema_dump
|
32
|
+
output = standard_dump
|
33
|
+
assert_match %r{create_table "accounts"}, output
|
34
|
+
assert_match %r{create_table "authors"}, output
|
35
|
+
assert_no_match %r{create_table "schema_migrations"}, output
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_schema_dump_excludes_sqlite_sequence
|
39
|
+
output = standard_dump
|
40
|
+
assert_no_match %r{create_table "sqlite_sequence"}, output
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_schema_dump_includes_camelcase_table_name
|
44
|
+
output = standard_dump
|
45
|
+
assert_match %r{create_table "CamelCase"}, output
|
46
|
+
end
|
47
|
+
|
48
|
+
def assert_line_up(lines, pattern, required = false)
|
49
|
+
return assert(true) if lines.empty?
|
50
|
+
matches = lines.map { |line| line.match(pattern) }
|
51
|
+
assert matches.all? if required
|
52
|
+
matches.compact!
|
53
|
+
return assert(true) if matches.empty?
|
54
|
+
assert_equal 1, matches.map{ |match| match.offset(0).first }.uniq.length
|
55
|
+
end
|
56
|
+
|
57
|
+
def column_definition_lines(output = standard_dump)
|
58
|
+
output.scan(/^( *)create_table.*?\n(.*?)^\1end/m).map{ |m| m.last.split(/\n/) }
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_types_line_up
|
62
|
+
column_definition_lines.each do |column_set|
|
63
|
+
next if column_set.empty?
|
64
|
+
|
65
|
+
lengths = column_set.map do |column|
|
66
|
+
if match = column.match(/t\.(?:integer|decimal|float|datetime|timestamp|time|date|text|binary|string|boolean)\s+"/)
|
67
|
+
match[0].length
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
assert_equal 1, lengths.uniq.length
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_arguments_line_up
|
76
|
+
column_definition_lines.each do |column_set|
|
77
|
+
assert_line_up(column_set, /default: /)
|
78
|
+
assert_line_up(column_set, /limit: /)
|
79
|
+
assert_line_up(column_set, /null: /)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_no_dump_errors
|
84
|
+
output = standard_dump
|
85
|
+
assert_no_match %r{\# Could not dump table}, output
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_schema_dump_includes_not_null_columns
|
89
|
+
stream = StringIO.new
|
90
|
+
|
91
|
+
ActiveRecord::SchemaDumper.ignore_tables = [/^[^r]/]
|
92
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
|
93
|
+
output = stream.string
|
94
|
+
assert_match %r{null: false}, output
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_schema_dump_includes_limit_constraint_for_integer_columns
|
98
|
+
stream = StringIO.new
|
99
|
+
|
100
|
+
ActiveRecord::SchemaDumper.ignore_tables = [/^(?!integer_limits)/]
|
101
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
|
102
|
+
output = stream.string
|
103
|
+
|
104
|
+
if current_adapter?(:PostgreSQLAdapter)
|
105
|
+
assert_match %r{c_int_1.*limit: 2}, output
|
106
|
+
assert_match %r{c_int_2.*limit: 2}, output
|
107
|
+
|
108
|
+
# int 3 is 4 bytes in postgresql
|
109
|
+
assert_match %r{c_int_3.*}, output
|
110
|
+
assert_no_match %r{c_int_3.*limit:}, output
|
111
|
+
|
112
|
+
assert_match %r{c_int_4.*}, output
|
113
|
+
assert_no_match %r{c_int_4.*limit:}, output
|
114
|
+
elsif current_adapter?(:MysqlAdapter, :Mysql2Adapter)
|
115
|
+
assert_match %r{c_int_1.*limit: 1}, output
|
116
|
+
assert_match %r{c_int_2.*limit: 2}, output
|
117
|
+
assert_match %r{c_int_3.*limit: 3}, output
|
118
|
+
|
119
|
+
assert_match %r{c_int_4.*}, output
|
120
|
+
assert_no_match %r{c_int_4.*:limit}, output
|
121
|
+
elsif current_adapter?(:SQLite3Adapter)
|
122
|
+
assert_match %r{c_int_1.*limit: 1}, output
|
123
|
+
assert_match %r{c_int_2.*limit: 2}, output
|
124
|
+
assert_match %r{c_int_3.*limit: 3}, output
|
125
|
+
assert_match %r{c_int_4.*limit: 4}, output
|
126
|
+
end
|
127
|
+
assert_match %r{c_int_without_limit.*}, output
|
128
|
+
assert_no_match %r{c_int_without_limit.*limit:}, output
|
129
|
+
|
130
|
+
if current_adapter?(:SQLite3Adapter)
|
131
|
+
assert_match %r{c_int_5.*limit: 5}, output
|
132
|
+
assert_match %r{c_int_6.*limit: 6}, output
|
133
|
+
assert_match %r{c_int_7.*limit: 7}, output
|
134
|
+
assert_match %r{c_int_8.*limit: 8}, output
|
135
|
+
elsif current_adapter?(:OracleAdapter)
|
136
|
+
assert_match %r{c_int_5.*limit: 5}, output
|
137
|
+
assert_match %r{c_int_6.*limit: 6}, output
|
138
|
+
assert_match %r{c_int_7.*limit: 7}, output
|
139
|
+
assert_match %r{c_int_8.*limit: 8}, output
|
140
|
+
else
|
141
|
+
assert_match %r{c_int_5.*limit: 8}, output
|
142
|
+
assert_match %r{c_int_6.*limit: 8}, output
|
143
|
+
assert_match %r{c_int_7.*limit: 8}, output
|
144
|
+
assert_match %r{c_int_8.*limit: 8}, output
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_schema_dump_with_string_ignored_table
|
149
|
+
stream = StringIO.new
|
150
|
+
|
151
|
+
ActiveRecord::SchemaDumper.ignore_tables = ['accounts']
|
152
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
|
153
|
+
output = stream.string
|
154
|
+
assert_no_match %r{create_table "accounts"}, output
|
155
|
+
assert_match %r{create_table "authors"}, output
|
156
|
+
assert_no_match %r{create_table "schema_migrations"}, output
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_schema_dump_with_regexp_ignored_table
|
160
|
+
stream = StringIO.new
|
161
|
+
|
162
|
+
ActiveRecord::SchemaDumper.ignore_tables = [/^account/]
|
163
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
|
164
|
+
output = stream.string
|
165
|
+
assert_no_match %r{create_table "accounts"}, output
|
166
|
+
assert_match %r{create_table "authors"}, output
|
167
|
+
assert_no_match %r{create_table "schema_migrations"}, output
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_schema_dump_illegal_ignored_table_value
|
171
|
+
stream = StringIO.new
|
172
|
+
ActiveRecord::SchemaDumper.ignore_tables = [5]
|
173
|
+
assert_raise(StandardError) do
|
174
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_schema_dumps_index_columns_in_right_order
|
179
|
+
index_definition = standard_dump.split(/\n/).grep(/add_index.*companies/).first.strip
|
180
|
+
if current_adapter?(:MysqlAdapter) || current_adapter?(:Mysql2Adapter) || current_adapter?(:PostgreSQLAdapter)
|
181
|
+
assert_equal 'add_index "companies", ["firm_id", "type", "rating"], name: "company_index", using: :btree', index_definition
|
182
|
+
else
|
183
|
+
assert_equal 'add_index "companies", ["firm_id", "type", "rating"], name: "company_index"', index_definition
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_schema_dumps_partial_indices
|
188
|
+
index_definition = standard_dump.split(/\n/).grep(/add_index.*company_partial_index/).first.strip
|
189
|
+
if current_adapter?(:PostgreSQLAdapter)
|
190
|
+
assert_equal 'add_index "companies", ["firm_id", "type"], name: "company_partial_index", where: "(rating > 10)", using: :btree', index_definition
|
191
|
+
elsif current_adapter?(:MysqlAdapter) || current_adapter?(:Mysql2Adapter)
|
192
|
+
assert_equal 'add_index "companies", ["firm_id", "type"], name: "company_partial_index", using: :btree', index_definition
|
193
|
+
else
|
194
|
+
assert_equal 'add_index "companies", ["firm_id", "type"], name: "company_partial_index"', index_definition
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_schema_dump_should_honor_nonstandard_primary_keys
|
199
|
+
output = standard_dump
|
200
|
+
match = output.match(%r{create_table "movies"(.*)do})
|
201
|
+
assert_not_nil(match, "nonstandardpk table not found")
|
202
|
+
assert_match %r(primary_key: "movieid"), match[1], "non-standard primary key not preserved"
|
203
|
+
end
|
204
|
+
|
205
|
+
if current_adapter?(:MysqlAdapter, :Mysql2Adapter)
|
206
|
+
def test_schema_dump_should_not_add_default_value_for_mysql_text_field
|
207
|
+
output = standard_dump
|
208
|
+
assert_match %r{t.text\s+"body",\s+null: false$}, output
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_schema_dump_includes_length_for_mysql_binary_fields
|
212
|
+
output = standard_dump
|
213
|
+
assert_match %r{t.binary\s+"var_binary",\s+limit: 255$}, output
|
214
|
+
assert_match %r{t.binary\s+"var_binary_large",\s+limit: 4095$}, output
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_schema_dump_includes_length_for_mysql_blob_and_text_fields
|
218
|
+
output = standard_dump
|
219
|
+
assert_match %r{t.binary\s+"tiny_blob",\s+limit: 255$}, output
|
220
|
+
assert_match %r{t.binary\s+"normal_blob"$}, output
|
221
|
+
assert_match %r{t.binary\s+"medium_blob",\s+limit: 16777215$}, output
|
222
|
+
assert_match %r{t.binary\s+"long_blob",\s+limit: 2147483647$}, output
|
223
|
+
assert_match %r{t.text\s+"tiny_text",\s+limit: 255$}, output
|
224
|
+
assert_match %r{t.text\s+"normal_text"$}, output
|
225
|
+
assert_match %r{t.text\s+"medium_text",\s+limit: 16777215$}, output
|
226
|
+
assert_match %r{t.text\s+"long_text",\s+limit: 2147483647$}, output
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_schema_dumps_index_type
|
230
|
+
output = standard_dump
|
231
|
+
assert_match %r{add_index "key_tests", \["awesome"\], name: "index_key_tests_on_awesome", type: :fulltext}, output
|
232
|
+
assert_match %r{add_index "key_tests", \["pizza"\], name: "index_key_tests_on_pizza", using: :btree}, output
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_schema_dump_includes_decimal_options
|
237
|
+
stream = StringIO.new
|
238
|
+
ActiveRecord::SchemaDumper.ignore_tables = [/^[^n]/]
|
239
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
|
240
|
+
output = stream.string
|
241
|
+
assert_match %r{precision: 3,[[:space:]]+scale: 2,[[:space:]]+default: 2.78}, output
|
242
|
+
end
|
243
|
+
|
244
|
+
if current_adapter?(:PostgreSQLAdapter)
|
245
|
+
def test_schema_dump_includes_bigint_default
|
246
|
+
output = standard_dump
|
247
|
+
assert_match %r{t.integer\s+"bigint_default",\s+limit: 8,\s+default: 0}, output
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_schema_dump_includes_extensions
|
251
|
+
connection = ActiveRecord::Base.connection
|
252
|
+
skip unless connection.supports_extensions?
|
253
|
+
|
254
|
+
connection.stubs(:extensions).returns(['hstore'])
|
255
|
+
output = standard_dump
|
256
|
+
assert_match "# These are extensions that must be enabled", output
|
257
|
+
assert_match %r{enable_extension "hstore"}, output
|
258
|
+
|
259
|
+
connection.stubs(:extensions).returns([])
|
260
|
+
output = standard_dump
|
261
|
+
assert_no_match "# These are extensions that must be enabled", output
|
262
|
+
assert_no_match %r{enable_extension}, output
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_schema_dump_includes_xml_shorthand_definition
|
266
|
+
output = standard_dump
|
267
|
+
if %r{create_table "postgresql_xml_data_type"} =~ output
|
268
|
+
assert_match %r{t.xml "data"}, output
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
def test_schema_dump_includes_json_shorthand_definition
|
273
|
+
output = standard_dump
|
274
|
+
if %r{create_table "postgresql_json_data_type"} =~ output
|
275
|
+
assert_match %r|t.json "json_data", default: {}|, output
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_schema_dump_includes_inet_shorthand_definition
|
280
|
+
output = standard_dump
|
281
|
+
if %r{create_table "postgresql_network_addresses"} =~ output
|
282
|
+
assert_match %r{t.inet\s+"inet_address",\s+default: "192.168.1.1"}, output
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_schema_dump_includes_cidr_shorthand_definition
|
287
|
+
output = standard_dump
|
288
|
+
if %r{create_table "postgresql_network_addresses"} =~ output
|
289
|
+
assert_match %r{t.cidr\s+"cidr_address",\s+default: "192.168.1.0/24"}, output
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_schema_dump_includes_macaddr_shorthand_definition
|
294
|
+
output = standard_dump
|
295
|
+
if %r{create_table "postgresql_network_addresses"} =~ output
|
296
|
+
assert_match %r{t.macaddr\s+"mac_address",\s+default: "ff:ff:ff:ff:ff:ff"}, output
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
def test_schema_dump_includes_uuid_shorthand_definition
|
301
|
+
output = standard_dump
|
302
|
+
if %r{create_table "poistgresql_uuids"} =~ output
|
303
|
+
assert_match %r{t.uuid "guid"}, output
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def test_schema_dump_includes_hstores_shorthand_definition
|
308
|
+
output = standard_dump
|
309
|
+
if %r{create_table "postgresql_hstores"} =~ output
|
310
|
+
assert_match %r[t.hstore "hash_store", default: {}], output
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_schema_dump_includes_ltrees_shorthand_definition
|
315
|
+
output = standard_dump
|
316
|
+
if %r{create_table "postgresql_ltrees"} =~ output
|
317
|
+
assert_match %r[t.ltree "path"], output
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_schema_dump_includes_arrays_shorthand_definition
|
322
|
+
output = standard_dump
|
323
|
+
if %r{create_table "postgresql_arrays"} =~ output
|
324
|
+
assert_match %r[t.text\s+"nicknames",\s+array: true], output
|
325
|
+
assert_match %r[t.integer\s+"commission_by_quarter",\s+array: true], output
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_schema_dump_includes_tsvector_shorthand_definition
|
330
|
+
output = standard_dump
|
331
|
+
if %r{create_table "postgresql_tsvectors"} =~ output
|
332
|
+
assert_match %r{t.tsvector "text_vector"}, output
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def test_schema_dump_keeps_large_precision_integer_columns_as_decimal
|
338
|
+
output = standard_dump
|
339
|
+
# Oracle supports precision up to 38 and it identifies decimals with scale 0 as integers
|
340
|
+
if current_adapter?(:OracleAdapter)
|
341
|
+
assert_match %r{t.integer\s+"atoms_in_universe",\s+precision: 38,\s+scale: 0}, output
|
342
|
+
else
|
343
|
+
assert_match %r{t.decimal\s+"atoms_in_universe",\s+precision: 55,\s+scale: 0}, output
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
def test_schema_dump_keeps_id_column_when_id_is_false_and_id_column_added
|
348
|
+
output = standard_dump
|
349
|
+
match = output.match(%r{create_table "goofy_string_id"(.*)do.*\n(.*)\n})
|
350
|
+
assert_not_nil(match, "goofy_string_id table not found")
|
351
|
+
assert_match %r(id: false), match[1], "no table id not preserved"
|
352
|
+
assert_match %r{t.string[[:space:]]+"id",[[:space:]]+null: false$}, match[2], "non-primary key id column not preserved"
|
353
|
+
end
|
354
|
+
|
355
|
+
def test_schema_dump_keeps_id_false_when_id_is_false_and_unique_not_null_column_added
|
356
|
+
output = standard_dump
|
357
|
+
assert_match %r{create_table "subscribers", id: false}, output
|
358
|
+
end
|
359
|
+
|
360
|
+
class CreateDogMigration < ActiveRecord::Migration
|
361
|
+
def up
|
362
|
+
create_table("dogs") do |t|
|
363
|
+
t.column :name, :string
|
364
|
+
end
|
365
|
+
add_index "dogs", [:name]
|
366
|
+
end
|
367
|
+
def down
|
368
|
+
drop_table("dogs")
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
def test_schema_dump_with_table_name_prefix_and_suffix
|
373
|
+
original, $stdout = $stdout, StringIO.new
|
374
|
+
ActiveRecord::Base.table_name_prefix = 'foo_'
|
375
|
+
ActiveRecord::Base.table_name_suffix = '_bar'
|
376
|
+
|
377
|
+
migration = CreateDogMigration.new
|
378
|
+
migration.migrate(:up)
|
379
|
+
|
380
|
+
output = standard_dump
|
381
|
+
assert_no_match %r{create_table "foo_.+_bar"}, output
|
382
|
+
assert_no_match %r{create_index "foo_.+_bar"}, output
|
383
|
+
assert_no_match %r{create_table "schema_migrations"}, output
|
384
|
+
ensure
|
385
|
+
migration.migrate(:down)
|
386
|
+
|
387
|
+
ActiveRecord::Base.table_name_suffix = ActiveRecord::Base.table_name_prefix = ''
|
388
|
+
$stdout = original
|
389
|
+
end
|
390
|
+
|
391
|
+
end
|