Commit Graph

5047 Commits

Author SHA1 Message Date
Doug Barth
5d870c9291 Don't swallow exceptions in transctional statements
The MySQL connection adapater swallows all StandardError exceptions,
which includes Mysql::Error and Mysql2::Error. The comment in the
exception clause claims errors thrown here indicate that transactions
aren't supported by the server but that isn't necessarily true. It's
possible the MySQL server has gone away and swallowing a failed commit
may let the application return a successful response when the data has
not been saved. Also, replication libraries like Galera require that the
application handle exceptions thrown at BEGIN/COMMIT.

I'm unable to determine what version of MySQL threw an exception for
transactional statements. I tried as far back as 3.23.49 with InnoDB
disabled but BEGIN & COMMIT statements do not throw an error. If there's
a real case for this logic to continue, we could instead push this
behavior into a configuration setting.

The exception swallowing has been there since the beginning:
db045dbbf60b53dbe013ef25554fd013baf88134
2013-11-05 11:47:08 -08:00
Yves Senn
44406d1e77 store enum mapping using Strings instead of Symbols.
This allows to assign both `String` and `Symbol` values to the enum
without having to call `to_sym`, which is a security problem.
2013-11-05 17:44:08 +01:00
Yves Senn
6c720d18a2 direct enum assignment rasies ArgumentError for unknown values. 2013-11-05 17:44:08 +01:00
Yves Senn
813c8c0751 define enum methods inside a Module to make them overwritable. 2013-11-05 16:45:34 +01:00
Rafael Mendonça França
679902b916 Remove private API test 2013-11-05 13:31:31 -02:00
Pablo Torres
6f788b1d91 Use 1.9 Hash syntax consistently 2013-11-05 08:13:37 -05:00
Aaron Patterson
9f8762f1d5 The enum value constant isn't used, so rm it for now. 2013-11-04 15:55:29 -08:00
Yves Senn
37d4bfbfd9 fix copy & paste test-case naming. [ci skip] 2013-11-04 19:22:53 +01:00
Carlos Antonio da Silva
28dea539e1 Convert schema file to ruby 1.9 style hash 2013-11-04 13:32:17 -02:00
Carlos Antonio da Silva
a7f3c6944d Style fixes on test schema file 2013-11-04 13:32:17 -02:00
Carlos Antonio da Silva
92c6305954 Respect cache timestamp format when giving timestamps to #cache_key 2013-11-04 13:11:51 -02:00
David Heinemeier Hansson
c59e902671 Add test verifying that you can only sort ARs of the same type 2013-11-02 20:05:23 -07:00
David Heinemeier Hansson
430b252d3d Revert "ActiveRecord::Base#<=> has been removed. Primary keys may not be in order," -- will be replaced with a check to ensure that the keys used for comparison are integers, and only fail if they are not.
This reverts commit 6256734e2d0bdd89f4b5d11da259d40afa0c95c7.

Conflicts:
	activerecord/CHANGELOG.md
2013-11-02 19:56:58 -07:00
David Heinemeier Hansson
661637e5b6 Delegate #rewhere to all on the class like all other relation methods 2013-11-02 19:45:03 -07:00
David Heinemeier Hansson
0342335473 Merge pull request #12747 from yury/explicit-enum-values
Explicit mapping for enum
2013-11-02 18:29:22 -07:00
Yury Korolev
7caa09c5e1 Explicit mapping for enum 2013-11-02 17:48:16 -07:00
David Heinemeier Hansson
f950b2699f Added ActiveRecord::QueryMethods#rewhere which will overwrite an existing, named where condition. 2013-11-02 17:36:45 -07:00
Rafael Mendonça França
4d7080f80c unscope now works on default_scope after 94924dc32baf78f13e289172534c2e71c9c8cade 2013-11-02 22:11:20 -02:00
David Heinemeier Hansson
09447929a0 Add a test case for the scope enum adds 2013-11-02 16:18:31 -07:00
David Heinemeier Hansson
e94e97ca79 Extend ActiveRecord::Base#cache_key to take an optional list of timestamp attributes of which the highest will be used. 2013-11-02 16:05:19 -07:00
Carlos Antonio da Silva
a2f27385f6 Use an already existing fixture 2013-11-02 18:13:02 -02:00
Carlos Antonio da Silva
6963e8959f Fix to work on Ruby 1.9.3, example and changelog improvements 2013-11-02 18:08:37 -02:00
David Heinemeier Hansson
db41eb8a6e Added ActiveRecord::Base#enum for declaring enum attributes where the values map to integers in the database, but can be queried by name 2013-11-02 12:01:31 -07:00
Rafael Mendonça França
1918b12c04 Fix wrong behavior where associations with dependent: :destroy options
was using nullify strategy

This caused a regression in applications trying to upgrade.

Also if the user set the dependent option as destroy he expects to get
the records removed from the database.
2013-11-01 19:04:30 -02:00
Rafael Mendonça França
a221b30b3f Test with the right association 2013-11-01 14:26:05 -02:00
Arun Agrawal
c10a78124c More Warnings removed for ruby trunk
Same as 4d4ff531b8807ee88a3fc46875c7e76f613956fb
2013-11-01 13:47:23 +01:00
Arun Agrawal
816126862e Warnings removed for ruby trunk
Same as 4d4ff531b8807ee88a3fc46875c7e76f613956fb
2013-11-01 09:49:57 +01:00
Aaron Patterson
1d75efed84 :cut: whitespace 2013-10-30 14:17:54 -07:00
Yves Senn
d0ea5c5b20 fix code typo in MysqlAdapter .Closes #12647. 2013-10-30 18:12:26 +01:00
Jan Bernacki
510601ce8e short arrays in inspect 2013-10-30 08:47:54 +04:00
David Heinemeier Hansson
ab177d8cbe Fix broken delete_all test, which will now be failing since #delete_all is broken 2013-10-28 21:48:02 -07:00
David Heinemeier Hansson
e562ddedba Add failing test for preloading with a polymorphic association and using the existential predicate 2013-10-28 21:26:03 -07:00
Rafael Mendonça França
6fb056e3b6 Merge pull request #12578 from jeradphelps/configurable_schema_migrations_table_name
Configurable name for schema_migrations table

