mack-active_record 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gems/activerecord-2.2.2/lib/active_record/aggregations.rb +261 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/association_preload.rb +374 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb +453 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb +272 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/belongs_to_association.rb +58 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/belongs_to_polymorphic_association.rb +49 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_and_belongs_to_many_association.rb +121 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_many_association.rb +121 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_many_through_association.rb +256 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_one_association.rb +115 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_one_through_association.rb +31 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations.rb +2227 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb +387 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/base.rb +2967 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/calculations.rb +299 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/callbacks.rb +331 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb +355 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb +136 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb +201 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb +94 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/quoting.rb +69 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/schema_definitions.rb +705 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb +434 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb +210 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb +585 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb +1065 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite_adapter.rb +418 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/dirty.rb +183 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/dynamic_finder_match.rb +41 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/fixtures.rb +998 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/i18n_interpolation_deprecation.rb +26 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/locale/en.yml +54 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/locking/optimistic.rb +148 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/locking/pessimistic.rb +77 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/migration.rb +560 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/named_scope.rb +181 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/observer.rb +197 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/query_cache.rb +21 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/reflection.rb +307 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/schema.rb +51 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/schema_dumper.rb +177 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/serialization.rb +98 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/serializers/json_serializer.rb +80 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/serializers/xml_serializer.rb +338 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/test_case.rb +60 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/timestamp.rb +41 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/transactions.rb +185 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/validations.rb +1061 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/version.rb +9 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record.rb +81 -0
- data/lib/gems/activerecord-2.2.2/lib/activerecord.rb +1 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/base64.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/basic_object.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/buffered_logger.rb +122 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/compressed_mem_cache_store.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/drb_store.rb +15 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/file_store.rb +72 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/mem_cache_store.rb +127 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/memory_store.rb +52 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/synchronized_memory_store.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache.rb +223 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/callbacks.rb +280 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/access.rb +53 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/conversions.rb +183 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/extract_options.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/grouping.rb +106 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/random_access.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/base64/encoding.rb +16 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/base64.rb +4 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/bigdecimal/conversions.rb +37 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/bigdecimal.rb +6 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/blank.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/cgi.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/attribute_accessors.rb +54 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/delegating_attributes.rb +46 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/removal.rb +50 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class.rb +4 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/behavior.rb +42 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/calculations.rb +230 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/conversions.rb +107 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date.rb +10 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time/calculations.rb +126 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time/conversions.rb +96 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/duplicable.rb +43 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/enumerable.rb +107 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/exception.rb +41 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/file/atomic.rb +46 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/file.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float/rounding.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float/time.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float.rb +7 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/conversions.rb +259 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/diff.rb +19 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/except.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/indifferent_access.rb +137 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/keys.rb +52 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/reverse_merge.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/slice.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/even_odd.rb +29 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/inflections.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/time.rb +45 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/debugger.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/reporting.rb +59 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/requires.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/load_error.rb +38 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/logger.rb +143 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/aliasing.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attr_internal.rb +32 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attribute_accessors.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/delegation.rb +95 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/inclusion.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/introspection.rb +90 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/loading.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/model_naming.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/synchronization.rb +39 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/name_error.rb +17 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/bytes.rb +44 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/conversions.rb +19 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/time.rb +81 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/conversions.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/extending.rb +80 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/instance_variables.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/metaclass.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/misc.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/pathname.rb +7 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/proc.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/process/daemon.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/process.rb +1 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/blockless_step.rb +32 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/conversions.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/include_range.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/overlaps.rb +15 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range.rb +11 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/rexml.rb +36 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/access.rb +82 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/behavior.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/conversions.rb +28 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/filters.rb +26 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/inflections.rb +167 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/iterators.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/multibyte.rb +81 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/starts_ends_with.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/xchar.rb +11 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/symbol.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/behavior.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/calculations.rb +303 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/conversions.rb +90 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/zones.rb +86 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time.rb +42 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext.rb +4 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/dependencies.rb +621 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/deprecation.rb +243 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/duration.rb +96 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/gzip.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/inflections.rb +55 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/inflector.rb +397 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/decoding.rb +63 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/date.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/date_time.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/enumerable.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/false_class.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/hash.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/nil_class.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/numeric.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/object.rb +6 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/regexp.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/string.rb +36 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/symbol.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/time.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/true_class.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoding.rb +37 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/variable.rb +10 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/locale/en.yml +32 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/memoizable.rb +82 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/chars.rb +679 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/exceptions.rb +8 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/unicode_database.rb +71 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/option_merger.rb +17 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/ordered_hash.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/ordered_options.rb +19 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/rescuable.rb +108 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/secure_random.rb +197 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/string_inquirer.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/test_case.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/core_ext/test/unit/assertions.rb +72 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/core_ext/test.rb +6 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/default.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/performance.rb +452 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb +120 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/time_with_zone.rb +328 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/values/time_zone.rb +403 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +216 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/exceptions.rb +53 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n.rb +194 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb +849 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +228 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +55 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +219 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +40 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +283 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +136 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +204 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +161 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +274 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +194 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +232 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +139 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +144 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +131 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +282 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +205 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +288 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +196 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +67 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +73 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +161 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +34 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +59 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +121 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +270 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +187 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +29 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +193 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +185 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +37 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +185 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +16 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +185 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +188 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +232 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +181 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +197 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +276 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +218 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +168 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +268 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +288 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +211 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +170 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +181 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +232 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +187 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +176 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +215 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +173 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +172 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +183 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +170 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +212 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +202 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +52 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +51 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +44 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +98 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +56 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +292 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +508 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +56 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +40 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +94 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +198 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +129 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +1021 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor.rb +34 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/version.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/whiny_nil.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support.rb +61 -0
- data/lib/gems/activesupport-2.2.2/lib/activesupport.rb +1 -0
- data/lib/gems.rb +13 -0
- data/lib/mack-active_record/database.rb +4 -4
- data/lib/mack-active_record/migration_generator/migration_generator.rb +6 -2
- data/lib/mack-active_record/model_generator/manifest.yml +3 -3
- data/lib/mack-active_record/model_generator/model_generator.rb +8 -1
- data/lib/mack-active_record/model_generator/templates/model.rb.template +1 -1
- data/lib/mack-active_record/model_generator/templates/rspec.rb.template +1 -1
- data/lib/mack-active_record/model_generator/templates/test.rb.template +1 -1
- data/lib/mack-active_record.rb +3 -1
- data/lib/mack-active_record_tasks.rb +3 -0
- metadata +457 -16
data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb
ADDED
@@ -0,0 +1,355 @@
|
|
1
|
+
require 'monitor'
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
module ActiveRecord
|
5
|
+
# Raised when a connection could not be obtained within the connection
|
6
|
+
# acquisition timeout period.
|
7
|
+
class ConnectionTimeoutError < ConnectionNotEstablished
|
8
|
+
end
|
9
|
+
|
10
|
+
module ConnectionAdapters
|
11
|
+
# Connection pool base class for managing ActiveRecord database
|
12
|
+
# connections.
|
13
|
+
#
|
14
|
+
# == Introduction
|
15
|
+
#
|
16
|
+
# A connection pool synchronizes thread access to a limited number of
|
17
|
+
# database connections. The basic idea is that each thread checks out a
|
18
|
+
# database connection from the pool, uses that connection, and checks the
|
19
|
+
# connection back in. ConnectionPool is completely thread-safe, and will
|
20
|
+
# ensure that a connection cannot be used by two threads at the same time,
|
21
|
+
# as long as ConnectionPool's contract is correctly followed. It will also
|
22
|
+
# handle cases in which there are more threads than connections: if all
|
23
|
+
# connections have been checked out, and a thread tries to checkout a
|
24
|
+
# connection anyway, then ConnectionPool will wait until some other thread
|
25
|
+
# has checked in a connection.
|
26
|
+
#
|
27
|
+
# == Obtaining (checking out) a connection
|
28
|
+
#
|
29
|
+
# Connections can be obtained and used from a connection pool in several
|
30
|
+
# ways:
|
31
|
+
#
|
32
|
+
# 1. Simply use ActiveRecord::Base.connection as with ActiveRecord 2.1 and
|
33
|
+
# earlier (pre-connection-pooling). Eventually, when you're done with
|
34
|
+
# the connection(s) and wish it to be returned to the pool, you call
|
35
|
+
# ActiveRecord::Base.clear_active_connections!. This will be the
|
36
|
+
# default behavior for ActiveRecord when used in conjunction with
|
37
|
+
# ActionPack's request handling cycle.
|
38
|
+
# 2. Manually check out a connection from the pool with
|
39
|
+
# ActiveRecord::Base.connection_pool.checkout. You are responsible for
|
40
|
+
# returning this connection to the pool when finished by calling
|
41
|
+
# ActiveRecord::Base.connection_pool.checkin(connection).
|
42
|
+
# 3. Use ActiveRecord::Base.connection_pool.with_connection(&block), which
|
43
|
+
# obtains a connection, yields it as the sole argument to the block,
|
44
|
+
# and returns it to the pool after the block completes.
|
45
|
+
#
|
46
|
+
# Connections in the pool are actually AbstractAdapter objects (or objects
|
47
|
+
# compatible with AbstractAdapter's interface).
|
48
|
+
#
|
49
|
+
# == Options
|
50
|
+
#
|
51
|
+
# There are two connection-pooling-related options that you can add to
|
52
|
+
# your database connection configuration:
|
53
|
+
#
|
54
|
+
# * +pool+: number indicating size of connection pool (default 5)
|
55
|
+
# * +wait_timeout+: number of seconds to block and wait for a connection
|
56
|
+
# before giving up and raising a timeout error (default 5 seconds).
|
57
|
+
class ConnectionPool
|
58
|
+
attr_reader :spec
|
59
|
+
|
60
|
+
# Creates a new ConnectionPool object. +spec+ is a ConnectionSpecification
|
61
|
+
# object which describes database connection information (e.g. adapter,
|
62
|
+
# host name, username, password, etc), as well as the maximum size for
|
63
|
+
# this ConnectionPool.
|
64
|
+
#
|
65
|
+
# The default ConnectionPool maximum size is 5.
|
66
|
+
def initialize(spec)
|
67
|
+
@spec = spec
|
68
|
+
|
69
|
+
# The cache of reserved connections mapped to threads
|
70
|
+
@reserved_connections = {}
|
71
|
+
|
72
|
+
# The mutex used to synchronize pool access
|
73
|
+
@connection_mutex = Monitor.new
|
74
|
+
@queue = @connection_mutex.new_cond
|
75
|
+
|
76
|
+
# default 5 second timeout unless on ruby 1.9
|
77
|
+
@timeout =
|
78
|
+
if RUBY_VERSION < '1.9'
|
79
|
+
spec.config[:wait_timeout] || 5
|
80
|
+
end
|
81
|
+
|
82
|
+
# default max pool size to 5
|
83
|
+
@size = (spec.config[:pool] && spec.config[:pool].to_i) || 5
|
84
|
+
|
85
|
+
@connections = []
|
86
|
+
@checked_out = []
|
87
|
+
end
|
88
|
+
|
89
|
+
# Retrieve the connection associated with the current thread, or call
|
90
|
+
# #checkout to obtain one if necessary.
|
91
|
+
#
|
92
|
+
# #connection can be called any number of times; the connection is
|
93
|
+
# held in a hash keyed by the thread id.
|
94
|
+
def connection
|
95
|
+
if conn = @reserved_connections[current_connection_id]
|
96
|
+
conn
|
97
|
+
else
|
98
|
+
@reserved_connections[current_connection_id] = checkout
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Signal that the thread is finished with the current connection.
|
103
|
+
# #release_connection releases the connection-thread association
|
104
|
+
# and returns the connection to the pool.
|
105
|
+
def release_connection
|
106
|
+
conn = @reserved_connections.delete(current_connection_id)
|
107
|
+
checkin conn if conn
|
108
|
+
end
|
109
|
+
|
110
|
+
# Reserve a connection, and yield it to a block. Ensure the connection is
|
111
|
+
# checked back in when finished.
|
112
|
+
def with_connection
|
113
|
+
conn = checkout
|
114
|
+
yield conn
|
115
|
+
ensure
|
116
|
+
checkin conn
|
117
|
+
end
|
118
|
+
|
119
|
+
# Returns true if a connection has already been opened.
|
120
|
+
def connected?
|
121
|
+
!@connections.empty?
|
122
|
+
end
|
123
|
+
|
124
|
+
# Disconnects all connections in the pool, and clears the pool.
|
125
|
+
def disconnect!
|
126
|
+
@reserved_connections.each do |name,conn|
|
127
|
+
checkin conn
|
128
|
+
end
|
129
|
+
@reserved_connections = {}
|
130
|
+
@connections.each do |conn|
|
131
|
+
conn.disconnect!
|
132
|
+
end
|
133
|
+
@connections = []
|
134
|
+
end
|
135
|
+
|
136
|
+
# Clears the cache which maps classes
|
137
|
+
def clear_reloadable_connections!
|
138
|
+
@reserved_connections.each do |name, conn|
|
139
|
+
checkin conn
|
140
|
+
end
|
141
|
+
@reserved_connections = {}
|
142
|
+
@connections.each do |conn|
|
143
|
+
conn.disconnect! if conn.requires_reloading?
|
144
|
+
end
|
145
|
+
@connections = []
|
146
|
+
end
|
147
|
+
|
148
|
+
# Verify active connections and remove and disconnect connections
|
149
|
+
# associated with stale threads.
|
150
|
+
def verify_active_connections! #:nodoc:
|
151
|
+
clear_stale_cached_connections!
|
152
|
+
@connections.each do |connection|
|
153
|
+
connection.verify!
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Return any checked-out connections back to the pool by threads that
|
158
|
+
# are no longer alive.
|
159
|
+
def clear_stale_cached_connections!
|
160
|
+
remove_stale_cached_threads!(@reserved_connections) do |name, conn|
|
161
|
+
checkin conn
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# Check-out a database connection from the pool, indicating that you want
|
166
|
+
# to use it. You should call #checkin when you no longer need this.
|
167
|
+
#
|
168
|
+
# This is done by either returning an existing connection, or by creating
|
169
|
+
# a new connection. If the maximum number of connections for this pool has
|
170
|
+
# already been reached, but the pool is empty (i.e. they're all being used),
|
171
|
+
# then this method will wait until a thread has checked in a connection.
|
172
|
+
# The wait time is bounded however: if no connection can be checked out
|
173
|
+
# within the timeout specified for this pool, then a ConnectionTimeoutError
|
174
|
+
# exception will be raised.
|
175
|
+
#
|
176
|
+
# Returns: an AbstractAdapter object.
|
177
|
+
#
|
178
|
+
# Raises:
|
179
|
+
# - ConnectionTimeoutError: no connection can be obtained from the pool
|
180
|
+
# within the timeout period.
|
181
|
+
def checkout
|
182
|
+
# Checkout an available connection
|
183
|
+
@connection_mutex.synchronize do
|
184
|
+
loop do
|
185
|
+
conn = if @checked_out.size < @connections.size
|
186
|
+
checkout_existing_connection
|
187
|
+
elsif @connections.size < @size
|
188
|
+
checkout_new_connection
|
189
|
+
end
|
190
|
+
return conn if conn
|
191
|
+
# No connections available; wait for one
|
192
|
+
if @queue.wait(@timeout)
|
193
|
+
next
|
194
|
+
else
|
195
|
+
# try looting dead threads
|
196
|
+
clear_stale_cached_connections!
|
197
|
+
if @size == @checked_out.size
|
198
|
+
raise ConnectionTimeoutError, "could not obtain a database connection#{" within #{@timeout} seconds" if @timeout}. The max pool size is currently #{@size}; consider increasing it."
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
# Check-in a database connection back into the pool, indicating that you
|
206
|
+
# no longer need this connection.
|
207
|
+
#
|
208
|
+
# +conn+: an AbstractAdapter object, which was obtained by earlier by
|
209
|
+
# calling +checkout+ on this pool.
|
210
|
+
def checkin(conn)
|
211
|
+
@connection_mutex.synchronize do
|
212
|
+
conn.run_callbacks :checkin
|
213
|
+
@checked_out.delete conn
|
214
|
+
@queue.signal
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
synchronize :clear_reloadable_connections!, :verify_active_connections!,
|
219
|
+
:connected?, :disconnect!, :with => :@connection_mutex
|
220
|
+
|
221
|
+
private
|
222
|
+
def new_connection
|
223
|
+
ActiveRecord::Base.send(spec.adapter_method, spec.config)
|
224
|
+
end
|
225
|
+
|
226
|
+
def current_connection_id #:nodoc:
|
227
|
+
Thread.current.object_id
|
228
|
+
end
|
229
|
+
|
230
|
+
# Remove stale threads from the cache.
|
231
|
+
def remove_stale_cached_threads!(cache, &block)
|
232
|
+
keys = Set.new(cache.keys)
|
233
|
+
|
234
|
+
Thread.list.each do |thread|
|
235
|
+
keys.delete(thread.object_id) if thread.alive?
|
236
|
+
end
|
237
|
+
keys.each do |key|
|
238
|
+
next unless cache.has_key?(key)
|
239
|
+
block.call(key, cache[key])
|
240
|
+
cache.delete(key)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def checkout_new_connection
|
245
|
+
c = new_connection
|
246
|
+
@connections << c
|
247
|
+
checkout_and_verify(c)
|
248
|
+
end
|
249
|
+
|
250
|
+
def checkout_existing_connection
|
251
|
+
c = (@connections - @checked_out).first
|
252
|
+
checkout_and_verify(c)
|
253
|
+
end
|
254
|
+
|
255
|
+
def checkout_and_verify(c)
|
256
|
+
c.verify!
|
257
|
+
c.run_callbacks :checkout
|
258
|
+
@checked_out << c
|
259
|
+
c
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# ConnectionHandler is a collection of ConnectionPool objects. It is used
|
264
|
+
# for keeping separate connection pools for ActiveRecord models that connect
|
265
|
+
# to different databases.
|
266
|
+
#
|
267
|
+
# For example, suppose that you have 5 models, with the following hierarchy:
|
268
|
+
#
|
269
|
+
# |
|
270
|
+
# +-- Book
|
271
|
+
# | |
|
272
|
+
# | +-- ScaryBook
|
273
|
+
# | +-- GoodBook
|
274
|
+
# +-- Author
|
275
|
+
# +-- BankAccount
|
276
|
+
#
|
277
|
+
# Suppose that Book is to connect to a separate database (i.e. one other
|
278
|
+
# than the default database). Then Book, ScaryBook and GoodBook will all use
|
279
|
+
# the same connection pool. Likewise, Author and BankAccount will use the
|
280
|
+
# same connection pool. However, the connection pool used by Author/BankAccount
|
281
|
+
# is not the same as the one used by Book/ScaryBook/GoodBook.
|
282
|
+
#
|
283
|
+
# Normally there is only a single ConnectionHandler instance, accessible via
|
284
|
+
# ActiveRecord::Base.connection_handler. ActiveRecord models use this to
|
285
|
+
# determine that connection pool that they should use.
|
286
|
+
class ConnectionHandler
|
287
|
+
def initialize(pools = {})
|
288
|
+
@connection_pools = pools
|
289
|
+
end
|
290
|
+
|
291
|
+
def connection_pools
|
292
|
+
@connection_pools ||= {}
|
293
|
+
end
|
294
|
+
|
295
|
+
def establish_connection(name, spec)
|
296
|
+
@connection_pools[name] = ConnectionAdapters::ConnectionPool.new(spec)
|
297
|
+
end
|
298
|
+
|
299
|
+
# Returns any connections in use by the current thread back to the pool,
|
300
|
+
# and also returns connections to the pool cached by threads that are no
|
301
|
+
# longer alive.
|
302
|
+
def clear_active_connections!
|
303
|
+
@connection_pools.each_value {|pool| pool.release_connection }
|
304
|
+
end
|
305
|
+
|
306
|
+
# Clears the cache which maps classes
|
307
|
+
def clear_reloadable_connections!
|
308
|
+
@connection_pools.each_value {|pool| pool.clear_reloadable_connections! }
|
309
|
+
end
|
310
|
+
|
311
|
+
def clear_all_connections!
|
312
|
+
@connection_pools.each_value {|pool| pool.disconnect! }
|
313
|
+
end
|
314
|
+
|
315
|
+
# Verify active connections.
|
316
|
+
def verify_active_connections! #:nodoc:
|
317
|
+
@connection_pools.each_value {|pool| pool.verify_active_connections! }
|
318
|
+
end
|
319
|
+
|
320
|
+
# Locate the connection of the nearest super class. This can be an
|
321
|
+
# active or defined connection: if it is the latter, it will be
|
322
|
+
# opened and set as the active connection for the class it was defined
|
323
|
+
# for (not necessarily the current class).
|
324
|
+
def retrieve_connection(klass) #:nodoc:
|
325
|
+
pool = retrieve_connection_pool(klass)
|
326
|
+
(pool && pool.connection) or raise ConnectionNotEstablished
|
327
|
+
end
|
328
|
+
|
329
|
+
# Returns true if a connection that's accessible to this class has
|
330
|
+
# already been opened.
|
331
|
+
def connected?(klass)
|
332
|
+
conn = retrieve_connection_pool(klass)
|
333
|
+
conn ? conn.connected? : false
|
334
|
+
end
|
335
|
+
|
336
|
+
# Remove the connection for this class. This will close the active
|
337
|
+
# connection and the defined connection (if they exist). The result
|
338
|
+
# can be used as an argument for establish_connection, for easily
|
339
|
+
# re-establishing the connection.
|
340
|
+
def remove_connection(klass)
|
341
|
+
pool = @connection_pools[klass.name]
|
342
|
+
@connection_pools.delete_if { |key, value| value == pool }
|
343
|
+
pool.disconnect! if pool
|
344
|
+
pool.spec.config if pool
|
345
|
+
end
|
346
|
+
|
347
|
+
def retrieve_connection_pool(klass)
|
348
|
+
pool = @connection_pools[klass.name]
|
349
|
+
return pool if pool
|
350
|
+
return nil if ActiveRecord::Base == klass
|
351
|
+
retrieve_connection_pool klass.superclass
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
class Base
|
3
|
+
class ConnectionSpecification #:nodoc:
|
4
|
+
attr_reader :config, :adapter_method
|
5
|
+
def initialize (config, adapter_method)
|
6
|
+
@config, @adapter_method = config, adapter_method
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# The connection handler
|
11
|
+
cattr_accessor :connection_handler, :instance_writer => false
|
12
|
+
@@connection_handler = ConnectionAdapters::ConnectionHandler.new
|
13
|
+
|
14
|
+
# Returns the connection currently associated with the class. This can
|
15
|
+
# also be used to "borrow" the connection to do database work that isn't
|
16
|
+
# easily done without going straight to SQL.
|
17
|
+
def connection
|
18
|
+
self.class.connection
|
19
|
+
end
|
20
|
+
|
21
|
+
# Establishes the connection to the database. Accepts a hash as input where
|
22
|
+
# the <tt>:adapter</tt> key must be specified with the name of a database adapter (in lower-case)
|
23
|
+
# example for regular databases (MySQL, Postgresql, etc):
|
24
|
+
#
|
25
|
+
# ActiveRecord::Base.establish_connection(
|
26
|
+
# :adapter => "mysql",
|
27
|
+
# :host => "localhost",
|
28
|
+
# :username => "myuser",
|
29
|
+
# :password => "mypass",
|
30
|
+
# :database => "somedatabase"
|
31
|
+
# )
|
32
|
+
#
|
33
|
+
# Example for SQLite database:
|
34
|
+
#
|
35
|
+
# ActiveRecord::Base.establish_connection(
|
36
|
+
# :adapter => "sqlite",
|
37
|
+
# :database => "path/to/dbfile"
|
38
|
+
# )
|
39
|
+
#
|
40
|
+
# Also accepts keys as strings (for parsing from YAML for example):
|
41
|
+
#
|
42
|
+
# ActiveRecord::Base.establish_connection(
|
43
|
+
# "adapter" => "sqlite",
|
44
|
+
# "database" => "path/to/dbfile"
|
45
|
+
# )
|
46
|
+
#
|
47
|
+
# The exceptions AdapterNotSpecified, AdapterNotFound and ArgumentError
|
48
|
+
# may be returned on an error.
|
49
|
+
def self.establish_connection(spec = nil)
|
50
|
+
case spec
|
51
|
+
when nil
|
52
|
+
raise AdapterNotSpecified unless defined? RAILS_ENV
|
53
|
+
establish_connection(RAILS_ENV)
|
54
|
+
when ConnectionSpecification
|
55
|
+
@@connection_handler.establish_connection(name, spec)
|
56
|
+
when Symbol, String
|
57
|
+
if configuration = configurations[spec.to_s]
|
58
|
+
establish_connection(configuration)
|
59
|
+
else
|
60
|
+
raise AdapterNotSpecified, "#{spec} database is not configured"
|
61
|
+
end
|
62
|
+
else
|
63
|
+
spec = spec.symbolize_keys
|
64
|
+
unless spec.key?(:adapter) then raise AdapterNotSpecified, "database configuration does not specify adapter" end
|
65
|
+
|
66
|
+
begin
|
67
|
+
require 'rubygems'
|
68
|
+
gem "activerecord-#{spec[:adapter]}-adapter"
|
69
|
+
require "active_record/connection_adapters/#{spec[:adapter]}_adapter"
|
70
|
+
rescue LoadError
|
71
|
+
begin
|
72
|
+
require "active_record/connection_adapters/#{spec[:adapter]}_adapter"
|
73
|
+
rescue LoadError
|
74
|
+
raise "Please install the #{spec[:adapter]} adapter: `gem install activerecord-#{spec[:adapter]}-adapter` (#{$!})"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
adapter_method = "#{spec[:adapter]}_connection"
|
79
|
+
if !respond_to?(adapter_method)
|
80
|
+
raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter"
|
81
|
+
end
|
82
|
+
|
83
|
+
remove_connection
|
84
|
+
establish_connection(ConnectionSpecification.new(spec, adapter_method))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class << self
|
89
|
+
# Deprecated and no longer has any effect.
|
90
|
+
def allow_concurrency
|
91
|
+
ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_concurrency has been deprecated and no longer has any effect. Please remove all references to allow_concurrency.")
|
92
|
+
end
|
93
|
+
|
94
|
+
# Deprecated and no longer has any effect.
|
95
|
+
def allow_concurrency=(flag)
|
96
|
+
ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_concurrency= has been deprecated and no longer has any effect. Please remove all references to allow_concurrency=.")
|
97
|
+
end
|
98
|
+
|
99
|
+
# Deprecated and no longer has any effect.
|
100
|
+
def verification_timeout
|
101
|
+
ActiveSupport::Deprecation.warn("ActiveRecord::Base.verification_timeout has been deprecated and no longer has any effect. Please remove all references to verification_timeout.")
|
102
|
+
end
|
103
|
+
|
104
|
+
# Deprecated and no longer has any effect.
|
105
|
+
def verification_timeout=(flag)
|
106
|
+
ActiveSupport::Deprecation.warn("ActiveRecord::Base.verification_timeout= has been deprecated and no longer has any effect. Please remove all references to verification_timeout=.")
|
107
|
+
end
|
108
|
+
|
109
|
+
# Returns the connection currently associated with the class. This can
|
110
|
+
# also be used to "borrow" the connection to do database work unrelated
|
111
|
+
# to any of the specific Active Records.
|
112
|
+
def connection
|
113
|
+
retrieve_connection
|
114
|
+
end
|
115
|
+
|
116
|
+
def connection_pool
|
117
|
+
connection_handler.retrieve_connection_pool(self)
|
118
|
+
end
|
119
|
+
|
120
|
+
def retrieve_connection
|
121
|
+
connection_handler.retrieve_connection(self)
|
122
|
+
end
|
123
|
+
|
124
|
+
def connected?
|
125
|
+
connection_handler.connected?(self)
|
126
|
+
end
|
127
|
+
|
128
|
+
def remove_connection(klass = self)
|
129
|
+
connection_handler.remove_connection(klass)
|
130
|
+
end
|
131
|
+
|
132
|
+
delegate :clear_active_connections!, :clear_reloadable_connections!,
|
133
|
+
:clear_all_connections!,:verify_active_connections!, :to => :connection_handler
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module ConnectionAdapters # :nodoc:
|
3
|
+
module DatabaseStatements
|
4
|
+
# Returns an array of record hashes with the column names as keys and
|
5
|
+
# column values as values.
|
6
|
+
def select_all(sql, name = nil)
|
7
|
+
select(sql, name)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns a record hash with the column names as keys and column values
|
11
|
+
# as values.
|
12
|
+
def select_one(sql, name = nil)
|
13
|
+
result = select_all(sql, name)
|
14
|
+
result.first if result
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns a single value from a record
|
18
|
+
def select_value(sql, name = nil)
|
19
|
+
if result = select_one(sql, name)
|
20
|
+
result.values.first
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns an array of the values of the first column in a select:
|
25
|
+
# select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]
|
26
|
+
def select_values(sql, name = nil)
|
27
|
+
result = select_rows(sql, name)
|
28
|
+
result.map { |v| v[0] }
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns an array of arrays containing the field values.
|
32
|
+
# Order is the same as that returned by +columns+.
|
33
|
+
def select_rows(sql, name = nil)
|
34
|
+
raise NotImplementedError, "select_rows is an abstract method"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Executes the SQL statement in the context of this connection.
|
38
|
+
def execute(sql, name = nil)
|
39
|
+
raise NotImplementedError, "execute is an abstract method"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns the last auto-generated ID from the affected table.
|
43
|
+
def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
|
44
|
+
insert_sql(sql, name, pk, id_value, sequence_name)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Executes the update statement and returns the number of rows affected.
|
48
|
+
def update(sql, name = nil)
|
49
|
+
update_sql(sql, name)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Executes the delete statement and returns the number of rows affected.
|
53
|
+
def delete(sql, name = nil)
|
54
|
+
delete_sql(sql, name)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Wrap a block in a transaction. Returns result of block.
|
58
|
+
def transaction(start_db_transaction = true)
|
59
|
+
transaction_open = false
|
60
|
+
begin
|
61
|
+
if block_given?
|
62
|
+
if start_db_transaction
|
63
|
+
begin_db_transaction
|
64
|
+
transaction_open = true
|
65
|
+
end
|
66
|
+
yield
|
67
|
+
end
|
68
|
+
rescue Exception => database_transaction_rollback
|
69
|
+
if transaction_open
|
70
|
+
transaction_open = false
|
71
|
+
rollback_db_transaction
|
72
|
+
end
|
73
|
+
raise unless database_transaction_rollback.is_a? ActiveRecord::Rollback
|
74
|
+
end
|
75
|
+
ensure
|
76
|
+
if transaction_open
|
77
|
+
begin
|
78
|
+
commit_db_transaction
|
79
|
+
rescue Exception => database_transaction_rollback
|
80
|
+
rollback_db_transaction
|
81
|
+
raise
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Begins the transaction (and turns off auto-committing).
|
87
|
+
def begin_db_transaction() end
|
88
|
+
|
89
|
+
# Commits the transaction (and turns on auto-committing).
|
90
|
+
def commit_db_transaction() end
|
91
|
+
|
92
|
+
# Rolls back the transaction (and turns on auto-committing). Must be
|
93
|
+
# done if the transaction block raises an exception or returns false.
|
94
|
+
def rollback_db_transaction() end
|
95
|
+
|
96
|
+
# Alias for <tt>add_limit_offset!</tt>.
|
97
|
+
def add_limit!(sql, options)
|
98
|
+
add_limit_offset!(sql, options) if options
|
99
|
+
end
|
100
|
+
|
101
|
+
# Appends +LIMIT+ and +OFFSET+ options to an SQL statement, or some SQL
|
102
|
+
# fragment that has the same semantics as LIMIT and OFFSET.
|
103
|
+
#
|
104
|
+
# +options+ must be a Hash which contains a +:limit+ option (required)
|
105
|
+
# and an +:offset+ option (optional).
|
106
|
+
#
|
107
|
+
# This method *modifies* the +sql+ parameter.
|
108
|
+
#
|
109
|
+
# ===== Examples
|
110
|
+
# add_limit_offset!('SELECT * FROM suppliers', {:limit => 10, :offset => 50})
|
111
|
+
# generates
|
112
|
+
# SELECT * FROM suppliers LIMIT 10 OFFSET 50
|
113
|
+
def add_limit_offset!(sql, options)
|
114
|
+
if limit = options[:limit]
|
115
|
+
sql << " LIMIT #{sanitize_limit(limit)}"
|
116
|
+
if offset = options[:offset]
|
117
|
+
sql << " OFFSET #{offset.to_i}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
sql
|
121
|
+
end
|
122
|
+
|
123
|
+
# Appends a locking clause to an SQL statement.
|
124
|
+
# This method *modifies* the +sql+ parameter.
|
125
|
+
# # SELECT * FROM suppliers FOR UPDATE
|
126
|
+
# add_lock! 'SELECT * FROM suppliers', :lock => true
|
127
|
+
# add_lock! 'SELECT * FROM suppliers', :lock => ' FOR UPDATE'
|
128
|
+
def add_lock!(sql, options)
|
129
|
+
case lock = options[:lock]
|
130
|
+
when true; sql << ' FOR UPDATE'
|
131
|
+
when String; sql << " #{lock}"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def default_sequence_name(table, column)
|
136
|
+
nil
|
137
|
+
end
|
138
|
+
|
139
|
+
# Set the sequence to the max value of the table's column.
|
140
|
+
def reset_sequence!(table, column, sequence = nil)
|
141
|
+
# Do nothing by default. Implement for PostgreSQL, Oracle, ...
|
142
|
+
end
|
143
|
+
|
144
|
+
# Inserts the given fixture into the table. Overridden in adapters that require
|
145
|
+
# something beyond a simple insert (eg. Oracle).
|
146
|
+
def insert_fixture(fixture, table_name)
|
147
|
+
execute "INSERT INTO #{quote_table_name(table_name)} (#{fixture.key_list}) VALUES (#{fixture.value_list})", 'Fixture Insert'
|
148
|
+
end
|
149
|
+
|
150
|
+
def empty_insert_statement(table_name)
|
151
|
+
"INSERT INTO #{quote_table_name(table_name)} VALUES(DEFAULT)"
|
152
|
+
end
|
153
|
+
|
154
|
+
def case_sensitive_equality_operator
|
155
|
+
"="
|
156
|
+
end
|
157
|
+
|
158
|
+
def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key)
|
159
|
+
"WHERE #{quoted_primary_key} IN (SELECT #{quoted_primary_key} FROM #{quoted_table_name} #{where_sql})"
|
160
|
+
end
|
161
|
+
|
162
|
+
protected
|
163
|
+
# Returns an array of record hashes with the column names as keys and
|
164
|
+
# column values as values.
|
165
|
+
def select(sql, name = nil)
|
166
|
+
raise NotImplementedError, "select is an abstract method"
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns the last auto-generated ID from the affected table.
|
170
|
+
def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
|
171
|
+
execute(sql, name)
|
172
|
+
id_value
|
173
|
+
end
|
174
|
+
|
175
|
+
# Executes the update statement and returns the number of rows affected.
|
176
|
+
def update_sql(sql, name = nil)
|
177
|
+
execute(sql, name)
|
178
|
+
end
|
179
|
+
|
180
|
+
# Executes the delete statement and returns the number of rows affected.
|
181
|
+
def delete_sql(sql, name = nil)
|
182
|
+
update_sql(sql, name)
|
183
|
+
end
|
184
|
+
|
185
|
+
# Sanitizes the given LIMIT parameter in order to prevent SQL injection.
|
186
|
+
#
|
187
|
+
# +limit+ may be anything that can evaluate to a string via #to_s. It
|
188
|
+
# should look like an integer, or a comma-delimited list of integers.
|
189
|
+
#
|
190
|
+
# Returns the sanitized limit parameter, either as an integer, or as a
|
191
|
+
# string which contains a comma-delimited list of integers.
|
192
|
+
def sanitize_limit(limit)
|
193
|
+
if limit.to_s =~ /,/
|
194
|
+
limit.to_s.split(',').map{ |i| i.to_i }.join(',')
|
195
|
+
else
|
196
|
+
limit.to_i
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|