Commit Graph

3573 Commits

Author SHA1 Message Date
Rafael Mendonça França
721cf54ee7 Fix the skip code.
Checking for the constant doesn't work
2012-10-28 23:47:20 -02:00
Rafael Mendonça França
a119dd3775 Merge pull request #7593 from veader/patch-1
Decode attributes pulled from URI.parse
Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/connection_adapters/connection_specification.rb
2012-10-28 23:47:16 -02:00
Aaron Patterson
f7c2a81141 frozen state should be restored after txn is aborted 2012-10-22 16:55:57 -07:00
Santiago Pastorino
9a38e73c63 Merge pull request #7371 from csmuc/fix_dup_validation_errors
Dup'ed ActiveRecord objects may not share the errors object
Conflicts:
	activerecord/CHANGELOG.md
	activerecord/test/cases/dup_test.rb
2012-10-17 22:39:48 -03:00
Arturo Pie
3980465f26 #7914 get default value when type uses schema name
PostgreSQL adapter properly parses default values when using multiple
schemas and domains.

When using domains across schemas, PostgresSQL prefixes the type of the
default value with the name of the schema where that type (or domain) is.

For example, this query:
```
SELECT a.attname, d.adsrc
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = "defaults"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum;
```

could return something like "'<default_value>'::pg_catalog.text" or
"(''<default_value>'::pg_catalog.text)::text" for the text columns with
defaults.

I modified the regexp used to parse this value so that it ignores
anything between ':: and \b(?:character varying|bpchar|text), and it
allows to have optional parens like in the above second example.
2012-10-14 01:07:29 -04:00
Ernie Miller
990a938cf7 Fix has_many assocation w/select load after create
If you create a new record via a collection association proxy that has
not loaded its target, and which selects additional attributes through
the association, then when the proxy loads its target, it will
inadvertently trigger a deprecation notice during attribute writing when
CollectionAssociation#merge_target_lists attempts to do its thing, since
the newly loaded records will possess attributes the created record does
not.
2012-10-12 16:21:56 -04:00
Rafael Mendonça França
de360ac565 Merge pull request #7850 from senny/5920_postgres_adapter_table_with_capital_letters
postgres, quote table names when fetching the primary key (#5920)
Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
2012-10-06 16:39:29 -03:00
Rafael Mendonça França
98967293cf Merge pull request #6978 from frodsan/count_nosql_unsaved_parent
Count returns 0 without querying if parent is not saved
2012-10-04 13:34:38 -03:00
Rafael Mendonça França
3f0bc97912 Merge pull request #7822 from lulalala/reset-counter-cache-for-has-many-through
Fix reset_counters crashing on has_many :through associations.
Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/counter_cache.rb
2012-10-02 15:58:49 -03:00
Evan Petrie
8dbf337e0a backport 68677ffb8298105eb9d3efa26d928dd88cc5e006 2012-09-28 14:19:31 -07:00
Jonathan Rochkind
39087068c2 ConnectionPool accepts spec key 'checkout_timeout'
Backport of #6441 cb6f83935 . Old 'wait_timeout' is still supported,
but conflicts with mysql2 using that spec key for different thing.
'checkout_timeout' can now be used taking precedence for ConnectionPool
over 'wait_timeout'.
2012-09-24 16:20:22 -04:00
Aaron Patterson
b8fba557e1 Merge pull request #3544 from amatsuda/_field_changed
Rename field_changed? to _field_changed? so that users can create a field named field
Conflicts:

	activerecord/lib/active_record/core.rb
	activerecord/test/cases/dirty_test.rb
2012-09-21 15:36:23 +03:00
Rafael Mendonça França
e4018a00fd Revert "backport fair connection pool 02b2335563 to 3-2-stable"
This reverts commit 0693e07970.

Revert "Cache columns metadata to avoid extra while testing"

This reverts commit a82f1e3f5d.

Reason: This is causing failures in the postgresql build.
See http://travis-ci.org/#!/rails/rails/builds/2485584

Related with #7675
2012-09-20 19:06:20 -03:00
Rafael Mendonça França
a82f1e3f5d Cache columns metadata to avoid extra while testing 2012-09-18 22:24:45 -03:00
Chris Barton
4325bec1d4 Making test accurately reflect what is going on in the schema migrations test 2012-09-18 13:15:02 -07:00
Jonathan Rochkind
0693e07970 backport fair connection pool 02b2335563 to 3-2-stable 2012-09-17 18:04:04 -04:00
Rafael Mendonça França
ee43989575 Merge pull request #7661 from ernie/build-join-records-on-unsaved-hmt
Fix collection= on hm:t join models when unsaved
2012-09-17 10:46:19 -03:00
Rafael Mendonça França
07c8055dc0 Merge pull request #7666 from kennyj/fix_9fa3f102813eeeec440abd75870dfa7b23835665
Fix warning: method redefine. Testcase name are duplicated.
2012-09-17 10:05:55 -03:00
Rafael Mendonça França
8432d03460 Merge pull request #7651 from steveklabnik/issue_3956
Don't preserve SELECT columns on COUNT

Closes #7651

Conflicts:
	activerecord/test/cases/associations/has_many_associations_test.rb
2012-09-16 23:31:35 -03:00
Rafael Mendonça França
6abe0e7b4e Backport explain fixes.
* Mark as SCHEMA some schema database queries. #7648
* Don't explain queries except normal CRUD sql. #7657

Closes #6458
Closes #7544
2012-09-16 22:18:11 -03:00
Rafael Mendonça França
dbfdd00e38 skip in Ruby 1.8 doesn't skip the test case without return 2012-09-13 22:26:08 -03:00
Steve Jorgensen
f48bb016a7 Backport PostgreSQL auto-reconnect test coverage
6d5f4de4c420ebb906109668f5702a537ac77692
Simulated & actual (manual/skipped) PostgreSQL auto-reconnection tests.

4b1bca04025a66c54e6e9d5eb6e4d4056bfa92f0
Stop being silly with formatting of method aliasing.

c381d5cbf959208adeb38e7859ee815dfbd2cf54
Fix just-plain-wrongness of psql auto-reconnect test.

1e17a9d367c54c680368be72f44247ae28b98904
Fix only-once stub logic.

f16c2043826ec1991cf94fe17cb671507b7a7f51
Changelog for PostgreSQL auto-reconnect test coverage backport.
2012-09-13 14:57:59 -07:00
Rafael Mendonça França
924ad60151 Merge pull request #7582 from tchandy/fix_type_cast_code
type_cast_code should always convert values to integer calling #to_i
2012-09-09 13:19:39 -07:00
Thiago Pradi
652107e2e1 ConnectionAdapters::Column.type_cast_code should always convert values to integer calling #to_i 2012-09-09 16:23:52 -03:00
Carlos Antonio da Silva
77dd3be503 Fix AR tests due to builder change with nil values / empty strings
Check 0180e090ab6cbe66f7b521a0c03e278a0463accd for more reasoning about
that.
2012-09-07 13:43:55 -03:00
Rafael Mendonça França
5054e266ac Merge pull request #7337 from adzap/string_to_dummy_time
Fix for time type columns with invalid time value
Conflicts:
	activerecord/CHANGELOG.md
2012-09-05 10:47:52 -03:00
Yves Senn
01d09a6079 set the configured #inheritance_column on #become (#7503)
I had to create a new table because I needed an STI table,
which does not have both a "type" and a "custom_type"

the test fails with:
  1) Error:
