Commit Graph

44119 Commits

Author SHA1 Message Date
Sean Griffin
65c33009ba Add a public API to allow users to specify column types
As a result of all of the refactoring that's been done, it's now
possible for us to define a public API to allow users to specify
behavior. This is an initial implementation so that I can work off of it
in smaller pieces for additional features/refactorings.

The current behavior will continue to stay the same, though I'd like to
refactor towards the automatic schema detection being built off of this
API, and add the ability to opt out of automatic schema detection.

Use cases:

- We can deprecate a lot of the edge cases around types, now that there
  is an alternate path for users who wish to maintain the same behavior.
- I intend to refactor serialized columns to be built on top of this
  API.
- Gem and library maintainers are able to interact with `ActiveRecord`
  at a slightly lower level in a more stable way.
- Interesting ability to reverse the work flow of adding to the schema.
  Model can become the single source of truth for the structure. We can
  compare that to what the database says the schema is, diff them, and
  generate a migration.
2014-05-26 15:26:38 -07:00
Rafael Mendonça França
9a6ed04914 Merge pull request #15352 from sgrif/sg-allow-empty-array-where
Allow empty arrays in where predicates
2014-05-26 19:25:16 -03:00
Sean Griffin
f2135aceeb Allow empty arrays in where predicates 2014-05-26 15:12:39 -07:00
Rafael Mendonça França
178448ae9d Merge pull request #15351 from sgrif/sg-allowed-types
Extract types which don't require additional typecasting to a method
2014-05-26 18:32:48 -03:00
Sean Griffin
8163a50fdc Extract types which don't require additional typecasting to a method
Database specific adapters shouldn't need to override `type_cast` to
define types which are already in an acceptable state.
2014-05-26 14:28:18 -07:00
Zachary Scott
5af6120ad1 Merge pull request #15347 from JuanitoFatas/benchmark-in-contributing-to-ror
[ci skip] Add benchmark your code section to contributing to ruby on rails guide.
2014-05-26 14:15:33 -07:00
Juanito Fatas
8b39eca5b7 [ci skip] Add benchmark your code section to contributing to ruby on rails guide.
I have seen many times that maintainers want people to use this gem to give
a benchmark report. It would be nice to add it and refer to it later.
2014-05-27 05:14:12 +08:00
Rafael Mendonça França
923e274313 Merge pull request #15300 from arthurnn/refactor_reflections
Refactor reflections
2014-05-26 18:08:26 -03:00
Arthur Neves
00b024218f
Refactoring .reflections public method.
Now the internal reflections will hold a reference to its public
representation, so when the outside world calls `Account.reflection` we
can build a list of public reflections.
2014-05-26 17:05:21 -04:00
Rafael Mendonça França
e11e285b13 Merge pull request #15350 from sgrif/sg-refactor-predicate-builder
Refactor the handling of arrays in where predicates
2014-05-26 18:02:37 -03:00
Sean Griffin
2f0956cde5 Refactor the handling of arrays in where predicates
Simplifies the code slightly, isolates non-nil non-range values into a
single array, which will make it easier to do things like apply type
casting to them in the future.
2014-05-26 13:47:27 -07:00
Rafael Mendonça França
772c57182d Merge pull request #15323 from JohnKellyFerguson/getting-started-app
Docs: Rename Posts to Articles in Guides' Getting Started App
2014-05-26 17:26:27 -03:00
Rafael Mendonça França
49f03a77ed Merge pull request #15346 from aditya-kapoor/correct-doc-for-path
correct documentation for asset_path and image_path [ci skip]
2014-05-26 16:54:41 -03:00
Aditya Kapoor
5e36411ec3 correct docs for (asset|image)_path [ci skip] 2014-05-27 00:58:47 +05:30
Guillermo Iguaran
de8c41cea2 Merge pull request #15345 from matthewd/skip-dalli-errors
Skip individual tests upon Dalli::RingError
2014-05-26 14:20:07 -05:00
Rafael Mendonça França
76f56c44ef Merge pull request #15342 from aditya-kapoor/correct-tag-docs
correct docs for audio_tag and video_tag [ci skip]
2014-05-26 16:18:22 -03:00
Matthew Draper
72045b2a9f Skip individual tests upon Dalli::RingError
Unlike the outer `rescue`, this one is much more precise about what we
want to handle: a connection failure (`Dalli::RingError`) is not
relevant to what we're testing here. But other Dalli errors may well be
indicating an actual problem.
2014-05-27 04:45:53 +09:30
Rafael Mendonça França
505a263c35 Escape user input before showing in the page.
This is not a security issue since this page is not present in
production and user have to type something in the field but is better to
escape the input.
2014-05-26 15:58:51 -03:00
Aditya Kapoor
6d8beaad1f correct doc for (audio|video)_tag [ci skip] 2014-05-27 00:21:30 +05:30
Rafael Mendonça França
6ed161e3fd Merge pull request #15333 from ShunsukeAida/update_ruby_version
update the recommended ruby version.
2014-05-26 15:14:45 -03:00
Rafael Mendonça França
70d126779e Merge pull request #15294 from schneems/schneems/generator-output-in-error2
print generators on failed generate
2014-05-26 14:51:15 -03:00
Rafael Mendonça França
b4ea605458 Merge pull request #15340 from aditya-kapoor/correct-docs
Correct Documentation for asset_tag_helpers
2014-05-26 14:48:20 -03:00
ShunsukeAida
ad7de78df9 update the recommended ruby version 2014-05-27 02:45:23 +09:00
Aditya Kapoor
c22a253d1a Correct Documentation for asset_tag_helpers 2014-05-26 23:14:16 +05:30
Rafael Mendonça França
cfd9d1d3e1 Merge pull request #15339 from sgrif/sg-mysql-booleans
Refactor the type casting of booleans in MySQL
2014-05-26 14:39:50 -03:00
Sean Griffin
fbdd58081e Refactor the type casting of booleans in MySQL 2014-05-26 10:34:02 -07:00
Matthew Draper
7a5fbaf02c Merge pull request #15336 from sgrif/sg-quoting
Remove checks against `column.type` in abstract adapter quoting
2014-05-27 03:03:09 +09:30
Rafael Mendonça França
abd28f67e1 Merge pull request #15335 from sgrif/sg-missing-test-case
Add missing test case for quoting behavior
2014-05-26 14:27:16 -03:00
Sean Griffin
597d9c8af8 Remove checks against column.type in abstract adapter quoting
The intention is to eventually remove `column` from the arguments list
both for `quote` and for `type_cast` entirely. This is the first step
to that end.
2014-05-26 09:04:17 -07:00
schneems
e83ce84ef9 print generators on failed generate
Let's say we just ran:

