Commit Graph

140 Commits

Author SHA1 Message Date
Erik Peterson
a6d9e16e41 Correctly parse bigint defaults in PostgreSQL, Backpost #10098.
Conflicts:

	activerecord/CHANGELOG.md
	activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
	activerecord/test/cases/schema_dumper_test.rb
2013-04-11 10:11:18 +02:00
Steve Klabnik
ee291b9b41 Revert "Merge pull request #9208 from dylanahsmith/3-2-mysql-quote-numeric"
This reverts commit 921a296a33.
2013-02-26 16:57:18 -08:00
Dylan Smith
04c2d2e2e4 active_record: Quote numeric values compared to string columns. 2013-02-07 05:02:38 -05:00
Yasuo Honda
e8357935ac This pull requests addresses ORA-01400 errors and also supports #6115 issue tested.
Issue #6115 has been fixed and tested with
the attribute `:null => false, :default => ""`
However `:null => false` attribute is not necessary to test this issue,
which causes many ORA-01400 errors with Oracle enhanced adapter.
2013-02-03 15:27:49 +04:00
Piotr Sarnacki
6a0a5f3032 Duplicate column_defaults properly
Backport c517602 to fix #6115

Deleted:
    activerecord/lib/active_record/core.rb

Conflicts:
    activerecord/test/cases/base_test.rb
2013-02-03 15:27:42 +04:00
Ian Lesperance
b6d4931292 Fix pluck when columns/tables are reserved words.
Backport #7536 to fix #8968.

Conflicts:

	activerecord/CHANGELOG.md
	activerecord/lib/active_record/relation/calculations.rb
2013-01-23 15:17:33 +01:00
Rafael Mendonça França
885f59f685 Serialized attribute can be serialized in an integer column
Fix #8575

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/attribute_methods/serialization.rb
	activerecord/test/cases/serialized_attribute_test.rb
	activerecord/test/models/person.rb
2012-12-21 16:04:56 -03:00
Rafael Mendonça França
660882bda4 Make sure the tests pass in the case closer to described in #8195 2012-12-10 17:05:00 -03:00
Carlos Antonio da Silva
26e8cb8809 Use 1.8 hash style in pg specific schema 2012-11-28 10:27:03 -02:00
Rafael Mendonça França
50f00463bd Merge pull request #8276 from pwnall/pgsql_text_limits
Postgresql doesn't accepts limits on text columns
Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
2012-11-20 14:13:45 -02:00
Nick Rogers
05e1466e05 Fix deleting from a HABTM join table upon destroying an object of a model with optimistic locking enabled. Fixes #5332. 2012-11-13 10:36:24 -08: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
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
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
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
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
48601c27b7 Merge pull request #6878 from masarakki/master
fix bug in limit of enum columns of mysql

Closes #6432
2012-06-28 17:24:09 -03:00
Victor Costan
36fdb728c6 Postgresql doesn't accept limits on binary (bytea) columns. 2012-05-21 03:21:32 -04:00
Aaron Patterson
4c44ca5cb9 Test for #5549.
Cherry-picked from e96d04a2e4e244ea5053cb4e8ab97db604d0c796.

Conflicts:

	activerecord/lib/active_record/attribute_methods/read.rb
2012-03-28 15:31:32 +01:00
kennyj
f1f2e8c80b Fix type_to_sql with text and limit on mysql/mysql2. Fix GH #3931. 2012-02-29 01:23:37 +09:00
Rafael Mendonça França
06dcd9c0fb Remove extra attributes from HABTM join tables in AR tests
HABTM Join tables should not have extra attributes

When extra attributes is needed in HABTM join tables is better to use
`has_many :through` association.

