Commit Graph

4599 Commits

Author SHA1 Message Date
Rafael Mendonça França
c56e6204db Merge pull request #9876 from macksmind/restore_cols_dropped_by_hstore_test
Restore columns dropped by hstore test
2013-03-26 13:39:03 -07:00
Mack Earnhardt
524ce560ff Combine tests and restore columns dropped by hstore testing
Disabling the hstore extension during testing created order dependent
test failures.
2013-03-26 16:15:07 -04:00
Rafael Mendonça França
17077639c2 Merge pull request #9928 from vipulnsward/fix_rename_auto_increment_mysql
respect auto_increment in rename_column for mysql
2013-03-26 11:55:12 -07:00
Vipul A M
437961b558 respect auto_increment in rename_column for mysql 2013-03-27 00:15:59 +05:30
Dan McClain
203e0e0e4a Checks :algorithm argument for valid values 2013-03-26 10:14:15 -04:00
Dan McClain
e199dc1a57 Adds support for concurrent indexing in PostgreSQL adapter
Adds support for algorithm option in MySQL indexes
Moves USING and algorithm options upstream

The syntax is still specific to the Adapter, so the actual executed string happens
in the corresponding adapter
2013-03-25 17:56:38 -04:00
Martin Schürrer
336b376728 Make Postgres point type correspond to ruby array with two floats inside 2013-03-25 19:29:52 +01:00
Ranjay Krishna
c2e2031732 Created a layer of abstraction for the valid type checking in schema dumper. Now, connection handles the check for valid types so that each database can handle the changes individually. 2013-03-25 09:35:22 -07:00
Rafael Mendonça França
ba012fa04d Merge pull request #9864 from vipulnsward/fix_test_AR_v2
Introduce test on Error#full_message for attribute with underscores; Fix...
2013-03-25 08:56:29 -07:00
Jeremy Kemper
558f320446 Merge pull request #9489 from obrie/fix/overridden_defaults_changed_attributes
Fix ActiveRecord locking column defaults not getting persisted
2013-03-24 15:42:50 -07:00
Rafael Mendonça França
e96fa8987b Merge branch 'jlxw-patch-2'
Closes #9184
2013-03-23 19:06:04 -03:00
jlxw
2c9304891e Fix regex to strip quotations from hstore values
Previously regex did not strip quotation marks where hstore values were multi-line strings.
2013-03-23 19:00:37 -03:00
Rafael Mendonça França
31388fa792 Merge pull request #9891 from doabit/additional_index_support
Custom index type support with :using.

Closes #9451
2013-03-23 14:37:16 -07:00
doabit
8094156728 Custom index type support with :using. 2013-03-24 05:09:54 +08:00
Neeraj Singh
36a45230da enhance unscoped tests
Make it obvious that using unscoped with another scope
without the block works
2013-03-23 16:01:26 -04:00
Aaron Patterson
7a872e9d84 Merge branch 'schema'
* schema:
  add uuid primary key support
  separate primary key from column type
  push the mysql add_column up to the abstract adapter
  allow multiple add columns
  pull add_column_options! off the pg connection class
  add a pg visitor for dealing with schema modification
  push alter table add column sql in to the schema modification visitor
  there is no reason to check for an already defined column
  push column initialization down to the factory method
  @columns list is no longer necessary
  keep ivars private, do not manipulate them outside their owner object
  factory methods should not alter object state
  push SQL generation inside the schema creation object
  mostly decouple TableDefinition from the database connection
  remove to_sql from TableDefinition
  decouple column definition from the database connection
  stop depending on sql_type in pg
  remove knowledge of SQL from the column definition object
2013-03-22 19:41:29 -07:00
Aaron Patterson
db3a6e6a7f squelch an unused variable warning 2013-03-22 19:41:13 -07:00
Aaron Patterson
bc8ebefe98 add uuid primary key support 2013-03-22 19:30:24 -07:00
Aaron Patterson
cd07f194dc decouple column definition from the database connection 2013-03-22 16:21:59 -07:00
Aaron Patterson
69ef76a6f8 remove knowledge of SQL from the column definition object 2013-03-22 16:21:59 -07:00
Carlos Antonio da Silva
d24fb610fe Merge pull request #9866 from choudhuryanupam/fix_connection_test
Removed unused loop variable
2013-03-22 07:57:31 -07:00
Carlos Antonio da Silva
39c26bcace Merge pull request #9867 from choudhuryanupam/fix_mysql2_active_schema_test
Removed unnecessary block
2013-03-22 07:51:11 -07:00
Yves Senn
22a819a2c2 test-case to prevent resetting associations when preloading twice.
Conflicts:

	activerecord/lib/active_record/associations/preloader/through_association.rb
	activerecord/test/cases/associations/eager_test.rb
