Commit Graph

4385 Commits

Author SHA1 Message Date
Yves Senn
e035699085 Expand order(:symbol) to "table".symbol to prevent broken queries on PG.
Fixes #9275.

When `#order` is called with a Symbol this patch will prepend the quoted_table_name.
Before the postgresql adapter failed to build queries containg a join and an order
with a symbol.

This expansion happens for all adapters.
2013-02-25 18:00:34 +01:00
Aaron Patterson
45321a69b3 Merge pull request #9246 from Noemj/update_prepared_statements
Changed update to use prepared statements
2013-02-24 22:16:52 -08:00
wangjohn
e52ff80960 Raising an ActiveRecordError when one tries to use .touch(name) on a new
object that has not yet been persisted. This behavior follows the
precedent set by update_columns.
2013-02-25 00:29:28 -05:00
Rafael Mendonça França
70ec7e0245 Remove warning 2013-02-24 18:22:23 -03:00
Yves Senn
4ef75b63db don't apply invalid ordering when preloading hmt associations.
closes #8663.

When preloading a hmt association there two possible scenarios:

1.) preload with 2 queries: first hm association, then hmt with id IN ()
2.) preload with join: hmt association is loaded with a join on the hm association

The bug was happening in scenario 1.) with a normal order clause on the hmt association.
The ordering was also applied when loading the hm association, which resulted in the error.

This patch only applies the ordering the the hm-relation if we are performing a join (2).
Otherwise the order will only appear in the second query (1).
2013-02-24 20:51:39 +01:00
Xavier Noria
d65376fce4 Merge pull request #9400 from senny/remove_auto_explain_threshold_in_seconds
remove config.auto_explain_threshold_in_seconds
2013-02-24 11:16:35 -08:00
Yves Senn
d3688e02ca remove AR auto-explain (config.auto_explain_threshold_in_seconds)
We discussed that the auto explain feature is rarely used.
This PR removes only the automatic explain. You can still display
the explain output for any given relation using `ActiveRecord::Relation#explain`.

As a side-effect this should also fix the connection problem during
asset compilation (#9385). The auto explain initializer in the `ActiveRecord::Railtie`
forced a connection.
2013-02-24 20:01:04 +01:00
Rafael Mendonça França
d5ec8efdaf Skip connection url test when the machine is using socket configuration.
The connection url parssing don't accept the socket option
2013-02-24 14:36:18 -03:00
Rafael Mendonça França
e54acf1308 Do not type cast all the database url values.
We should only type cast when we need to use.

Related to 4b005fb371c2e7af80df7da63be94509b1db038c
2013-02-24 14:36:18 -03:00
Steve Klabnik
c3d001b048 Merge pull request #9356 from senny/988_multiple_actions_for_after_commit
multiple actions for :on option with `after_commit` and `after_rollback`
2013-02-24 08:30:48 -08:00
Yves Senn
96c1cafd3a test case to prevent duplicated associations with custom PK.
closes #9201
2013-02-24 16:49:47 +01:00
Yasuo Honda
6fad6b5e5c Oracle enhanced adapter shortens its name if it is longer than 30 bytes
because of Oracle database index length spec.
2013-02-24 12:11:34 +09:00
Yves Senn
e7f0716eee also rename the test-case class inside columns_test.rb 2013-02-24 02:26:01 +01:00
Yves Senn
d03928c81a rename_column_test.rb -> columns_test.rb to reveal intent.
I renamed the test to better communicate it's intention. Since it also tests:
  - add_column
  - remove_column
  - change_column
There is no reason to call it rename_column_test.
2013-02-23 15:42:55 +01:00
Yves Senn
2d4e3fecc2 forwardport #9388 rename/remove column preserves custom PK. 2013-02-23 15:40:07 +01:00
Yves Senn
d98763a602 multiple actions for :on option with after_commit and after_rollback
Closes #988.
2013-02-21 15:02:52 +01:00
Rafael Mendonça França
6614471173 Fix warning 2013-02-21 00:51:39 -03:00
Rafael Mendonça França
d3563bd661 Skip failing test and add a FIXME note 2013-02-20 14:32:11 -03:00
Yves Senn
39eef1a565 also rename indexes when a table or column is renamed
When a table or a column is renamed related indexes kept their name. This will lead to confusing names. This patch renames related indexes when a column or a table is renamed. Only indexes with names generated by rails will be renamed. Indexes with custom names will not be renamed.
2013-02-20 18:19:25 +01:00
Yves Senn
cca43528d4 reserve index name chars for internal rails operations
Some adapter (SQLite3) need to perform renaming operations to support
the rails DDL. These rename prefixes operate with prefixes. When an
index name already uses up the full space provieded by
`index_name_length` these internal operations will fail. This patch
introduces `allowed_index_name_length` which respects the amount of
characters used for internal operations. It will always be <=
`index_name_length` and every adapter can define how many characters
need to be reserved.
2013-02-20 17:50:10 +01:00
Rafael Mendonça França
7bae72c69f Merge pull request #9332 from wangjohn/adding_documentation_to_error_raising_in_query_methods
Tests to make sure empty arguments in WhereChain raise errors
2013-02-20 08:38:50 -08:00
wangjohn
d49f862b9a Added comments about the check_empty_arguments method which is called
for query methods in a where_clause. Also, modified the CHANGELOG entry
because it had false information and added tests.
2013-02-20 10:53:25 -05:00
wangjohn
67d8bb963d Reduced memory leak problem in transactions by lazily updating AR objects with new transaction state. If AR object has a callback, the callback will be performed immediately (non-lazily) so the transaction still has to keep records with callbacks. 2013-02-20 10:51:28 -05:00
Rafael Mendonça França
e1456ad95e Whitespace ❤️ and hash syntax change 2013-02-20 10:27:18 -03:00
Yves Senn
0a6b61a5f5 descriptive error message when AR adapter was not found. Closes #7313. 2013-02-20 10:54:58 +01:00
Takehiro Adachi
679777849b delete duplicated tests in AR base_test.rb
These are duplicated with the tests which are in relations_test.rb
2013-02-19 21:38:25 +09:00
Takehiro Adachi
2db91fb546 add tests for ActiveRecord::Base#create 2013-02-18 02:12:08 +09:00
Jon Leighton
c65b076328 Revert "checking in the abstractions for valid type checking:"
This reverts commit c321b309a9a90bbfa0912832c11b3fef52e71840.

Conflicts:
	activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
	activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb

Reason: failing test

  1) Error:
