- 10 9月, 2020 1 次提交
-
-
由 Jean Boussier 提交于
Revert "Revert "Raise ConnectionNotEstablished rather than StatementInvalid in Mysql2Adapter#quote_string"" This reverts commit 6f92c40d.
-
- 09 9月, 2020 3 次提交
-
-
由 Ryuta Kamizono 提交于
-
https://github.com/rails/rails/pull/40178#issuecomment-688222844由 Ryuta Kamizono 提交于
It is a common use case especially for MySQL users.
-
由 KapilSachdev 提交于
This reverts commit b8ab1f89, reversing changes made to 73ae5655.
-
- 08 9月, 2020 3 次提交
-
-
由 Kevin Deisz 提交于
If you're using the `nulls_first` or `nulls_last` functionality with an explicit ordering, then previously it wasn't properly handling calls to `#reverse` (called through `reverse_order`). This commit changes the behavior to match what would be expected.
-
由 Eugene Kenny 提交于
These methods are PostgreSQL-specific, and all supported versions of PostgreSQL support validating constraints.
-
由 Alex Robbin 提交于
Active Record already supports adding `NOT VALID` foreign key constraints in PostgreSQL, but back in #31323 when check constraint support was initially added, the ability to add a check constraint and validate it separately was not included. This adds that functionality!
-
- 07 9月, 2020 1 次提交
-
-
由 Muhammad Usman 提交于
Closes #40187.
-
- 04 9月, 2020 4 次提交
-
-
由 Guo Xiang Tan 提交于
This prevents the `from` query method from being ignored silently in the resulting SQL query that is generated.
-
由 Josh Goodall 提交于
The current behaviour of reverse_order, when presented with an existing order that is an Arel expression, is to ignore it. This isn't quite in keeping with how it handles Arel attributes (which it reverse) or arbitrary strings (which throw an exception). The easy path would be to throw an exception, but we don't have to. Any SQL expression that is a valid default sort expression can be reversed with DESC. It follows that if there's an existing Arel::Nodes::NodeExpression that is not already wrapped with an Arel::Nodes::Ordering, then it can be reversed with DESC.
-
由 Guo Xiang Tan 提交于
When ActiveRecord is used with Rails, loading `ActiveRecord` will set the configurations so there is no need to do it twice.
-
由 eileencodes 提交于
The handling for single database applications has always set a schema.rb or structure.sql files for loading the database schema. When we first implemented multiple database support we intended to keep this for the original, default database. Afterall Rails _has_ to connect to something on boot. In development only one connection is connected on boot since we don't eager load the app. Originally we had thought that all applications should be required to add a `primary` entry in the database configurations file. However, this hasn't worked in practice and we have some code now that does not assume there's a primary. The schema dumping/loading code however, still assumed there was a "primary" in the configurations file. We want the "default" database in any application to use the original files even when converted to a multiple database application as this reduces the need to make changes when implementing this functionality on an existing application. The changes here update Rails to ensure that we treat either "primary" or the first database configuration for an environment as "default". If there is a "primary" that will be used as the default configuration. If there is no primary the configuration that is first for an environment will be used as the default. For schema dump/load this means that the default configuration (primary or first) will use `schema.rb` as the filename and other configurations will use `[CONFIGURATION_NAME]_schema.rb`. This should also help us finish the pull request to infer migrations paths since now we can say the first configuration is the default. This is a natural assumption for application developers. Followup to #39536
-
- 02 9月, 2020 2 次提交
-
-
由 Ryuta Kamizono 提交于
This reverts commit 55d9e494, reversing changes made to 03e987cd. Legacy mysql adapter is already removed in #22642.
-
由 Ryuta Kamizono 提交于
-
- 01 9月, 2020 5 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 Jean Boussier 提交于
-
由 Jean Boussier 提交于
-
由 Ryuta Kamizono 提交于
Don't call `arel_table[attr]` directly makes handling predicate building easier in 3rd party code.
-
由 Ryuta Kamizono 提交于
Originally, time object is decorated after `changes_applied` by `forgetting_assignment` (`value_for_database`). https://github.com/rails/rails/blob/d2cdf0be675b44771f950697fc0b19ef0ea453f9/activemodel/lib/active_model/attribute.rb#L67-L69 https://github.com/rails/rails/blob/d2cdf0be675b44771f950697fc0b19ef0ea453f9/activemodel/lib/active_model/attribute.rb#L55-L57 Before #36352, fortunately `apply_seconds_precision` will return undecorated new time object by everytime `value.change` is called. Now, we need to explicitly check a time value is decorated or not in `cast_value`. Fixes #36910.
-
- 27 8月, 2020 1 次提交
-
-
由 Rafael Mendonça França 提交于
-
- 26 8月, 2020 7 次提交
-
-
由 Jean Boussier 提交于
-
由 Jean Boussier 提交于
-
由 Guo Xiang Tan 提交于
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
If a table is joined multiple times, those tables are aliased other than the first one. It happens easily on self referential associations, and in that case currently there is no way to work custom attribute (type casting) and attribute alias resolution for aliased tables in `where` conditions. To address the issue, it will allow `where` references association names as table aliases. If association names are referenced in `where`, those names are used for joined table alias names. ```ruby class Comment < ActiveRecord::Base enum label: [:default, :child] has_many :children, class_name: "Comment", foreign_key: :parent_id end # ... FROM comments LEFT OUTER JOIN comments children ON ... WHERE children.label = 1 Comment.includes(:children).where("children.label": "child") ``` Fixes #39727.
-
由 Rafael Mendonça França 提交于
MySQL <= 5.7 doesn't support so we should not try to check them.
-
由 Petrik 提交于
In 7f938cac the test model `Man` was renamed to `Human`. Maybe this is a good time to also change `horrible_human` and `dirty_human` to `happy_human` and `confused_human`. While this change is mostly cosmetic change, the phrase "dirty man" has a negative meaning. The adjectives "confused" and "puzzled" were chosen because they are used for defining associations with errors.
-
- 25 8月, 2020 2 次提交
-
-
由 Guo Xiang Tan 提交于
Not disconnecting the connections in the pool results in a session left idling in the DB. An idle session will prevent the database being dropped and affect commands like `bin/rails db:test:prepare`. While this is an edge case, it is still good practice to clean up the connections in the pool.
-
由 Petrik 提交于
If an inverse association isn't found we can suggest similar associations: ``` class Human < ActiveRecord::Base has_one :dirty_face, class_name: "Face", inverse_of: :dirty_human end class Face < ActiveRecord::Base belongs_to :human, inverse_of: :face belongs_to :horrible_human, class_name: "Human", inverse_of: :horrible_face end Human.first.dirty_face Could not find the inverse association for dirty_face (:dirty_human in Face) Did you mean? human horrible_human .... ``` Co-authored-by: NDaniel Colson <danieljamescolson@gmail.com>
-
- 24 8月, 2020 6 次提交
-
-
由 Ryuta Kamizono 提交于
Since other part in `arel` is not necessary for that.
-
由 Jean Boussier 提交于
Before 29874cc4 the order values would be deduplicated when the SQL query is generated, but now it has to be eager.
-
由 Ryuta Kamizono 提交于
-
由 Eugene Kenny 提交于
This was added in 6223e206 to allow `table_name_prefix`, `table_name_suffix`, and `pluralize_table_names` to be injected instead of always being read from `ActiveRecord::Base`. It was never documented, and after 336783ad and 0c843640 setting it has no effect.
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
-
- 23 8月, 2020 1 次提交
-
-
由 Ryuta Kamizono 提交于
This is an alternative of #29722. Before Rails 6.1, storing demodulized class name is supported only for STI type by `store_full_sti_class` class attribute. Now `store_full_class_name` class attribute can handle both STI and polymorphic types. Closes #29722. See also #29601, #32048, #32148.
-
- 19 8月, 2020 1 次提交
-
-
由 mikong 提交于
-
- 17 8月, 2020 1 次提交
-
-
由 Ryuta Kamizono 提交于
Related to #35210. We sometimes use `select` to limit unused columns for performance. For example, `GET /posts/1` (post detail) usually use (almost) all columns, but `GET /posts` (post list) does not always use all columns (e.g. use `id` and `title` for the list view, but `body` is not used). If an association is eager loaded, the limited `select` doesn't works as expected, eager loading will load all columns on the model, plus also load the `select` columns additionally. It works differently with natural load and preload. It means that changing natural load or preload to eager load (or vice versa) is unsafe. This fixes eager loading that always load all columns (plus extra `select` columns), to respect the `select` columns like as others. ```ruby post = Post.select("UPPER(title) AS title").first post.title # => "WELCOME TO THE WEBLOG" post.body # => ActiveModel::MissingAttributeError # Rails 6.0 (ignore the `select` values) post = Post.select("UPPER(title) AS title").eager_load(:comments).first post.title # => "Welcome to the weblog" post.body # => "Such a lovely day" # Rails 6.1 (respect the `select` values) post = Post.select("UPPER(title) AS title").eager_load(:comments).first post.title # => "WELCOME TO THE WEBLOG" post.body # => ActiveModel::MissingAttributeError ```
-
- 16 8月, 2020 1 次提交
-
-
由 Ryuta Kamizono 提交于
Someone had relied on the behavior that preloading with a given scope, but the behavior has lost in #35496 to fix the minor bug that unloading through association. Basically we don't guarantee the internal behavior, but the bugfix can be achieved without any breaking change, so I've restored the lost functionality. Fixes #36638. Fixes #37720.
-
- 15 8月, 2020 1 次提交
-
-
由 eileencodes 提交于
Looking at the history this is holdover from the pre-pool manager and changes made by Shopify. The tests pass without it and we've had enough changes that it doesn't appear necessary anymore. Co-authored-by: NJohn Crepezzi <john.crepezzi@gmail.com>
-