Jason Meller
03855e790d
Ensure AR #second, #third, etc. finders work through associations
...
This commit fixes two regressions introduced in cafe31a078
where
newly created finder methods #second, #third, #forth, and #fifth
caused a NoMethodError error on reload associations and where we
were pulling the wrong element out of cached associations.
Examples:
some_book.authors.reload.second
# Before
# => NoMethodError: undefined method 'first' for nil:NilClass
# After
# => #<Author id: 2, name: "Sally Second", ...>
some_book.first.authors.first
some_book.first.authors.second
# Before
# => #<Author id: 1, name: "Freddy First", ...>
# => #<Author id: 1, name: "Freddy First", ...>
# After
# => #<Author id: 1, name: "Freddy First", ...>
# => #<Author id: 2, name: "Sally Second", ...>
Fixes #13783 .
2014-01-21 19:35:27 -05:00
Yves Senn
9f494a9a34
test cleanup, remove ruby_type because it's no longer needed
...
All tests with a custom inheritance_column use the `Vegtable` model.
The field ruby_type on the Company models is no longer needed
2012-09-03 20:38:14 +02:00
Jon Leighton
e8ada11aac
Associations: DRY up the code which is generating conditions, and make it all use arel rather than SQL strings
2010-12-26 19:38:04 +00:00
Jon Leighton
f2230c06ed
Fix dodgy tests which were effectively asserting nil == nil
2010-12-26 19:38:04 +00:00
Aaron Patterson
5b918bb97c
using arel to compile sql statements
2010-12-25 16:19:59 -07:00
Santiago Pastorino
b451de0d6d
Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;)
2010-08-14 04:12:33 -03:00
Pratik Naik
45e6f19925
Revert "Revert "Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [ #2118 state:resolved]""
...
This reverts commit 80f1f863cd
.
The feature doesn't work on Postgres, so don't test it on Postgres.
Also, Postgres compatibility is irrelevant to the ticket/patch in question.
2009-07-01 00:02:00 +01:00
Yehuda Katz + Carl Lerche
80f1f863cd
Revert "Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [ #2118 state:resolved]"
...
This reverts commit 4851ca9e13
.
The tests do not pass for postgresql.
2009-06-22 12:04:02 -07:00
Patrick Joyce
4851ca9e13
Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [ #2118 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-06-21 22:07:23 +01:00
Andre Arko
3351d29970
Add has_many :primary_key option to allow setting the primary key on a has many association
...
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-07-06 20:25:10 +02:00
Jeremy Kemper
3704088ebd
has_one supports the :dependent => :delete option which skips the typical callback chain and deletes the associated object directly from the database. Closes #5927 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4848 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-08-29 17:06:27 +00:00
Tobias Lütke
13fccff283
modified finder test a tiny bit so that it passes on sqlserver
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2657 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-16 20:50:06 +00:00
Tobias Lütke
7086993161
Adds :nullify option to :depends. Closes #2015 (Robby Russell)
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2595 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-15 00:46:55 +00:00
Jamis Buck
37a370d8d4
Be sure to use the @finder_sql in the has_many association's #find method, even if explicit conditions have not been given.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1412 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-06-13 12:03:33 +00:00
David Heinemeier Hansson
daf3e92a31
Added a db2 adapter that only depends on the Ruby/DB2 bindings ( http://raa.ruby-lang.org/project/ruby-db2/ ) #386 [Maik Schmidt]. Converted all the fixtures to YAML style ones.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@303 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-01-01 19:22:16 +00:00