1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test
Petrik d163fcd620 Generators should raise an error if a field has an invalid type
Generators can create invalid migrations when passing an invalid
field type. For example, when mixing up the name and type:

    bin/rails g model post string:title

This will generate a field for post with a column named `string`
of the type `title`, instead of a column named `title` of the type
`string`. Running the migration will result in an error as the type
`title` is not known to the database.

Instead of generating invalid files, the generator should raise an error
if the type is invalid. We validate the type by checking if it's a
default migration types like: string, integer, datetime, but also
references, and rich_text.

If the type isn't a default type, we can ask the
database connection if the type is valid. This uses the `valid_type?`
method defined on each database adapter, which returns true if the
adapter supports the column type. This method is also used by the
SchemaDumper.

Some gems like 'postgis' add custom types. The 'postgis' gem adds these
types by overriding the `native_database_types` method.
That method is used by `valid_type?` method on the database adapter,
making this change compatible with 'postgis'.
2021-05-29 15:17:36 +02:00
..
application rails tmp:clear: clear tmp/storage 2021-05-28 22:34:49 -04:00
command Display a help message if rails new is called without a path 2021-05-14 10:21:26 -05:00
commands Support using replicas when using rails dbconsole 2021-05-24 13:57:46 -07:00
configuration
engine Remove all version checking for older Rubies in tests 2021-02-05 13:21:45 +09:00
fixtures Populate ARGV with Rails::Command.invoke args 2021-04-03 10:12:52 -05:00
generators Generators should raise an error if a field has an invalid type 2021-05-29 15:17:36 +02:00
isolation Refactor CVE-2021-22881 fix 2021-02-13 12:03:23 -06:00
minitest
railties Invoke namespaced task when necessary 2021-05-26 13:44:42 +01:00
test_unit
abstract_unit.rb
app_loader_test.rb
backtrace_cleaner_test.rb
code_statistics_calculator_test.rb Add support for stylesheets and ERB views to rails stats. 2020-11-10 09:40:18 -07:00
code_statistics_test.rb
console_helpers.rb
engine_test.rb
env_helpers.rb
generators_test.rb
initializable_test.rb
json_params_parsing_test.rb
path_generation_test.rb
paths_test.rb
rack_logger_test.rb
rails_info_controller_test.rb
rails_info_test.rb
secrets_test.rb
version_test.rb