Conflicts:
	activerecord/CHANGELOG.md
2013-10-27 21:07:03 -02:00
Rafael Mendonça França
8a00866099 Assert the return value in the test 2013-10-27 18:11:00 -02:00
Paul Nikitochkin
6b71a1416c Skip include_values from through associations chains for building target scope
Fixes: #12242, #9517, #10240
2013-10-27 21:15:41 +02:00
Jerad Phelps
26638f0ac9 added schema_migrations_table_name to ActiveRecord::Base in order that the name of the schema migrations table can be configured.
consolidated test_schema_migrations_table_name tests

Added changelog entry

edited changelog

removed commented lines

removed reader

ensure the schema migrations table is reset at end of test

added entry to configuration guide

guides typo and changelog order
2013-10-27 08:50:35 -05:00
Yves Senn
dc8fac1cac Merge pull request #12643 from severin/pg_cast_json_on_write
cast json values on write to be consistent with reading from the db.
2013-10-25 08:17:40 -07:00
Severin Schoepke
c3606afb2a cast json values on write to be consistent with reading from the db.
See also commit 5ac2341fab689344991b2a4817bd2bc8b3edac9d
2013-10-25 17:05:42 +02:00
Yves Senn
0e918ea97a prevent time_zone_aware_attributes test leak. follow-up to #12633. 2013-10-25 17:05:41 +02:00
Yves Senn
a0599535aa only warn on leaked time zone state instead of rasing an error.
Raising `RuntimeErrors` skips important cleanup code and leads to
a lot of subsequent errors. This clutters the test output with a lot
of noise.
2013-10-25 15:59:04 +02:00
Yves Senn
2dc579baf4 Merge pull request #12633 from senny/no_more_time_zone_leaks
prevent global timezone state from leaking out of test cases.
2013-10-25 06:10:11 -07:00
Yves Senn
abe91cb3bf prevent global timezone state from leaking out of test cases. 2013-10-25 14:40:57 +02:00
Yves Senn
0492ea6d39 ActiveRecord::Store works together with PG hstore columns.
This is necessary because as of 5ac2341 `hstore` columns are always stored
as `Hash` with `String` keys. `ActiveRecord::Store` expected the attribute to
be an instance of `HashWithIndifferentAccess`, which led to the bug.
2013-10-25 08:35:35 +02:00
Yves Senn
bf43b4c33f stored_attributes need to be specific to a subclass.
Currently they are all stored globally in the same `Hash`.
This commit forces the creation of a per-class variable if necessary.

The behavior was exposed through the following test-case:

```
  1) Failure:
StoreTest#test_all_stored_attributes_are_returned [/Users/senny/Projects/rails/activerecord/test/cases/store_test.rb:151]:
--- expected
+++ actual
@@ -1 +1 @@
-[:color, :homepage, :favorite_food]
+[:resolution, :color, :homepage, :favorite_food]
```
2013-10-25 08:35:35 +02:00
Yves Senn
557b8b6947 test to verify the ActiveRecord::Store behavior with PG's json type 2013-10-25 08:34:59 +02:00
Rafael Mendonça França
7160ffbe59 Merge pull request #12621 from laurocaetano/fix_has_one_association_with_primary_key_set
Save association when primary key is manually set

Conflicts:
	activerecord/CHANGELOG.md
2013-10-24 22:37:29 -02:00
laurocaetano
8022fc4913 Save association when primary key is manually set 2013-10-24 22:30:30 -02:00
Rafael Mendonça França
5ad34a8d8d Fix order dependent tests 2013-10-22 11:35:33 -02:00
Aaron Patterson
8f5647e9c5 Merge branch 'master' into joindep
* master: (23 commits)
  Escape the parentheses in the default function regexp
  Update docs on Tilt::Template in Asset Pipeline guide
  Fix loading a sql structure file on postgres when the file's path has whitespace in it
  remove trailing whitespace added with b057765 [ci skip].
  Allow unscope to work with `where.not`
  Raise an exception when model without primary key calls .find_with_ids
  Process sub-query relation's binding values
  Instrument the generation of Action Mailer messages
  Remove extra variable creation and merge.
  In Relation#empty? use #exists? instead of #count.
  [ci skip] avoid deprecation warning in sample code
  Convert Fixnum into String the port number in MySQL
  Fix some indentation on autosave association
  Make define_non_cyclic_method simpler
  Add Sass gobbling info to asset pipeline docs
  Ensure the state is clean after one failure
  Fix typo in form_helper.rb
  add a new local variable to track if digests are being stored, to ensure the cleanup works correctly
  [ci skip] Fix number of methods added by association.
  update digestor code based on review
  ...
2013-10-21 14:59:14 -07:00
Rafael Mendonça França
b98c10c164 Merge pull request #12588 from jetthoughts/12586_subquery_with_unprepared_sql
Inline bind values for sub-queries generated for Relation in where

Conflicts:
	activerecord/CHANGELOG.md
2013-10-21 19:13:04 -02:00