2013-03-22 15:18:18 +01:00
Dmitry Vorotilin
89828a4052 When we pass id to update_attributes it will try to set new id for that record 2013-03-22 17:57:34 +04:00
Anupam Choudhury
c9890731f8 Removed unnecessary block 2013-03-22 18:14:46 +05:30
Jon Leighton
79c02e849b Delete failing test
I don't think this is testing anything useful, and the test code is
exceedingly brittle. It is broken since
34c7e73c1def1312e59ef1f334586ff2f668246e because the test code makes
assumptions about the implementation of PostgreSQLAdapter#active? which
are incorrect after the commit.

I could fix this test but it would be even more brittle (by stubbing the
underlying @connection.connect_poll) and it doesn't test any complex
logic. I conclude that it's not worth it.
2013-03-22 11:55:17 +00:00
Vipul A M
24fee97581 Add Error#full_message test; Fix typos
Introduce test on Error#full_message for attribute with underscores; Fix
some typos
2013-03-22 14:53:32 +05:30
Anupam Choudhury
ae41ca80b5 Removed unused loop variable 2013-03-22 14:21:46 +05:30
Alexander Murmann and Can Berk Güder
018fc5fc07 Allows setting fixture_path to a Pathname 2013-03-21 14:10:44 -07:00
Rafael Mendonça França
b1b9de3d96 Merge pull request #9847 from vipulnsward/fix_sqlite_test
Fix copy table index test; Change == to ! on false in travis.rb
2013-03-21 05:30:25 -07:00
Vipul A M
5b673f3d46 Fix copy table index test; Change == to ! on false in travis.rb 2013-03-21 10:57:52 +05:30
Ian Young
66679c8ecd Update other counter caches on destroy 2013-03-20 13:43:07 -07:00
Anupam Choudhury
5f7c3515ee Removed unnecessary block 2013-03-20 21:02:21 +05:30
Vipul A M
abd89f96cd Fix some typos in AR- CHANGELOG, tests, method doc. fixed 2013-03-20 11:17:01 +05:30
Josh Adams
9a62711c41 Commas aren't comas.
Type a fixo.
2013-03-19 21:12:44 -05:00
wangjohn
840ca09a11 Calling find() on an association with an inverse will now check to see
if the association already holds that record in memory before checking
the database for the specified ids.
2013-03-19 16:33:49 -04:00
wangjohn
3ee30ca44a The repair_validations helper was not working correctly before because
it only cleared the validations that created :validate callbacks. This
didn't include the validates created by validates_with, so I've added a
method to clear all validations.
2013-03-19 12:23:20 -04:00
Aaron Pfeifer
a240e526a8 Fix ActiveRecord locking column defaults not getting persisted
When partial inserts are enabled, overridden db defaults are ignored. This
results in locking columns having a nil value for new records if the db default
is null. This happens because the list of changed attributes for new records is
always assumed to be empty.

Solution: When a new record's default attributes are set, also initialize the
list of changed attributes by comparing current values against what's stored as
the column defaults in the database.
2013-03-18 22:09:01 -04:00
Carlos Antonio da Silva
4620bdcefd Fix failing tests related to where values change to strings
Introduced in 5dc2e3531babcbdc165884d1a47cbcd13455522d.
2013-03-18 17:58:59 -03:00
Rafael Mendonça França
8621b69917 Merge pull request #9782 from vipulnsward/change_from_each_to_each_key_habtm
Change from each to each_value;drop assignment in habtm
2013-03-18 13:04:38 -07:00
Krzysztof Jurewicz
72de894651 Use define_method when method name contains weird characters. 2013-03-18 21:01:04 +01:00
Vipul A M
aee54249dd 1. Change from each to each_value since we did not use key
2. drop assignment of value to sum in test
2013-03-19 01:15:25 +05:30
Steve Klabnik
bfdd3c2182 Merge pull request #9778 from vipulnsward/fix_typos_in_ar_v1
fix typos in AR. lots of them.
2013-03-18 11:40:00 -07:00
Vipul A M
55686dd1be fix typos in AR. lots of them. 2013-03-19 00:04:39 +05:30
Aaron Patterson
2392535f40 Merge branch 'master-sec'
* master-sec:
  fix protocol checking in sanitization [CVE-2013-1857]
  JDOM XXE Protection [CVE-2013-1856]
  fix incorrect ^$ usage leading to XSS in sanitize_css [CVE-2013-1855]
  stop calling to_sym when building arel nodes [CVE-2013-1854]