test_alt_becomes_works_with_sti(InheritanceTest):
NoMethodError: undefined method `type=' for #<Cabbage id: 1, name: "my cucumber", custom_type: "Cucumber">
    /Users/username/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:432:in `method_missing'
    /Users/username/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:100:in `method_missing'
    /Users/username/Projects/rails/activerecord/lib/active_record/persistence.rb:165:in `becomes'
    test/cases/inheritance_test.rb:134:in `test_becomes_works_with_sti'
    test/cases/inheritance_test.rb:140:in `test_alt_becomes_works_with_sti'

Conflicts:

	activerecord/test/cases/inheritance_test.rb
2012-09-03 16:35:38 +02:00
Pratik Naik
58d35f6211 Ensure association preloading properly merges default scope and association conditions
Conflicts:

	activerecord/test/models/reader.rb
2012-08-28 12:57:41 -07:00
Carlos Antonio da Silva
d5fe242d2a Use Ruby 1.8 hash syntax
Introduced in backport 648c5a1369.
2012-08-21 17:23:08 -03:00
Rafael Mendonça França
015cac7553 Use a model without counter cache to test read-only attributes 2012-08-21 15:57:24 -03:00
Rafael Mendonça França
648c5a1369 Merge pull request #5210 from Pliny/masteri
Fix for #5200

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/counter_cache.rb
2012-08-21 14:36:04 -03:00
Rafael Mendonça França
8905c1fb49 Merge pull request #6986 from kennyj/fix_6975
Fix #6975. Round usec when writing timestamp attribute.