Fix #4653
2012-01-26 10:32:10 -02:00
Aaron Patterson
57f73a6bcf Merge pull request #4487 from sarenji/fix-reset-counters
Fix bug where reset_counters resets the wrong counter cache.
2012-01-17 10:23:56 -08:00
Alvaro Bautista
6b9ab88a48 serialize fails on subclass 2011-12-23 18:22:42 +00:00
David Heinemeier Hansson
85b64f98d1 Added ActiveRecord::Base.store for declaring simple single-column key/value stores [DHH] 2011-10-13 16:24:22 -05:00
Joseph Palermo
c90e5ce779 Only use LOWER for mysql case insensitive uniqueness check when column has a case sensitive collation. 2011-10-09 13:14:07 -07:00
Jon Leighton
50d395f96e Raise error when using write_attribute with a non-existent attribute.
Previously we would just silently write the attribute. This can lead to
subtle bugs (for example, see the change in AutosaveAssociation where a
through association would wrongly gain an attribute.

Also, ensuring that we never gain any new attributes after
initialization will allow me to reduce our dependence on method_missing.
2011-09-13 00:01:58 +01:00
Jon Leighton
1712d90050 Fix exception if old and new targets are both nil. Fixes #1471. 2011-07-12 00:14:45 +01:00
José Valim
6917c65f04 Merge pull request #2017 from Casecommons/active_record_lint
ActiveRecord::Base subclasses should pass ActiveModel::Lint.
2011-07-08 18:34:02 -07:00
Grant Hutchins & Peter Jaros
6b9c38c1a8 ActiveRecord::Base should pass ActiveModel::Lint. 2011-07-08 17:51:40 -04:00
Tomas D'Stefano
ea4b94a7bf Destroy association habtm record before destroying the record itself. Fixes issue #402. 2011-07-08 22:26:54 +01:00
Jon Leighton
2033ff825b Merge pull request #560 from guilleiguaran/fix_pluralize_table_names_false
Fixing has_many when ActiveRecord::Base.pluralize_table_names is false
2011-05-16 15:40:12 -07:00
Guillermo Iguaran
ecbde46e57 Fixing has_many association when ActiveRecord::Base.pluralize_table_names is false. fixes #557 2011-05-15 03:53:10 -05:00
Jon Leighton
60b23ea1da CollectionAssociation#merge_target_lists should write to the underlying attributes when copying, rather than using the assignment method 2011-05-14 19:49:22 +01:00
Jon Leighton
a8c1fa4afd Add test to specify that attributes from an association's conditions should be assigned without mass-assignment protection when a record is built on the association. 2011-05-10 23:35:15 +01:00
Christopher Meiklejohn
4fbd8adf48 Don't quote ID's as Arel will quote them -- follow same conventions as the delete method. 2011-05-08 18:37:28 +01:00
Josh Kalderimis
86d7ed3375 singular and collection relations in AR can now specify mass-assignment security options (:as and :without_protection) in build, create and create! methods. 2011-05-01 23:30:07 +02:00
Benjamin Fritsch
714b4a82f4 Added tsvector Datatype Support
Applied Patch from https://rails.lighthouseapp.com/projects/8994/tickets/5577-suport-from-tsvector-data-type-in-postgresql
2011-04-26 09:47:40 +02:00
Aaron Patterson
a0d4c8d1bf using the database adapter to typecast before executing prepared statement 2011-04-14 13:37:39 -07:00
Santiago Pastorino
baa237c974 Allow to read and write AR attributes with non valid identifiers 2011-03-22 20:02:32 -03:00
Jon Leighton
735844db71 Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/association_preload.rb
	activerecord/lib/active_record/associations.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
	activerecord/lib/active_record/associations/has_many_association.rb
	activerecord/lib/active_record/associations/has_many_through_association.rb
	activerecord/lib/active_record/associations/has_one_association.rb
	activerecord/lib/active_record/associations/has_one_through_association.rb
	activerecord/lib/active_record/associations/through_association_scope.rb
	activerecord/lib/active_record/reflection.rb
	activerecord/test/cases/associations/has_many_through_associations_test.rb
	activerecord/test/cases/associations/has_one_through_associations_test.rb
	activerecord/test/cases/reflection_test.rb
	activerecord/test/cases/relations_test.rb
	activerecord/test/fixtures/memberships.yml
	activerecord/test/models/categorization.rb
	activerecord/test/models/category.rb
	activerecord/test/models/member.rb
	activerecord/test/models/reference.rb
	activerecord/test/models/tagging.rb
2011-03-04 09:30:27 +00:00
Franck Verrot
8bc464c809 The optimistic lock column should be increased when calling touch
Signed-off-by: Santiago Pastorino and José Ignacio Costa <santiago+jose@wyeworks.com>
2011-02-09 18:27:40 -02:00
Jan
9643243204 make set_table_name take effect immediately 2011-02-08 10:31:09 -08:00
Jon Leighton
52f09eac5b Correctly update counter caches on deletion for has_many :through [#2824 state:resolved]. Also fixed a bunch of other counter cache bugs in the process, as once I fixed this one others started appearing like nobody's business. 2011-02-07 23:35:05 +00:00
Jon Leighton
05bcb8cecc Support the :dependent option on has_many :through associations. For historical and practical reasons, :delete_all is the default deletion strategy employed by association.delete(*records), despite the fact that the default strategy is :nullify for regular has_many. Also, this only works at all if the source reflection is a belongs_to. For other situations, you should directly modify the through association. 2011-02-07 23:35:05 +00:00
Edward Faulkner
909588d964 Fixing ordering of HABTM association deletion [#6191 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-04 19:39:59 -02:00
Jon Leighton
52c47556b7 Add create_association! for belongs_to 2011-01-16 13:43:53 -08:00
Jon Leighton
3c400627eb Support for :counter_cache on polymorphic belongs_to 2010-12-31 20:00:44 +00:00
Szymon Nowak
85683f2a79 Fix creation of has_many through records with custom primary_key option on belongs_to [#2990 state:resolved] 2010-12-23 15:19:17 -08:00
Jon Leighton
834e5336a5 has_many associations with :dependent => :delete_all should update the counter cache when deleting records 2010-12-20 13:56:04 -08:00