2013-03-18 10:17:32 -07:00
Carlos Antonio da Silva
2ce4af485a Merge pull request #9766 from senny/remove_ancient_todos
Remove ancient TODOs [ci skip]
2013-03-18 08:43:38 -07:00
Yves Senn
85261a5e96 remove ancient TODOs [ci skip]. 2013-03-18 16:42:08 +01:00
Takehiro Adachi
4666108c68 move tests out from base_test.rb
These tests should be in inheritance_test.rb since its testing a
feature which is implemented in inheritance.rb
2013-03-18 15:45:39 +09:00
Yves Senn
274e966a6a rake db:create does not change permissions of root user.
Closes #8079.

I had to rework some of the tests because the mock allowed any arguments
for `connection.exeucte`. I think this is very dangerous as there could
anything be executed without the tests noticing it.
2013-03-17 20:34:04 +01:00
Xavier Noria
8744632fb5 sets limit 191 for schema_migrations#version in mysql2 if the encoding is "utf8mb4"
Please, see rationale in the included CHANGELOG patch.
2013-03-17 20:29:58 +01:00
Mack Earnhardt
1d6eabb677 Refactor Person/Friendship relationships to be more intuitive
PR #5210 added a Friendship model to illustrate a bug, but in doing so
created a confusing structure because both belongs_to declarations in
Friendship referred to the same side of the join. The new structure
maintains the integrity of the bug test while changing the follower
relationship to be more useful for other testing.
2013-03-17 02:11:19 -04:00
John Wang
455d710242 If a counter_cache is defined, then using update_attributes and changing
the primary key on an association will make sure that the corresponding
counter on the association is changed properly. Fixes #9722.
2013-03-15 21:28:28 -04:00
Aaron Patterson
5dc2e3531b stop calling to_sym when building arel nodes [CVE-2013-1854] 2013-03-15 17:45:10 -07:00
Carlos Antonio da Silva
a662a7894b Fix implicit join references option reversion in test 2013-03-15 14:17:59 -03:00
Jon Leighton
5558bb0d65 Merge pull request #9733 from senny/9712_option_to_turn_references_deprecation_off
make it possible to disable implicit join references.
2013-03-15 08:12:09 -07:00
Yves Senn
34402c7623 make it possible to disable implicit join references.
Closes #9712.
2013-03-15 16:07:05 +01:00
Jon Leighton
133a1759a4 Cache the association proxy object
This reimplements the behaviour of Rails 3, as I couldn't see why we
shouldn't cache the object, and @alindeman had a good use case for
caching it:

c86a32d745 (commitcomment-2784312)
2013-03-15 13:48:45 +00:00
Jon Leighton
0721d3b370 Merge pull request #9683 from senny/deprecate_count_distinct_option
rename `Relation#uniq` to `Relation#distinct`
2013-03-15 06:21:53 -07:00
Yves Senn
cd87c85ef0 Deprecate the :distinct option for Relation#count.
We moved more and more away from passing options to finder / calculation
methods. The `:distinct` option in `#count` was one of the remaining places.
Since we can now combine `Relation#distinct` with `Relation#count` the option
is no longer necessary and can be deprecated.
2013-03-15 14:15:47 +01:00
Yves Senn
a1bb6c8b06 rename Relation#uniq to Relation#distinct. #uniq still works.
The similarity of `Relation#uniq` to `Array#uniq` is confusing. Since our
Relation API is close to SQL terms I renamed `#uniq` to `#distinct`.