Conflicts:
	activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
2012-08-21 10:36:01 -03:00
Carlos Antonio da Silva
fdf4eae506 Merge pull request #7377 from brainopia/use_inversed_parent_for_first_and_last_child
Use inversed parent for first and last child of has_many association

[Backport] Closes #3223.

Conflicts:
	activerecord/lib/active_record/associations/collection_association.rb
2012-08-21 01:00:14 -03:00
Joe Rafaniello
066ecf0037 Table#remove passed an array to remove_column, which is deprecated.
See 02ca9151a0
2012-08-18 11:21:10 -04:00
Rafael Mendonça França
d6dbd7fbbc Merge pull request #7352 from aripollak/microsecond-timestamp
Fix occasional microsecond conversion inaccuracy
Conflicts:
	activerecord/CHANGELOG.md
2012-08-17 14:47:40 -03:00
Rafael Mendonça França
8055cd6568 Do not use update_column where update_attribute is not interchangeable
Revert "Deprecate update_attribute."

This reverts commit b081f6b59f.

Reason: Since the new deprecation policy we removed the deprecation of
update_attribute but we didn't reverted the changes to use
update_column.

Fixes #7306
2012-08-15 11:58:41 -03:00
Rafael Mendonça França
786713a3ab Merge pull request #6073 from daveyeu/restore-state-on-record-invalid
Restore state on create when ActiveRecord::RecordInvalid is raised
Conflicts:
	activerecord/CHANGELOG.md
2012-08-11 23:24:47 -03:00
Rafael Mendonça França
2e00074380 Merge pull request #7286 from kennyj/fix_7191
Fix #7191. Remove unnecessary transaction when assigning has_one associations.
Conflicts:
	activerecord/test/cases/associations/has_one_associations_test.rb
2012-08-10 15:05:02 -03:00
Jeremy Walker
af6dfdb1f3 Backport #7173. 2012-08-09 13:57:44 -03:00
Jeremy Walker
2a6039a810 Ported PR #4856 to 3-2-stable. 2012-08-09 12:44:59 +01:00
Rafael Mendonça França
99f622de23 Do not consider the numeric attribute as changed if the old value is
zero and the new value is not a string.

Before this commit this was the behavior

r = Review.find_by_issue(0)
r.issue
=> 0
r.changes
=> {}
r.issue = 0
=> 0
r.changed?
=> true
r.changes
=> {"issue"=>[0,0]}

Fixes #7237
2012-08-02 14:11:51 -03:00
kennyj
f137c2b838 Backport #5168 to 3-2-stable. Fix a problem that NULLS is ignored by postgresql_adapter.rb while creating distincts. 2012-08-02 23:31:46 +09:00
Rafael Mendonça França
736bf14d7c Revert "Deprecating composed_of in ActiveRecord"
This reverts commit 44b313bc4e.
2012-08-01 15:09:56 -03:00
Jon Leighton
0c52702630 Revert "Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql."
This reverts commit a79bfa92e7.

Conflicts:
	activerecord/CHANGELOG.md

We shouldn't introducing deprecations in point releases.
It will be deprecated in 4.0 instead.
2012-08-01 19:13:55 +01:00
Rafael Mendonça França
2f930df518 Revert "Add update_columns and the suggestion of using update_columns
instead of update_column"

This reverts commit 9fa06c3d98.

This reverts commit 17a64de498.

This reverts commit def9c85ffb, reversing
changes made to 6b7d26cf3c.

Reason: This was supposed to be released with 3.2.7 before the
suggestion to use update_column. Since it was not release now is not
good to suggest to use another method because it will confusing the
people.
2012-07-30 10:16:28 -03:00
Carlos Antonio da Silva
17a64de498 Fix AR#update_columns tests on Ruby 1.8.7 2012-07-25 22:43:21 -03:00
Sebastian Martinez
f27a8eb71a New #update_columns method. 2012-07-26 11:42:31 +12:00
Jon Leighton
a79bfa92e7 Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql. 2012-07-20 17:59:27 +01:00
Carlos Antonio da Silva
b16e7ed58e Merge pull request #6616 from dpassage/fix_resolver_test_sqlite3
Resolver tests fail if mysql adapter not installed
2012-07-19 21:15:55 -03:00
John Firebaugh
9b5309fb68 AR::Integration must be included after AM::Conversion
Integration's definition of #to_param must override
Conversion's. Otherwise, there is a regression from
3.1 in the behavior of a non-persisted AR::Base instance
which nevertheless has an id.
2012-07-17 13:57:30 -07:00