aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
Commit message (Collapse)AuthorAgeFilesLines
* exists?(false) returns falseEgor Lynko2012-06-251-0/+4
| | | | `FinderMethods#exists?` finder method now returns *false* with the *false* argument
* Revert "Merge pull request #6344"Piotr Sarnacki2012-06-252-15/+4
| | | | | | | | | | | | | | This commit needs to be reverted because it introduces difficulties when using sqlite3 in development and other databases in production. This happens because when you create time column in sqlite3, it's dumped as datetime in schema.rb file. This reverts commit 57d534ee9e441d078fcc161c0c78ebaa5aacd736, reversing changes made to 20f049fb50daee0c5e5a69b55b529af5737e8e3f. Conflicts: activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
* Stop assuming strings for grouped calculationsErnie Miller2012-06-241-0/+5
| | | | | | | | | | | | | | | Execute_grouped_calculation is one of those places where ActiveRecord forgets that it has ARel underpinnings, and assumes that the values provided to group_values are strings. This artificially hobbles otherwise functional code. This patch stops assuming that incoming values respond to to_sym, stops using string interpolation for table aliases on objects that support aliasing, and stops unnecessarily joining group_values on the relation. Additionally, it calls to_sql, if available, on objects sent to column_alias_for, in order to get a more reasonable alias string than a non-string's default to_str method.
* Move tasks(rake) tests to under the tasks dir.kennyj2012-06-244-0/+0
|
* Add test cases for 46492949b8c09f99db78b9f7a02d039e7bc6a702Andrew White2012-06-231-0/+52
|
* Allow precision option for postgresql datetimesTony Schneider2012-06-221-0/+65
| | | | | | | | | | This patch addresses the difficulty of retrieving datetime fields. By default, the database holds a higher precision than the time as a String. This issue is discussed at length at the following links: - [#3519](https://github.com/rails/rails/issues/3519) - [#3520](https://github.com/rails/rails/issues/3520) Also, kudos to @mattscilipoti
* Merge pull request #6800 from mschneider/dynamic_finders_for_aliased_attributesRafael Mendonça França2012-06-223-1/+12
|\ | | | | Dynamic finders for aliased attributes
| * made dynamic finders alias_attribute awareMaximilian Schneider2012-06-223-1/+12
| | | | | | | | | | previously dynamic finders only worked in combination with the actual column name and not its alias defined with #alias_attribute
* | Refactor pluck with multiple columnsCarlos Antonio da Silva2012-06-221-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | Ensure it works with mix of symbols and strings, and with a select clause possibly containing more than one column. Also remove support for pluck with an array of columns, in favor of passing the list of attributes: Model.pluck(:a, :b) See comments: https://github.com/rails/rails/pull/6500#issuecomment-6030292
* | ActiveRecord#pluck now accepts multiple columnsjeroeningen2012-06-221-1/+16
| |
* | Fix serializable_hash with xml generation and default :except optionCarlos Antonio da Silva2012-06-222-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When generating xml with a custom implementation of serializable_hash, if using the :except option, it was being overriden by the default AR implementation that attempts to ignore the inheritance column from STI automatically. So, if you have an implementation like this: def serializable_hash(options={}) super({ except: %w(some_attr) }.merge!(options)) end The :except option was correctly being used for :json generation, but not for :xml, because the options hash already contained the :except key with the inheritance column, thus overriding the customization. This commit fixes this problem by removing the :except logic from the xml serializer, that happened before calling serializable_hash. Since serializable_hash also does the same check for inheritance column, this logic was duplicated in both places, thus it's safe to remove it from xml serializer (see ActiveRecord::Serialization#serializable_hash). This is an attempt to solve issue #2498, that claims for a "Single transformation API for both xml and json representations".
* | Add some coverage for AR serialization with serializable_hashCarlos Antonio da Silva2012-06-222-9/+81
| | | | | | | | | | | | ActiveRecord json/xml serialization should use as base serializable_hash, provided by ActiveModel. Add some more coverage around options :only and :except for both json and xml serialization.
* | disallow mutating a relation once loadedJon Leighton2012-06-221-0/+27
| |
* | Improve the derivation of HABTM assocation join table namesAndrew White2012-06-223-15/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve the derivation of HABTM join table name to take account of nesting. It now takes the table names of the two models, sorts them lexically and then joins them, stripping any common prefix from the second table name. Some examples: Top level models (Category <=> Product) Old: categories_products New: categories_products Top level models with a global table_name_prefix (Category <=> Product) Old: site_categories_products New: site_categories_products Nested models in a module without a table_name_prefix method (Admin::Category <=> Admin::Product) Old: categories_products New: categories_products Nested models in a module with a table_name_prefix method (Admin::Category <=> Admin::Product) Old: categories_products New: admin_categories_products Nested models in a parent model (Catalog::Category <=> Catalog::Product) Old: categories_products New: catalog_categories_products Nested models in different parent models (Catalog::Category <=> Content::Page) Old: categories_pages New: catalog_categories_content_pages Also as part of this commit the validity checks for HABTM assocations have been moved to ActiveRecord::Reflection One side effect of this is to move when the exceptions are raised from the point of declaration to when the association is built. This is consistant with other association validity checks.
* | explain listener does not care about time, so use evented listenerAaron Patterson2012-06-201-5/+5
| |
* | Refactor testcase codes. It's repeated.kennyj2012-06-211-132/+38
|/
* Merge pull request #6798 from kennyj/db-rake-structure-loadCarlos Antonio da Silva2012-06-204-34/+107
|\ | | | | Refactor db:structure:load task.
| * Remove duplicated codes.kennyj2012-06-211-41/+11
| |
| * Refactor db:structure:load task.kennyj2012-06-214-0/+103
| |
* | Merge pull request #4396 from kennyj/fix_4259Rafael Mendonça França2012-06-201-0/+32
|\ \ | |/ |/| | | Fix GH #4259. When we execute schema dumper, we must remove table_name_prefix and table_name_suffix.
| * Fix GH #4259. We must remove table_name_prefix and table_name_suffix, when ↵kennyj2012-01-101-0/+32
| | | | | | | | we execute schema dumper.
* | Extract conditional to a method to avoid duplicationRafael Mendonça França2012-06-191-0/+3
| | | | | | | | Also use if/else block to not use short circuit return
* | handle joins/includes correctly for pluck and calculation.Andrey Deryabin2012-06-191-0/+43
| | | | | | | | Fix #5990
* | Merge pull request #6782 from kennyj/db-rake-structure-dumpRafael Mendonça França2012-06-194-1/+106
|\ \ | | | | | | Refactor db:structure:dump task.
| * | Refactor db:structure:dump task.kennyj2012-06-204-1/+106
| | |
* | | Merge pull request #6785 from kennyj/rename_testcase_nameCarlos Antonio da Silva2012-06-191-1/+1
|\ \ \ | | | | | | | | Rename testcase name. It's wrong in the context.
| * | | Rename testcase name. It's wrong in the context.kennyj2012-06-201-1/+1
| |/ /
* / / Rename MySQLTestPurge to MySQLPurgeTest for consistency.kennyj2012-06-201-1/+1
|/ /
* | Refactor db:charset taskSimon Jefford2012-06-194-3/+93
| | | | | | | | | | In a similar vein to Pat's work on create, drop etc, the db:charset task is now a one liner in databases.rake
* | Validates_numericality_of is skipped when changing 0 to to non-empty stringAngelo capilleri2012-06-191-0/+10
| | | | | | | | | | | | | | | | | | | | This happens when A has_many many B and A accepts_nested_attributes B that has a numeric colum with initial 0 value. So a.update_attributes({:b_attributes => { :id => b.id, :numeric => 'foo' }}) passes the validation test but, the value of :numeric doesn't change. his commit forces that the update fails with the above conditions. Fixes #6393 Fixes #2331
* | Remember the stored attributes in a config attribute.Joost Baaij2012-06-181-1/+5
| | | | | | | | | | | | This allows you to retrieve the list of attributes you've defined. Usable for e.g. selects in the view, or interators based on the attributes you wish to store in the serialized column.
* | Merge pull request #6743 from steveklabnik/remove_composed_ofRafael Mendonça França2012-06-185-401/+0
|\ \ | | | | | | | | | Removing composed_of
| * | Removing composed_of from ActiveRecord.Steve Klabnik2012-06-185-401/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature adds a lot of complication to ActiveRecord for dubious value. Let's talk about what it does currently: class Customer < ActiveRecord::Base composed_of :balance, :class_name => "Money", :mapping => %w(balance amount) end Instead, you can do something like this: def balance @balance ||= Money.new(value, currency) end def balance=(balance) self[:value] = balance.value self[:currency] = balance.currency @balance = balance end Since that's fairly easy code to write, and doesn't need anything extra from the framework, if you use composed_of today, you'll have to add accessors/mutators like that. Closes #1436 Closes #2084 Closes #3807
* | | Add ensure Joke.reset_sequence_nameYasuo Honda2012-06-191-0/+2
|/ / | | | | | | | | to avoid ORA-02289: sequence does not exist for `SELECT "BLACK_JOKES_SEQ".NEXTVAL FROM dual`
* | Change minimum (default) log level in PostgreSQL to warning.kennyj2012-06-181-0/+4
| |
* | fix invalid syntax and sqlite rake failing testsFrancesco Rodriguez2012-06-183-4/+6
| |
* | Merge pull request #6761 from freelancing-god/db-rakeJon Leighton2012-06-174-0/+715
|\ \ | | | | | | Get logic out of db rake tasks, and into classes and objects
| * | Rails is the default (but now override able) source for environment and path.Pat Allan2012-06-172-28/+32
| | |
| * | Cleaning up after some warnings, adding slightly higher-level tests.Pat Allan2012-06-172-2/+296
| | |
| * | db:drop and some of db:test:purge.Pat Allan2012-06-173-2/+180
| | |
| * | db:create for PostgreSQL pulled out into a class.Pat Allan2012-06-171-0/+57
| | |
| * | db:create for MySQL now much cleaner.Pat Allan2012-06-171-0/+120
| | |
| * | Confirm connection is not established if file exists.Pat Allan2012-06-171-1/+10
| | |
| * | A beginning of sorts.Pat Allan2012-06-171-0/+53
| | | | | | | | | | | | Minimal implementation that supports db:create SQLite replacement
* | | Fix deprecation warnings when using ↵Jon Leighton2012-06-151-0/+32
| | | | | | | | | | | | config.active_record.mass_assignment_sanitizer=
* | | Fix config.active_record.whitelist_attributes with AR::ModelJon Leighton2012-06-151-0/+27
| | |
* | | Simplify AR configuration code.Jon Leighton2012-06-152-3/+3
| | | | | | | | | | | | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* | | Remove unneded tests.Rafael Mendonça França2012-06-141-11/+1
| | | | | | | | | | | | | | | | | | | | | Before 7f4b0a1231bf3c65db2ad4066da78c3da5ffb01, this test are asserting that update_attribute does the dirty tracking. Since we remove this method and update_column write in the database directly this tests will always fail>
* | | Merge pull request #6713 from etehtsea/activerecord-uuidRafael Mendonça França2012-06-143-6/+22
|\ \ \ | | | | | | | | | | | | Add uuid datatype support to PostgreSQL adapter
| * | | Add uuid type support to PostgreSQL adapterKonstantin Shabanov2012-06-143-6/+22
| | | |