There is no deprecation. `#uniq` and `#uniq!` are aliases and will continue
to work. I also updated the documentation to promote the use of `#distinct`.
2013-03-15 14:15:47 +01:00
Jon Leighton
962604f424 Merge pull request #9686 from strzalek/cast_number_to_string_in_pg
Cast number to string in Postgres
2013-03-15 05:50:17 -07:00
Yves Senn
b601399b72 #reset_counters verifies counter names.
Closes #9724.

Raise an `ArgumentError` when the name of the counter does not
match an association name.
2013-03-15 11:22:01 +01:00
Aaron Patterson
8d3e5c8c52 hide more data in the schema cache 2013-03-14 22:45:46 -07:00
Aaron Patterson
a0dfd84440 safely publish columns and columns hash info 2013-03-14 22:45:46 -07:00
Aaron Patterson
d758794371 you can provide uuid_generate_v4 as the default value for uuid columns 2013-03-14 18:21:00 -07:00
Adam Gamble
8fccbc1ad4 Modifies belong_to touch callback to touch old associations also #9091 2013-03-14 12:46:50 -05:00
PikachuEXE
7fc339059c + Add test for auto timestamps update of both old & new parent records 2013-03-14 12:45:56 -05:00
Vipul A M
d338a0feaf MOAR cleanups. 2013-03-14 10:47:13 +05:30
Łukasz Strzałkowski
aae89ee860 Cast number to string in Postgres
fixes #9170
2013-03-12 16:13:01 +01:00
Matthew M. Boedicker
d3e5118e7d Pass column to quote when copying a sqlite table.
To make quote escape binary data correctly it needs the column passed in.
2013-03-11 23:14:46 -07:00
Takehiro Adachi
8b80311e5f add an missing assertion to inheritance_test.rb
assertion for
https://github.com/rails/rails/blob/ad624345e54bd20802de67b2b5c9ef29ecf5
d5f4/activerecord/lib/active_record/inheritance.rb#L32
2013-03-11 20:27:13 +09:00
Yasuo Honda
5571e833f2 Address ActiveRecord::StatementInvalid: OCIError: ORA-00979 2013-03-11 03:37:04 +09:00
Carlos Antonio da Silva
6e5ab6fccb Change uniq validation with conditions examples to use where with hashes
Take the opportunity to showcase where.not.
2013-03-09 19:21:33 -03:00
Yves Senn
ad1a24f0e0 Uniqueness validation uses a proc to specify the :conditions option.
This is a follow up to #5321 and follows the general direction in
AR to make things lazy evaluated.
2013-03-09 23:09:00 +01:00
Ben Moss
992d87db02 Deprecate #connection in favour of accessing it via the class
This allows end-users to have a `connection` method on their models
without clashing with ActiveRecord internals.
2013-03-09 15:16:15 -05:00
OZAWA Sakuro
c3a26c592c Preserve magic comments and content encoding of copied migrations.
During insertion of "# This migration comes from ... " comment at the beginning of
a migration, presence of magic comment was not considered.
2013-03-09 15:38:02 +09:00
Rafael Mendonça França
74d24ea1fe Merge pull request #9497 from route/subclass_from_attrs
Fix ActiveRecord `subclass_from_attrs` when eager_load is false.

Conflicts:
	activerecord/CHANGELOG.md
2013-03-08 11:59:29 -03:00
Anupam Choudhury
1231eb80c8 Refactored test case with standard variable naming 2013-03-08 19:45:20 +05:30
Rafael Mendonça França
ba6b3c165f Merge pull request #8868 from tehgeekmeister/master
Use the index name explicitly provided in a migration when reverting.

Fixes #8868

Conflicts:
	activerecord/CHANGELOG.md
2013-03-08 10:35:16 -03:00
Rafael Mendonça França
22f31214a0 Merge pull request #8966 from cfabianski/disable_prepared_statement_when_preparing_a_query
Unprepared Visitor + unprepared_statement

Conflicts:
	activerecord/CHANGELOG.md
2013-03-08 10:19:58 -03:00
Carlos Antonio da Silva
9588924440 Update test name to reflect change in how scopes merging works
Introduced in f1082b8588a9144eedb34d511f0074031f692d98.
Full changelog in 9f007d7fe5f90257c71baa2c4e7c76fb44512986.

