Andrés Mejía
84dad446c6
Adding first_or_create, first_or_create!, first_or_new and first_or_build to Active Record.
...
This let's you write things like:
User.where(:first_name => "Scarlett").first_or_create!(:last_name => "Johansson", :hot => true)
Related to #2420 .
2011-08-30 16:33:37 -05:00
Jon Leighton
bd4bd3f50a
Merge pull request #2750 from rsim/fix_test_column_names_are_escaped_for_oracle
...
Fix test column names are escaped for oracle
2011-08-30 11:04:01 -07:00
Aaron Patterson
cebff6d0f7
Merge pull request #2021 from dasch/more_postgres_utils
...
Make #extract_schema_and_table an instance method in Utils
2011-08-29 13:38:10 -07:00
Jon Leighton
735d985b01
The join_nodes must be passed to the JoinDependency initializer and therefore counted by the alias tracker. This is because the association_joins are aliased on initialization and then the tables are cached, so it is no use to alias the join_nodes later. Fixes #2556 .
2011-08-29 15:05:47 +01:00
Jon Leighton
5766539342
Create an AbstractMysqlAdapter to abstract the common code between MysqlAdapter and Mysql2Adapter.
2011-08-29 12:43:39 +01:00
Aaron Patterson
d63688d9e6
fixing typo
2011-08-28 16:31:13 -07:00
Aaron Patterson
b4ff82a791
clear and disable query cache when an exception is raised from called middleware
2011-08-28 14:16:00 -07:00
Aaron Patterson
42a7979cf1
Force binary data inserted for a string data type to utf-8 and log an
...
error. Strings tagged as binary will be stored in sqlite3 as blobs. It
is an error to insert binary data to a string column, so an error is
emitted in the log file. People are highly encouraged to track down the
source of the binary strings and make sure that the encoding is set
correctly before inserting to the database.
2011-08-25 16:07:54 -07:00
Akira Matsuda
0a0da9d554
do not compute table names for abstract classes
2011-08-24 21:11:15 +09:00
Ernie Miller
f74f5f7f00
Fix PredicateBuilder clobbering select_values in subquery.
2011-08-20 13:16:39 -04:00
Ernie Miller
e2ae015952
Fix assumption of primary key name in PredicateBuilder subquery.
2011-08-20 13:00:26 -04:00
Aaron Patterson
8a39f411dc
prevent sql injection attacks by escaping quotes in column names
2011-08-16 15:24:42 -07:00
Santiago Pastorino
c6e57467a6
Revert "Merge pull request #2543 from htanata/unused_require_in_ar_test"
...
This reverts commit 87152f2604e73b218df90befda576f0acfed0bbf, reversing
changes made to 0d3615f04c79f6e90d8ab33fdfc920b8faac9cb8.
2011-08-16 09:24:49 -03:00
Hendy Tanata
21e2eeacff
Remove unused require.
2011-08-16 12:40:57 +08:00
Jon Leighton
43b99f290a
Support for multi-table updates with limits, offsets and orders
2011-08-15 23:10:15 +01:00
Jon Leighton
128d006242
Support updates with joins. Fixes #522 .
2011-08-15 23:10:15 +01:00
Jon Leighton
57423d815b
Ensure empty has_many :through association preloaded via joins is marked as loaded. Fixes #2054 .
2011-08-15 16:01:01 +01:00
Jon Leighton
24f902b1bc
Fix default scope thread safety. Thanks @thedarkone for reporting.
2011-08-13 16:54:05 +01:00
José Valim
291072a64a
Merge pull request #2514 from myronmarston/fix_active_record_observer_disabling
...
Allow ActiveRecord observers to be disabled.
2011-08-13 08:40:13 -07:00
Jon Leighton
34689c40a0
Work around for lolruby bug. (Read on for explanation.)
...
We were experiencing CI test failures, for example:
* 3-1-stable: http://travis-ci.org/#!/rails/rails/builds/79473/L407
* master: http://travis-ci.org/#!/rails/rails/builds/79507/L80
These failures only happened on 1.8.7-p352, and we were only able to
reproduce on the Travis CI VM worker. We even tried creating a new 32
bit Ubuntu VM and running the tests on that, and it all worked fine.
After some epic trial and error, we discovered that replacing the
following:
fuu = Marshal.load(Marshal.dump(fuu))
with:
marshalled = Marshal.dump(fuu)
fuu = Marshal.load(marshalled)
seemed to prevent the failure.
We have NO IDEA why this is. If anyone has some great insight to
contribute then that is welcome. Otherwise, hopefully this will just
help us get the CI green again.
Many thanks to @joshk for help with sorting this out.
2011-08-13 13:54:54 +01:00
Myron Marston
d3c15a1d31
Allow ActiveRecord observers to be disabled.
...
We have to use Observer#update rather than Observer#send since the enabled state is checked in #update before forwarding the method call on.
2011-08-12 20:48:44 -07:00
Jon Leighton
9062b75bb7
Fully marshal AR::Base objects. Fixes #2431 .
2011-08-08 23:28:49 +01:00
Jon Leighton
7db90aa7c7
Make it the responsibility of the connection to hold onto an ARel visitor for generating SQL. This improves the code architecture generally, and solves some problems with marshalling. Adapter authors please take note: you now need to define an Adapter.visitor_for method, but it degrades gracefully with a deprecation warning for now.
2011-08-08 23:28:23 +01:00
Raimonds Simanovskis
58af0d46cf
Fixed test_disable_referential_integrity on Oracle
...
On Oracle disable_referential_integrity before execution of block will disable foreign key constraints and after block will enable them but when constraints are enabled then they are validated. Therefore created record with invalid foreign key should be deleted before enabling foreign key constraints.
2011-08-08 22:32:26 +03:00
Santiago Pastorino
1b676fc760
Revert "to_key on a destroyed model should return nil". Closes #2440
...
This reverts commit c5448721b5054b8a467958d60427fdee15eac604.
2011-08-05 19:39:19 -03:00
Santiago Pastorino
e0a6ec2149
Fix test for Rubinius
2011-08-05 16:48:46 -03:00
Aaron Patterson
5a05207d99
pg does not allow aliases in the having clause, but functions are fine
2011-08-05 11:20:15 -07:00
Jon Leighton
f000d4e5fa
Quote these dates to prevent intermittent test failure. Suppose local time is 00:50 GMT+1. Without the quoting, the YAML parser would parse this as 00:50 UTC, into the local time of 01:50 GMT+1. Then, it would get written into the database in local time as 01:50. When it came back out the UTC date from the database and the UTC date of two weeks ago would be compared. The former would be 23:50, and the latter would be 00:50, so the two dates would differ, causing the assertion to fail. Quoting it prevents the YAML parser from getting involved.
2011-08-04 00:38:27 +01:00
Christopher Meiklejohn
43fc814074
Ensure that .up and .down work as well.
2011-08-02 18:57:34 -07:00
Christopher Meiklejohn
74d7bfb200
Support backwards compatible interface for migration down/up with rails 3.0.x.
2011-08-02 18:55:59 -07:00
Vishnu Atrai
624c4571fd
remove extra require for 'stringio' as it is required in helper.rb
2011-07-31 18:05:05 +05:30
José Valim
779d78d591
Merge pull request #2358 from arunagw/test_fix_187_skip
...
skiping magic comment test for < 1.9
2011-07-31 04:25:25 -07:00
Arun Agrawal
329409decd
magic comment test only if encoding_aware?.
2011-07-30 23:46:26 +05:30
Brian Cardarella
e7330f3d4f
Resolve warnings by instantizing @attrubtes as nil
2011-07-30 12:08:26 -04:00
Aaron Patterson
3d6e187255
dump IO encoding value along with schema.rb so the file can be reloaded. fixes #1592
2011-07-29 12:23:37 -07:00
Jon Leighton
971a74b81f
Revert "Merge pull request #2309 from smasry/master"
...
This reverts commit 9d396ee8195e31f646e0b89158ed96f4db4ab38f, reversing
changes made to fa2bfd832c1d1e997d93c2269a485cc74782c86d.
Reason: the change broke the build.
2011-07-28 13:14:11 +01:00
Samer Masry
18d307ed94
Reverse order fix when using function for ActiveRecord::QueryMethods Fixes #1697
2011-07-27 10:17:25 -07:00
Dmitriy Kiriyenko
9a298a162c
Fixed failing query when performing calculation with having based on select.
2011-07-27 16:48:15 +03:00
Jon Leighton
24f0a872e6
Add a proxy_association method to association proxies, which can be called by association extensions to access information about the association. This replaces proxy_owner etc with proxy_association.owner.
2011-07-27 12:36:00 +01:00
Vishnu Atrai
1e69f0b84a
remove deprication warning: ambiguous first argument; put parentheses or even spaces
2011-07-26 23:39:17 +05:30
Piotr Sarnacki
14c6fca9cd
Revert "allow select to have multiple arguments"
...
This reverts commit 04cc446d178653d362510e79a22db5300d463161.
I reverted it because apparently we want to use: select([:a, :b])
instead of select(:a, :b), but there was no tests for that form.
2011-07-26 16:15:12 +02:00
Piotr Sarnacki
89f3d8a886
Merge pull request #2271 from slawosz/enhance_select_method_api
...
allow select to have multiple arguments ie. Post.select(:id,:name,:author)
2011-07-26 06:33:54 -07:00
Sławosz Sławiński
04cc446d17
allow select to have multiple arguments
2011-07-26 14:57:47 +02:00
Franck Verrot
41902e6932
Simplify the test by using id and name. id
will be the only real sort criteria in any case as it's unique.
2011-07-26 11:36:18 +02:00
Santiago Pastorino
64affc9384
Merge pull request #2236 from cldwalker/after_initialize
...
Fix after_initialize and Base.create edge case
2011-07-25 07:20:38 -07:00
thedarkone
10863580aa
Bring back the ability to provide :order for update_all.
2011-07-25 13:33:44 +02:00
Aaron Patterson
02691d3516
Merge pull request #2238 from cesario/order-with-extra-spaces
...
Ordering with extra spaces was raising a SQL exception
2011-07-24 14:40:15 -07:00
Gabriel Horner
f5e4d13270
use existing model for testing Base.create with #after_initialize
2011-07-24 16:36:06 -04:00
Xavier Noria
4bb0a8bcbd
Merge branch 'master' of git://github.com/lifo/docrails
2011-07-24 21:02:51 +02:00
Oemuer Oezkir
71d18ce48e
Changed a few instances of of words in the API docs written in British English to
...
American English(according to Weber)
2011-07-24 10:21:42 +00:00