```
$ rails g migrate add_click_to_issue_assignment
```

We will get an error that looks like:

```
Could not find generator migrate.
```

This patch adds all existing migrations to the output to make it easier for a developer to find a valid migration.

```
Could not find generator "migrate". Please select a valid generator:
Rails:
  assets
  controller
  generator
  helper
  integration_test
  mailer
  migration
  model
  resource
  scaffold
  scaffold_controller
  task
```


It would be nice to do some spelling detection and suggest alternatives, but for now this should  help.
2014-05-26 10:11:07 -05:00
Sean Griffin
a8afc6395b Add missing test case for quoting behavior
It appears that the only time that `quote` is called with a column,
but without first calling `type_cast` is when where is called with an
array. My previous pull request broke this behavior, without failing
tests. This adds a test for the only case I can think of that exercises
the `if column.type == :integer` branch of `quote` effectively.
2014-05-26 08:08:32 -07:00
Yves Senn
d075c84320 Merge pull request #15307 from sgrif/sg-type-cast-for-write
Add an interface for type objects to control Ruby => SQL
2014-05-26 15:22:09 +02:00
Sean Griffin
b5c4ef2c78 Add an interface for type objects to control Ruby => SQL
Adds the ability to save custom types, which type cast to non-primitive
ruby objects.
2014-05-26 06:19:44 -07:00
Yves Senn
7a2b37fbbb pg, add missing :nodoc: to adapter. 2014-05-26 10:35:20 +02:00
Yves Senn
b952ca3692 pg, remove unused code. Use extract_schema_and_table instead. 2014-05-26 10:28:02 +02:00
Yves Senn
2ae6e11003 Merge pull request #15325 from tgxworld/no_need_to_call_to_s
Remove duplicated to_s method call.
2014-05-26 09:10:00 +02:00
Yves Senn
42fe948917 Merge pull request #15316 from akshay-vishnoi/test-cases
Fix test cases for inflector.rb
2014-05-26 08:56:26 +02:00
Yves Senn
30d4200970 Merge pull request #15324 from andriytyurnikov/simple_rake_stats_for_everything
simple solution that brings rake stats task to all rails project
2014-05-26 08:40:31 +02:00
Yves Senn
942194b926 Merge pull request #15328 from kuldeepaggarwal/remove-warnings
remove unused variable warning.
2014-05-26 08:18:13 +02:00
Guillermo Iguaran
22e96d03b0 Fix docs for ActionController::Renderers.add 2014-05-26 01:12:38 -05:00
Kuldeep Aggarwal
91cf768fa6 remove unused variable warning
`warning: assigned but unused variable - album`
2014-05-26 11:06:25 +05:30
Guo Xiang Tan
86396f8c30 Remove duplicated to_s method call. 2014-05-25 19:07:57 -07:00
Carlos Antonio da Silva
2926a9af87 Merge pull request #15310 from tgxworld/small_refactor_get_routes_as_head
Remove unnecessary flatten! method call.
2014-05-25 20:43:02 -03:00
Andriy Tyurnikov
272f80dc16 simple solution that brings rake stats task to every kind of rails project 2014-05-26 02:19:53 +03:00
John Kelly Ferguson
45072f34d2 Rename Posts to Articles in Guides' Getting Started App, continuation of #15215 [ci skip] 2014-05-25 18:48:14 -04:00
Akshay Vishnoi
93c193ed82 Fix test cases for inflector.rb
`yield` was missing in #with_dup, due to which 57 assertions were not running
in real, and all tests were passing by default.
Error was introduced in commit - 31ceb5e.
2014-05-25 21:36:02 +05:30
Santiago Pastorino
6c30717f8c Merge pull request #15315 from JuanitoFatas/guides-guidelines
[ci skip] Update GFM link in guides guidelines.
2014-05-25 13:01:44 -03:00
Juanito Fatas
7981f06952 [ci skip] Update GFM link in guides guidelines.
Also remove a duplicated sentence.
2014-05-25 23:36:02 +08:00
Yves Senn
21ec7fefea Merge pull request #15312 from JuanitoFatas/action_view/asset_path
Convert source to string if it is present.
2014-05-25 17:16:05 +02:00
Yves Senn
2bb6b51c01 Merge pull request #15311 from zuhao/refactor_actionpack_bare_metal_test
The correct status to test should be :switching_protocols.
2014-05-25 13:56:59 +02:00