[ci skip]
2013-03-08 09:34:33 -03:00
Cédric FABIANSKI
9f549212c3 Unprepared Visitor + unprepared_statement 2013-03-08 09:14:31 +01:00
Ezekiel Smithburg
b6226c3cfb If an index can't be found by column, use the index name.
schema_statements uses the column name by default to construct the index name, and then raises an exception if it doesn't exist, even if the name option is specified, which causes #8858.  this commit makes index_name_for_remove fall back to constructing the index name to remove based on the name option.
2013-03-07 20:03:17 -08:00
Neeraj Singh and John Leighton
cd26b6ae7c Combine scope conditions using AND
Currently Post.active.inactive will result in Post.inactive since
the last where clause wins when scopes are merged.

This pull request will merge all scopes ( barring defaul scope)
using AND.

The default scope will be overridden if another scope acts on the
same where clause.

closes #7365
2013-03-07 18:57:27 -05:00
Rafael Mendonça França
c6839277a9 Merge pull request #9597 from senny/9110_serialized_not_null_default
test case for `serialize` default values.
2013-03-07 08:31:14 -08:00
Rafael Mendonça França
2e3e171e31 Merge pull request #9105 from bemurphy/cache_key_updated_on
cache_key consults updated_on timestamp if present

Conflicts:
	activerecord/CHANGELOG.md
2013-03-07 13:28:46 -03:00
Yves Senn
fa18c61153 test case for serialize default values.
Closes #9110
2013-03-07 17:26:35 +01:00
Rafael Mendonça França
d3adfd6d3b Merge pull request #9474 from HonoreDB/master
More helpful error message when instantiating an abstract class

Conflicts:
	activerecord/CHANGELOG.md
2013-03-07 13:26:03 -03:00
Anupam Choudhury
f15d9bd116 Refactored and removed unnecessary lines in the test case 2013-03-07 20:42:38 +05:30
Rafael Mendonça França
173e0e086f Remove regression test added in 0268b5d8cdc3c5a1337462135f0a326a2654ba1a
It was added because a regression caused by a712e08ebe21f6d8653a0e6602df2e0f5d40d9ca

Closes #9255
2013-03-07 11:02:49 -03:00
Yves Senn
0a5fdcd5ae rake db:structure:dump warns when mysqldump is not in PATH.
Closes #9518.

The rake task used to fail silently and left an empty `structure.sql`.
It's confusing for users to get to the root of the problem.
The warning message tells them where to look.
2013-03-06 15:12:48 +01:00
Yves Senn
854b74242c Connection#structure_dump is no longer used. #9518
As of ccc6910c we use `mysqldump` to create the `structure.sql`.
The old `#structure_dump` code is still in AR but never used.

I removed all relevant parts from the code-base.
2013-03-06 15:12:20 +01:00
Rafael Mendonça França
4ce9843251 Merge pull request #9507 from senny/9483_migrations_without_transactions
Transactions can be turned off per Migration
2013-03-06 06:05:47 -08:00
Dmitry Vorotilin
b04051d4e0 Fix ActiveRecord subclass_from_attrs when eager_load is false.
It cannot find subclass because all classes are loaded automatically
when it needs.
2013-03-06 11:46:07 +04:00
kennyj
e9fc2d3397 Remove unused return value, because collecting_queries_for_explain isn't public API. 2013-03-06 00:35:55 +09:00
Yves Senn
b337390889 transactions can be turned off per Migration.
Closes #9483.

There are SQL Queries that can't run inside a transaction. Since
the Migrator used to wrap all Migrations inside a transaction there
was no way to run these queries within a migration.

This patch adds `self.disable_ddl_transaction!` to the migration to
turn transactions off when necessary.
2013-03-05 16:12:08 +01:00
Yves Senn
f1241ef959 transactional migration test-case was broken.
The cleanup commit a85625d broke the test-case.
The schema was no longer modified so there was no
way to check that the rollback actually happened.
2013-03-05 14:15:50 +01:00
Yves Senn
4b7a33e142 assigning '0.0' to a nullable numeric column does not make it dirty 2013-03-05 14:00:41 +01:00
Yves Senn
8c7d4018e0 ActiveRecord::Base.include_root_in_json is false by default.
Closes #9459.