test_valid_column(ActiveRecord::ConnectionAdapters::SQLite3AdapterTest):
NoMethodError: undefined method `column' for
    test/cases/adapters/sqlite3/sqlite3_adapter_test.rb:29:in
`test_valid_column'
2013-02-15 16:23:25 +00:00
Yves Senn
4a4ff50459 don't cache invalid subsets when preloading hmt associations.
closes #8423.
2013-02-14 17:46:07 +01:00
James Miller
caabed6c76 Don't call after_commit when creating through an association and save fails, fixes #5802 2013-02-13 12:27:06 -08:00
Aaron Patterson
f8c8ad56c8 Merge pull request #9204 from ranjaykrishna/col-prob
schema dumper tests now conducted by ActiveRecord::Base.Connection
2013-02-12 13:26:40 -08:00
Ranjay Krishna
c321b309a9 checking in the abstractions for valid type checking: 2013-02-12 02:10:48 -05:00
Aaron Patterson
0268b5d8cd test for regression from a712e08ebe21f6d8653a0e6602df2e0f5d40d9ca 2013-02-11 18:36:46 -08:00
Sergey Nartimov
9dfef5a46b define Active Record Store accessors in a module
Allow store accessors to be overrided like other attribute methods,
e.g.:

    class User < ActiveRecord::Base
      store :settings, accessors: [ :color, :homepage ], coder: JSON

      def color
        super || 'red'
      end
    end
2013-02-11 17:00:55 +03:00
Noemj
a53935dfa0 Changed update_record to use prepared statements. 2013-02-11 15:17:06 +02:00
Aaron Patterson
cdd293cb96 fixing bit string test 2013-02-10 22:50:13 -08:00
Guillermo Iguaran
29f3a036e7 Reverting e170014113 (Change behaviour with empty hash in where clause) 2013-02-08 16:53:49 -05:00
Guillermo Iguaran
fa987cb8ec Reverting 16f6f25 (Change behaviour with empty array in where clause) 2013-02-08 14:22:10 -05:00
robertomiranda
16f6f2592e Change behaviour with empty array in where clause 2013-02-08 06:37:30 -05:00
robertomiranda
e170014113 Change behaviour with empty hash in where clause 2013-02-08 01:04:32 -05:00
Guillermo Iguaran
408227d9c5 Merge pull request #9207 from dylanahsmith/mysql-quote-numeric
active_record: Quote numeric values compared to string columns.
2013-02-07 12:16:53 -08:00
Carlos Antonio da Silva
dca0b57d03 Skip schema dumper extensions test if connection does not support it
Travis failed because the postgresql version installed there does not
support extensions, so we just need to skip this for now.
2013-02-07 08:33:35 -02:00
Dylan Smith
a712e08ebe active_record: Quote numeric values compared to string columns. 2013-02-07 04:59:33 -05:00
Carlos Antonio da Silva
1b75666f7f Run schema dumper extensions without creating real extensions
There is no need to create the extension in the database just to test if
it's dumped, we can stub that instead.
2013-02-06 23:03:48 -02:00
Carlos Antonio da Silva
86f4db97aa Do not print anything related to extensions when they don't none exist
When extensions are supported but there's no one enabled in the
database, we should not print anything related to them in schema.rb.
2013-02-06 22:57:10 -02:00
Justin George
e2fdfa9c07 improve tests to check for existence of extensions method, and skip testing dumped extensions if they are unsupported by the database 2013-02-06 16:01:25 -08:00
Justin George
c0990f040f Add some tests to enumerate how extensions should be stored in the schema output 2013-02-06 16:01:25 -08:00
Rafael Mendonça França
b713f1b3cc Enable hstore extensions on tests if it is not enabled and database supports it 2013-02-05 17:47:50 -02:00
Aaron Stone
4b005fb371 DATABASE_URL parsing should turn numeric strings into numeric types, and
the strings true and false into boolean types, in order to match how
YAML would parse the same values from database.yml and prevent
unexpected type errors in the database adapters.
2013-01-31 09:01:20 -08:00
Carlos Antonio da Silva
18e889f91b Merge pull request #9119 from dazuma/database_tasks_for_unknown_adapter
Raise an exception with a useful message if a rake task is requested for an unknown adapter
2013-01-31 03:22:31 -08:00