Commit Graph

13381 Commits

Author SHA1 Message Date
Godfrey Chan
53f3803b52 Partially revert ae33aea
Using enum names in SQL strings doesn't actually work, the test was wrong (fixed
in 3dfd1ba).
2015-02-13 16:50:08 -08:00
Godfrey Chan
58adda3477 Break up these tests
Make sure we have coverage for both the find/build cases
2015-02-13 16:46:52 -08:00
Godfrey Chan
3dfd1bab6a oops, 'format' is not a real enum 2015-02-13 16:40:43 -08:00
Godfrey Chan
91f431972b Enums mapping is a HWIA [ci skip]
The previous edit kind of de-emphasized that, so changing it to be more explict.
(It also avoids showing it as if it's a string-keyed hash.)
2015-02-13 16:22:20 -08:00
Godfrey Chan
ae33aea62c Enums should be referred to by symbols
Also updated the documentation about the new ability to query them normally,
and added test to make sure they work!
2015-02-13 16:18:26 -08:00
Yves Senn
57a1d2bf9d remove CHANGELOG entry for Rails 5.0 only feature. #18918
`has_secure_token` hasen't been released yet. No need to track
every change in the CHANGELOG.
2015-02-13 09:16:22 +01:00
Wojciech Wnętrzak
0817bb06f7 Do not overwrite secret token value when already present.
```
user = User.create(token: "custom-secure-token")
user.token # => "custom-secure-token"
```
2015-02-12 22:05:45 +01:00
Rafael Mendonça França
ce32ff462f Merge pull request #18915 from kamipo/extract_date_time_precision_test
Extract `DateTimePrecisionTest`
2015-02-12 17:42:48 -02:00
Eugene Gilburg
d7a7a050e1 Optimize none? and one? relation query methods to use LIMIT and COUNT.
Use SQL COUNT and LIMIT 1 queries for none? and one? methods if no block or limit is given,
instead of loading the entire collection to memory. The any? and many? methods already
follow this behavior.

[Eugene Gilburg & Rafael Mendonça França]
2015-02-12 17:40:59 -02:00
Ryuta Kamizono
694f4b5120 Extract DateTimePrecisionTest
The datetime precision tests for any adapters is duplicated.
2015-02-13 03:16:47 +09:00
Rafael Mendonça França
68ce508e18 Merge pull request #18886 from kamipo/allow_precision_option_for_time_column
Allow `:precision` option for time type columns
2015-02-12 15:12:27 -02:00
Yves Senn
9e9a3c5314 get rid of transaction warning when running PG tests.
This finally removes the warning "WARNING:  there is no transaction in progress"
when running Active Record tests using PostgreSQL.
2015-02-12 14:45:34 +01:00
Yves Senn
efeaa01e74 pg tests, be clear about the missing type that causes a test skip.
Also removed some cruft in the `setup` and `teardown` methods.
2015-02-12 12:20:03 +01:00
Yves Senn
d93aae9ae7 tests, remove unused requires.
"active_support/testing/stream" is already required in `test_case.rb`.
Furthermore the test "test/cases/migration_test.rb" could no longer be executed
directly.
2015-02-12 10:31:37 +01:00
Ryuta Kamizono
1502caefd3 Allow :precision option for time type columns 2015-02-12 07:23:53 +09:00
Tamir Duberstein
4f357ea104 Schema creation doesn't load the app 2015-02-11 14:20:56 -08:00
Sean Griffin
933decceaf Don't break enum on PG 2015-02-11 15:14:21 -07:00
Sean Griffin
c51f9b61ce Refactor enum to be defined in terms of the attributes API
In addition to cleaning up the implementation, this allows type casting
behavior to be applied consistently everywhere. (#where for example). A
good example of this was the previous need for handling value to key
conversion in the setter, because the number had to be passed to `where`
directly. This is no longer required, since we can just pass the string
along to where. (It's left around for backwards compat)

Fixes #18387
2015-02-11 15:02:36 -07:00
Sean Griffin
5e0b555b45 current_scope shouldn't pollute sibling STI classes
It looks like the only reason `current_scope` was thread local on
`base_class` instead of `self` is to ensure that when we call a named
scope created with a proc on the parent class, it correctly uses the
default scope of the subclass. The reason this wasn't happening was
because the proc captured `self` as the parent class, and we're not
actually defining a real method. Using `instance_exec` fixes the
problem.

Fixes #18806
2015-02-11 13:46:30 -07:00
Rafael Mendonça França
42d62de000 Merge pull request #18888 from kamipo/refactor_quote_default_expression
Refactor `quote_default_expression`
2015-02-11 18:41:41 -02:00
Sean Griffin
c9cc1f47ad Remove the SQLite3 Binary subclass
As far as I can tell, the original reason that this behavior was added
has been sufficiently resolved elsewhere, as we no longer remove the
encoding of strings coming out of the database.
2015-02-11 10:32:13 -07:00
Sean Griffin
066d50bc83 Remove an unused option that I didn't mean to commit [ci skip] 2015-02-11 08:51:30 -07:00
Sean Griffin
aafee233fb Remove most PG specific type subclasses
The latest version of the PG gem can actually convert the primitives for
us in C code, which gives a pretty substantial speed up. A few cases
were only there to add the `infinity` method, which I just put on the
range type (which is the only place it was used). Floats also needed to
parse `Infinity` and `NaN`, but it felt reasonable enough to put that on
the generic form.
2015-02-11 08:49:31 -07:00
Sean Griffin
9a656a7776 Merge pull request #18883 from kamipo/fix_datetime_precision_dumping_zero_for_postgresql
The datetime precision with zero should be dumped
2015-02-11 08:24:47 -07:00
Yves Senn
3ffffcc39d prefer drop_table :table, if_exists: true over explicit checks. 2015-02-11 11:21:00 +01:00
Yves Senn
174f5ed545 add test to ensure remove_reference with index and fk is invertable. 2015-02-11 11:20:59 +01:00
Yves Senn
a893718c31 fix remove_reference with foreign_key: true on MySQL. #18664.
MySQL rejects to remove an index which is used in a foreign key constraint:

```
ActiveRecord::StatementInvalid: Mysql2::Error: Cannot drop index 'index_copies_on_title_id': needed in a foreign key constraint: ALTER TABLE `copies` DROP `title_id`
```

Removing the constraint before removing the column (and the index) solves this problem.
2015-02-11 11:20:59 +01:00
Yves Senn
9bdb083dba Merge pull request #18890 from kamipo/remove_cast_type
Remove `cast_type` in `ColumnDefinition`
2015-02-11 09:47:50 +01:00
Ryuta Kamizono
4748d5a1ef Remove cast_type in ColumnDefinition
This is no longer needed.
2015-02-11 11:13:52 +09:00
Ryuta Kamizono
be9addb69b Use keyword argument in transaction
The keys are already validated, so it is better to use the built-in
feature to do this.
2015-02-11 11:03:18 +09:00
Ryuta Kamizono
bb2a7c38d8 Refactor quote_default_expression
`quote_default_expression` and `quote_default_value` are almost the same
handling for do not quote default function of `:uuid` columns. Rename
`quote_default_value` to `quote_default_expression`, and remove
duplicate code.
2015-02-11 10:26:23 +09:00
Ryuta Kamizono
18e0ffe90f The datetime precision with zero should be dumped
`precision: 0` was not dumped by f1a0fa9e19b7e4ccaea191fc6cf0613880222ee7.
However, `precision: 0` is valid value for PostgreSQL timestamps.
2015-02-11 09:53:34 +09:00
Rafael Mendonça França
3d91083e14 Merge pull request #18877 from prathamesh-sonpatki/ar-changelog-typos-2
Fixed typos in ActiveRecord CHANGELOG [ci skip]
2015-02-10 17:23:13 -02:00
Rafael Mendonça França
5d180fdf06 Merge pull request #12257 from vipulnsward/end_on_find_in_batches
Add an option `end` to `find_in_batches`
2015-02-10 17:16:48 -02:00
Prathamesh Sonpatki
cb7190aa9c Fixed typos in ActiveRecord CHANGELOG [ci skip] 2015-02-11 00:43:51 +05:30
Sean Griffin
f1a0fa9e19 Refactor microsecond precision to be database agnostic
The various databases don't actually need significantly different
handling for this behavior, and they can achieve it without knowing
about the type of the object.

The old implementation was returning a string, which will cause problems
such as breaking TZ aware attributes, and making it impossible for the
adapters to supply their logic for time objects.
2015-02-10 11:55:59 -07:00
Rafael Mendonça França
f926c1c953 Merge pull request #18860 from alex-handley/enhancement/dependent_documentation_fix
Documentation Fix: Corrects explanation of what happens when dependent is not set
2015-02-10 15:15:30 -02:00
Sean Griffin
2f8c596d1b Maintain a consistent order in ActiveRecord::Base#attributes
Fixes #18871
2015-02-10 08:21:46 -07:00
Sean Griffin
a2c80a8945 Change LockingType to use DelegateClass
Significantly faster than `SimpleDelegator`.
2015-02-09 10:28:54 -07:00
Sean Griffin
bae903440d Merge pull request #18849 from kamipo/array_type_is_a_part_of_sql_type
An array type is a part of `sql_type`
2015-02-09 08:29:10 -07:00
Alex Handley
577a7c6dd1 [ci skip] corrects documentation for the default dependent behaviour
By default the foreign key will remain set with the parent id after
destroy is fired.
2015-02-09 14:15:39 +00:00
Vipul A M
3dc432068b Add an option end_at to find_in_batches
that complements the `start`parameter to specify where to stop batch processing
2015-02-09 01:33:57 +05:30
Carlos Antonio da Silva
f636ab75f1 Remove debug code
Added by 101c19f55f5f1d86d35574b805278f11e9a1a48e.
2015-02-08 11:51:22 -02:00
Ryuta Kamizono
f983912037 Fix rounding problem for PostgreSQL timestamp column
If timestamp column have the precision, it need to format according to
the precision of timestamp column.
2015-02-08 22:22:55 +09:00
Andrew White
31fafe0a32 Merge pull request #18602 from kamipo/respect_database_charset_and_collation
Respect the database default charset for `schema_migrations` table.
2015-02-08 13:12:01 +00:00
Andrew White
b1e6794238 Merge pull request #18848 from kamipo/add_auto_increment_method
Add `auto_increment?` instead of `extra == 'auto_increment'`
2015-02-08 13:07:53 +00:00
Andrew White
b7e592bd3b Merge pull request #18851 from kamipo/remove_unused_line
Remove unused line
2015-02-08 12:55:27 +00:00
Ryuta Kamizono
2abde96002 Missing @ [ci skip] 2015-02-08 20:23:46 +09:00
Ryuta Kamizono
1f39b731c1 Remove unused line 2015-02-08 20:14:07 +09:00
Ryuta Kamizono
b199012c4f An array type is a part of sql_type
`sql_type` is reused in `lookup_cast_type`. If making it a part of
`sql_type` when handled array option first, it isn't necessary to do
again.
2015-02-08 19:09:04 +09:00