The PR #6597 unified the configuration for `include_root_in_json`
in AM and AR to `false`.
Later on with the refactoring commit: e030f26 the value in AR was
set to `true` but I think this was not on purpose.

With this commit both AM and AR will have the same configuration
for `include_root_in_json`, which is `false`.
2013-03-04 21:18:40 +01:00
Yves Senn
eeba679470 rewrite tests to have no side-effects on include_root_in_json. 2013-03-04 21:18:40 +01:00
wangjohn
293875457b Created an unscope method for removing relations from a chain of
relations. Specific where values can be unscoped, and the unscope method
still works when relations are merged or combined.
2013-03-03 20:42:01 -05:00
Aaron Weiner
53f18f2c54 More helpful error message when instantiating an abstract class
Calling a literal ActiveRecord::Base.new raises NoMethodError,
since it ends up calling Class.abstract_class? which does not exist.
Similarly, instantiating an actual abstract class hits the database,
when conventionally it should immediately throw NotImplementedError.

ActiveRecord::Base can't be made abstract without breaking many,
many things, so check for it separately.
2013-03-03 12:36:51 -05:00
Andrew White
c09f934dcb Merge pull request #9431 from troyk/patch-2
Fix PostgreSQL TIMESTAMP WITH TIME ZONE to return ActiveSupport::Time
2013-03-02 10:03:04 +00:00
Yves Senn
b9399c470b deal with #append and #prepend on association collections.
Closes #7364.

Collection associations behave similar to Arrays. However there is no
way to prepend records. And to append one should use `<<`. Before this
patch `#append` and `#prepend` did not add the record to the loaded
association.

`#append` now behaves like `<<` and `#prepend` is not defined.
2013-03-01 21:29:46 +01:00
Troy Kruthoff
2cc09441c2 Fix PostgreSQL TIMESTAMP WITH TIME ZONE to return ActiveSupport::Time
In an AR model a timestamptz attribute would return a ruby string and AR
tests did not check for any type casting.  Previous tests would pass
only because an assert_equal was being used on a Time.utc object, which
will parse the right side of the eq to a valid Time instance for
comparision.

switch to test instance of Time instead of ActiveSupport::TimeWithZone
2013-03-01 09:51:23 -08:00
kennyj
e2a4b7a506 Wrong exception is occured when raising no translatable exception 2013-03-01 02:47:57 +09:00
Yves Senn
5d0ca74622 Support PostgreSQL specific column types when using change_table.
Closes #9480.

We use `TableDefinition` for `#create_table` and `Table` for `#change_table`.
The PostgreSQL sepcifc types were only defined on `TableDefinition` so I
also added them to `Table`.
2013-02-28 13:42:30 +01:00
Steve Klabnik
afd4a14332 Revert "Merge pull request #9207 from dylanahsmith/mysql-quote-numeric"
This reverts commit 408227d9c5ed7de26310d72a1a99c1ee02311c63, reversing
changes made to dca0b57d03deffc933763482e615c3cf0b9a1d97.
2013-02-27 08:46:40 -08:00
Erik Peterson
72a4670af1 Fix default output for postgres network address types 2013-02-26 14:26:53 -05:00
Olek Janiszewski
dce4383319 Fix touching an invalid parent record for belongs_to
If the parent of a `belongs_to` record fails to be saved due to
validation errors, `touch` will be called on a new record, which causes
an exception (see https://github.com/rails/rails/pull/9320).

Example:

    class Owner < ActiveRecord::Base
      validates_presence_of :name
    end

    class Pet < ActiveRecord::Base
      belongs_to :owner, touch: true
    end

    pet = Pet.new(owner: Owner.new)

    # Before, this line would raise ActiveRecord::ActiveRecordError
    # "can not touch on a new record object"
    pet.save
2013-02-26 18:46:10 +01:00
Rafael Mendonça França
8bc5e714f4 Merge pull request #9414 from senny/9275_order_with_symbol_and_join
Expand order(:symbol) to "table".symbol to prevent broken queries on PG.
2013-02-26 05:15:14 -08:00
Brendon Murphy
1dc98c143c cache_key consults updated_on timestamp if present
- Extract max timestamp retrieval for cache_key
- Update changelog for cache_key changes
2013-02-26 00:04:05 -08:00
Yves Senn
e035699085 Expand order(:symbol) to "table".symbol to prevent broken queries on PG.
Fixes #9275.

When `#order` is called with a Symbol this patch will prepend the quoted_table_name.
Before the postgresql adapter failed to build queries containg a join and an order
with a symbol.

This expansion happens for all adapters.
2013-02-25 18:00:34 +01:00
Hiroshige Umino
ec9aa3ca89 Do not override attributes on dup by default scopes 2013-02-26 00:30:49 +09:00
Rafael Mendonça França
fa8a78d12e ✂️ 2013-02-25 10:18:55 -03:00
Aaron Patterson
45321a69b3 Merge pull request #9246 from Noemj/update_prepared_statements
Changed update to use prepared statements
2013-02-24 22:16:52 -08:00
wangjohn
e52ff80960 Raising an ActiveRecordError when one tries to use .touch(name) on a new
object that has not yet been persisted. This behavior follows the
precedent set by update_columns.
2013-02-25 00:29:28 -05:00
Rafael Mendonça França
70ec7e0245 Remove warning 2013-02-24 18:22:23 -03:00
Yves Senn
4ef75b63db don't apply invalid ordering when preloading hmt associations.
closes #8663.

When preloading a hmt association there two possible scenarios:

1.) preload with 2 queries: first hm association, then hmt with id IN ()
2.) preload with join: hmt association is loaded with a join on the hm association

