52353c8bf5
This commit addresses the following errors against MySQL 8.0.18 or lower version of MySQL 8.0. - Steps to reproduce ```ruby git clone https://github.com/rails/rails cd rails git clone https://github.com/rails/buildkite-config .buildkite/ RUBY_IMAGE=ruby:3.3 docker-compose -f .buildkite/docker-compose.yml build base && CI=1 MYSQL_IMAGE=mysql:8.0.18 docker-compose -f .buildkite/docker-compose.yml run mysqldb runner activerecord 'rake db:mysql:rebuild test:mysql2' ``` - Actual behavior ```ruby ... snip ... Error: InsertAllTest#test_upsert_all_implicitly_sets_timestamps_on_create_when_model_record_timestamps_is_false_but_overridden: ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `ships_values` ON DUPLICATE KEY UPDATE updated_at=(CASE WHEN (`ships`.`name`<' at line 1 /usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:151:in `_query' /usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:151:in `block in query' /usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:150:in `handle_interrupt' /usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:150:in `query' lib/active_record/connection_adapters/mysql2/database_statements.rb:104:in `block (2 levels) in raw_execute' lib/active_record/connection_adapters/abstract_adapter.rb:997:in `block in with_raw_connection' /rails/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:23:in `handle_interrupt' /rails/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:23:in `block in synchronize' /rails/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:19:in `handle_interrupt' /rails/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:19:in `synchronize' lib/active_record/connection_adapters/abstract_adapter.rb:969:in `with_raw_connection' lib/active_record/connection_adapters/mysql2/database_statements.rb:102:in `block in raw_execute' /rails/activesupport/lib/active_support/notifications/instrumenter.rb:58:in `instrument' lib/active_record/connection_adapters/abstract_adapter.rb:1112:in `log' lib/active_record/connection_adapters/mysql2/database_statements.rb:101:in `raw_execute' lib/active_record/connection_adapters/abstract_mysql_adapter.rb:237:in `execute_and_free' lib/active_record/connection_adapters/mysql2/database_statements.rb:23:in `internal_exec_query' lib/active_record/connection_adapters/abstract/database_statements.rb:171:in `exec_insert_all' lib/active_record/connection_adapters/abstract/query_cache.rb:26:in `exec_insert_all' lib/active_record/insert_all.rb:55:in `execute' lib/active_record/insert_all.rb:13:in `block in execute' lib/active_record/connection_adapters/abstract/connection_pool.rb:384:in `with_connection' lib/active_record/connection_handling.rb:270:in `with_connection' lib/active_record/insert_all.rb:12:in `execute' lib/active_record/persistence.rb:363:in `upsert_all' test/cases/insert_all_test.rb:561:in `block in test_upsert_all_implicitly_sets_timestamps_on_create_when_model_record_timestamps_is_false_but_overridden' test/cases/insert_all_test.rb:809:in `with_record_timestamps' test/cases/insert_all_test.rb:560:in `test_upsert_all_implicitly_sets_timestamps_on_create_when_model_record_timestamps_is_false_but_overridden' bin/rails test /rails/activerecord/test/cases/insert_all_test.rb:557 E ... snip ... 8856 runs, 25842 assertions, 1 failures, 52 errors, 41 skips ``` Follow up #51274 Refer to these release notes, WL and commits for MySQL 8.0.19 and 8.0.20. - MySQL 8.0.19 supports aliases in the VALUES and SET clauses of INSERT INTO ... ON DUPLICATE KEY UPDATE statement https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html > MySQL now supports aliases in the VALUES and SET clauses of INSERT INTO ... ON DUPLICATE KEY UPDATE statement > for the row to be inserted and its columns. Consider a statement such as this one: https://dev.mysql.com/worklog/task/?id=6312 |
||
---|---|---|
.devcontainer | ||
.github | ||
actioncable | ||
actionmailbox | ||
actionmailer | ||
actionpack | ||
actiontext | ||
actionview | ||
activejob | ||
activemodel | ||
activerecord | ||
activestorage | ||
activesupport | ||
guides | ||
railties | ||
tasks | ||
tools | ||
.gitattributes | ||
.gitignore | ||
.mdlrc | ||
.mdlrc.rb | ||
.rubocop.yml | ||
.yardopts | ||
.yarnrc | ||
Brewfile | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
Gemfile | ||
Gemfile.lock | ||
MIT-LICENSE | ||
package.json | ||
RAILS_VERSION | ||
rails.gemspec | ||
Rakefile | ||
README.md | ||
RELEASING_RAILS.md | ||
version.rb | ||
yarn.lock |
Welcome to Rails
What's Rails?
Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.
Understanding the MVC pattern is key to understanding Rails. MVC divides your application into three layers: Model, View, and Controller, each with a specific responsibility.
Model layer
The Model layer represents the domain model (such as Account, Product,
Person, Post, etc.) and encapsulates the business logic specific to
your application. In Rails, database-backed model classes are derived from
ActiveRecord::Base
. Active Record allows you to present the data from
database rows as objects and embellish these data objects with business logic
methods.
Although most Rails models are backed by a database, models can also be ordinary
Ruby classes, or Ruby classes that implement a set of interfaces as provided by
the Active Model module.
View layer
The View layer is composed of "templates" that are responsible for providing appropriate representations of your application's resources. Templates can come in a variety of formats, but most view templates are HTML with embedded Ruby code (ERB files). Views are typically rendered to generate a controller response or to generate the body of an email. In Rails, View generation is handled by Action View.
Controller layer
The Controller layer is responsible for handling incoming HTTP requests and
providing a suitable response. Usually, this means returning HTML, but Rails controllers
can also generate XML, JSON, PDFs, mobile-specific views, and more. Controllers load and
manipulate models, and render view templates in order to generate the appropriate HTTP response.
In Rails, incoming requests are routed by Action Dispatch to an appropriate controller, and
controller classes are derived from ActionController::Base
. Action Dispatch and Action Controller
are bundled together in Action Pack.
Frameworks and libraries
Active Record, Active Model, Action Pack, and Action View can each be used independently outside Rails.
In addition to that, Rails also comes with:
- Action Mailer, a library to generate and send emails
- Action Mailbox, a library to receive emails within a Rails application
- Active Job, a framework for declaring jobs and making them run on a variety of queuing backends
- Action Cable, a framework to integrate WebSockets with a Rails application
- Active Storage, a library to attach cloud and local files to Rails applications
- Action Text, a library to handle rich text content
- Active Support, a collection of utility classes and standard library extensions that are useful for Rails, and may also be used independently outside Rails
Getting Started
-
Install Rails at the command prompt if you haven't yet:
$ gem install rails
-
At the command prompt, create a new Rails application:
$ rails new myapp
where "myapp" is the application name.
-
Change directory to
myapp
and start the web server:$ cd myapp $ bin/rails server
Run with
--help
or-h
for options. -
Go to
http://localhost:3000
and you'll see the Rails bootscreen with your Rails and Ruby versions. -
Follow the guidelines to start developing your application. You may find the following resources handy:
Contributing
We encourage you to contribute to Ruby on Rails! Please check out the Contributing to Ruby on Rails guide for guidelines about how to proceed. Join us!
Trying to report a possible security vulnerability in Rails? Please check out our security policy for guidelines about how to proceed.
Everyone interacting in Rails and its sub-projects' codebases, issue trackers, chat rooms, and mailing lists is expected to follow the Rails code of conduct.
License
Ruby on Rails is released under the MIT License.