The bug was happening in scenario 1.) with a normal order clause on the hmt association.
The ordering was also applied when loading the hm association, which resulted in the error.

This patch only applies the ordering the the hm-relation if we are performing a join (2).
Otherwise the order will only appear in the second query (1).
2013-02-24 20:51:39 +01:00
Xavier Noria
d65376fce4 Merge pull request #9400 from senny/remove_auto_explain_threshold_in_seconds
remove config.auto_explain_threshold_in_seconds
2013-02-24 11:16:35 -08:00
Yves Senn
d3688e02ca remove AR auto-explain (config.auto_explain_threshold_in_seconds)
We discussed that the auto explain feature is rarely used.
This PR removes only the automatic explain. You can still display
the explain output for any given relation using `ActiveRecord::Relation#explain`.

As a side-effect this should also fix the connection problem during
asset compilation (#9385). The auto explain initializer in the `ActiveRecord::Railtie`
forced a connection.
2013-02-24 20:01:04 +01:00
Rafael Mendonça França
d5ec8efdaf Skip connection url test when the machine is using socket configuration.
The connection url parssing don't accept the socket option
2013-02-24 14:36:18 -03:00
Rafael Mendonça França
e54acf1308 Do not type cast all the database url values.
We should only type cast when we need to use.

Related to 4b005fb371c2e7af80df7da63be94509b1db038c
2013-02-24 14:36:18 -03:00
Steve Klabnik
c3d001b048 Merge pull request #9356 from senny/988_multiple_actions_for_after_commit
multiple actions for :on option with `after_commit` and `after_rollback`
2013-02-24 08:30:48 -08:00
Yves Senn
96c1cafd3a test case to prevent duplicated associations with custom PK.
closes #9201
2013-02-24 16:49:47 +01:00
Yasuo Honda
6fad6b5e5c Oracle enhanced adapter shortens its name if it is longer than 30 bytes
because of Oracle database index length spec.
2013-02-24 12:11:34 +09:00
Yves Senn
e7f0716eee also rename the test-case class inside columns_test.rb 2013-02-24 02:26:01 +01:00
Yves Senn
d03928c81a rename_column_test.rb -> columns_test.rb to reveal intent.
I renamed the test to better communicate it's intention. Since it also tests:
  - add_column
  - remove_column
  - change_column
There is no reason to call it rename_column_test.
2013-02-23 15:42:55 +01:00
Yves Senn
2d4e3fecc2 forwardport #9388 rename/remove column preserves custom PK. 2013-02-23 15:40:07 +01:00
Yves Senn
d98763a602 multiple actions for :on option with after_commit and after_rollback
Closes #988.
2013-02-21 15:02:52 +01:00
Rafael Mendonça França
6614471173 Fix warning 2013-02-21 00:51:39 -03:00
Rafael Mendonça França
d3563bd661 Skip failing test and add a FIXME note 2013-02-20 14:32:11 -03:00
Yves Senn
39eef1a565 also rename indexes when a table or column is renamed
When a table or a column is renamed related indexes kept their name. This will lead to confusing names. This patch renames related indexes when a column or a table is renamed. Only indexes with names generated by rails will be renamed. Indexes with custom names will not be renamed.
2013-02-20 18:19:25 +01:00
Yves Senn
cca43528d4 reserve index name chars for internal rails operations
Some adapter (SQLite3) need to perform renaming operations to support
the rails DDL. These rename prefixes operate with prefixes. When an
index name already uses up the full space provieded by
`index_name_length` these internal operations will fail. This patch
introduces `allowed_index_name_length` which respects the amount of
characters used for internal operations. It will always be <=
`index_name_length` and every adapter can define how many characters
need to be reserved.
2013-02-20 17:50:10 +01:00
Rafael Mendonça França
7bae72c69f Merge pull request #9332 from wangjohn/adding_documentation_to_error_raising_in_query_methods
Tests to make sure empty arguments in WhereChain raise errors
2013-02-20 08:38:50 -08:00
wangjohn
d49f862b9a Added comments about the check_empty_arguments method which is called
for query methods in a where_clause. Also, modified the CHANGELOG entry
because it had false information and added tests.
2013-02-20 10:53:25 -05:00
wangjohn
67d8bb963d Reduced memory leak problem in transactions by lazily updating AR objects with new transaction state. If AR object has a callback, the callback will be performed immediately (non-lazily) so the transaction still has to keep records with callbacks. 2013-02-20 10:51:28 -05:00
Rafael Mendonça França
e1456ad95e Whitespace ❤️ and hash syntax change 2013-02-20 10:27:18 -03:00
Yves Senn
0a6b61a5f5 descriptive error message when AR adapter was not found. Closes #7313. 2013-02-20 10:54:58 +01:00
Takehiro Adachi
679777849b delete duplicated tests in AR base_test.rb
These are duplicated with the tests which are in relations_test.rb
2013-02-19 21:38:25 +09:00
Takehiro Adachi
2db91fb546 add tests for ActiveRecord::Base#create 2013-02-18 02:12:08 +09:00
Jon Leighton
c65b076328 Revert "checking in the abstractions for valid type checking:"
This reverts commit c321b309a9a90bbfa0912832c11b3fef52e71840.

Conflicts:
	activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
	activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb

Reason: failing test

  1) Error:
test_valid_column(ActiveRecord::ConnectionAdapters::SQLite3AdapterTest):
NoMethodError: undefined method `column' for
    test/cases/adapters/sqlite3/sqlite3_adapter_test.rb:29:in
`test_valid_column'
2013-02-15 16:23:25 +00:00
Yves Senn
4a4ff50459 don't cache invalid subsets when preloading hmt associations.
closes #8423.
2013-02-14 17:46:07 +01:00
James Miller
caabed6c76 Don't call after_commit when creating through an association and save fails, fixes #5802 2013-02-13 12:27:06 -08:00
Aaron Patterson
f8c8ad56c8 Merge pull request #9204 from ranjaykrishna/col-prob
schema dumper tests now conducted by ActiveRecord::Base.Connection
2013-02-12 13:26:40 -08:00
Ranjay Krishna
c321b309a9 checking in the abstractions for valid type checking: 2013-02-12 02:10:48 -05:00
Aaron Patterson
0268b5d8cd test for regression from a712e08ebe21f6d8653a0e6602df2e0f5d40d9ca 2013-02-11 18:36:46 -08:00
Sergey Nartimov
9dfef5a46b define Active Record Store accessors in a module
Allow store accessors to be overrided like other attribute methods,
e.g.:

    class User < ActiveRecord::Base
      store :settings, accessors: [ :color, :homepage ], coder: JSON

      def color
        super || 'red'
      end
    end
2013-02-11 17:00:55 +03:00
Noemj
a53935dfa0 Changed update_record to use prepared statements. 2013-02-11 15:17:06 +02:00
Aaron Patterson
cdd293cb96 fixing bit string test 2013-02-10 22:50:13 -08:00