Commit Graph

84137 Commits

Author SHA1 Message Date
Jean Boussier
2077524d5e
Merge pull request #45373 from ghiculescu/sqlite3-strict-database-yml
Let sqlite `strict` config read from `database.yml` or config
2022-06-16 21:24:09 +02:00
Gannon McGibbon
c47e663750
Merge pull request #45377 from gmcgibbon/update_migration_docs
Add more detailed description to migration generator
2022-06-16 12:49:17 -05:00
Gannon McGibbon
179024de99 Add more detailed description to migration generator 2022-06-16 12:11:05 -05:00
Jonathan Hefner
fa7a904d4c
Merge pull request #45376 from siaw23/concise_version_note
Use suggested version of note [ci-skip]
2022-06-16 11:37:38 -05:00
Jean Boussier
1a377562a9
Merge pull request #45344 from HParker/add-deprecation-warning-for-association-names
Add configurable deprecation warning for singular associations
2022-06-16 18:25:54 +02:00
HParker
3a04c7b339 Add configurable deprecation warning for singular associations
This removes the singularize from `where` which runs on all `expand_from_hash` keys which might be reflections or column names. This saves a lot of time by avoiding singularizing column names.

Previously in https://github.com/rails/rails/pull/45163 the singularize was removed entirely. after some reflection, I think it is better to at least give a warning for one release since `where` is a very popular API and the problems you can run into with incorrect relation could be hard to debug.

Configurable with `ActiveRecord::Base.allow_deprecated_singular_assocaitions_name = false` / `config.active_record.allow_deprecated_singular_assocaitions_name = false`
2022-06-16 09:14:12 -07:00
John Crepezzi
df0de681dc Remove the multi-call form of assert_called_with
The `assert_called_with` helper allows passing a multi-dimensional array to
mock multiple calls to the same method for a given block. This works
fine now, but when adding support for real kwargs arguments to line up with
recent upgrades in Minitest, this approach is no longer workable because
we can't pass multiple sets of differing kwargs.

Rather than complicated this method further, this commit removes the
multi-call form of `assert_called_with` and modifies the tests that
currently make use of that functionality to just use the underlying
`Minitest::Mock` calls.

Co-authored-by: Eileen M. Uchitelle <eileencodes@gmail.com>
2022-06-16 11:13:57 -04:00
Matthew Draper
8a52f9ba81
Merge pull request #45378 from malis/patch-1
Connections Map changed to Each in ping task
2022-06-16 22:18:06 +09:30
Dominik Malis
cef3342e40
Connections Map changed to Each in ping task
No need to make new array containing all connections because returned value of map is not used
2022-06-16 13:20:14 +02:00
Jean Boussier
33e371070b
Merge pull request #45372 from ghiculescu/sqlite3_adapter_strict_strings_by_default-init
Make `sqlite3_adapter_strict_strings_by_default` work from an initializer
2022-06-16 09:24:39 +02:00
Emmanuel Hayford
d2050b2adc Use suggested version of note [ci-skip]
my_app seems to be what Rails docs use mostly. Changed it for some
consistency
2022-06-16 01:36:35 +02:00
Alex Ghiculescu
507cc6fabe Let sqlite strict config read from database.yml or config
Per this discussion: https://github.com/rails/rails/pull/45346#discussion_r898376510

The adapter should read from `database.yml`, if a value is provided for `strict`. If no value is provided then it should fall back to `config.active_record.strict_strings_by_default`.

Co-authored-by: fatkodima123 <fatkodima123@gmail.com>
2022-06-15 15:59:36 -05:00
Alex Ghiculescu
52e1ea4fba Make sqlite3_adapter_strict_strings_by_default work from an initializer
https://github.com/rails/rails/pull/45346 added an entry to new framework defaults, this PR ensures that configuration works and adds a test for it.
2022-06-15 15:20:45 -05:00
Jonathan Hefner
bdc3e192bb
Merge pull request #45366 from seanpdoyle/field-name-nil-object-name
Support calls to `#field_name` with nil `object_name`
2022-06-15 14:23:27 -05:00
Sean Doyle
8a0bc4aa90 Support calls to #field_name with nil object_name
It's possible for `ActionView::Helpers::FormTagHelper#field_name` calls
made by instances constructed through `fields` and `fields_for` helpers
to have an `object_name` argument that's `nil`. For example, the
following will raise an `undefined method `empty?' for nil:NilClass`
exception:

```erb
<%= fields do |f| %>
  <%= f.field_name :body %>
<% end %>
```

To guard against those calls, replace the method's call to
`String#empty?` with `Object#blank?`, since `NilClass#empty?` is not
defined.
2022-06-15 18:51:20 +01:00
Eileen M. Uchitelle
fd0f114f95
Merge pull request #45368 from eileencodes/move-db-and-shard-selector-middleware-to-railtie
Move db and shard selector initalizer to Railties
2022-06-15 13:27:06 -04:00
Asherah Connor
ec34400abb
Behaviour constant deprecation fix (#45367)
* Add failing test for Behaviour deprecated alias

* Correct DeprecatedConstantProxy use

* DeprecatedConstantProxy docs indicate "full" constant names
2022-06-15 10:21:17 -07:00
Jonathan Hefner
282b769fb5
Merge pull request #45347 from skipkayhil/docs-ad-response
Fix references to RequestHelpers methods in docs [ci skip]
2022-06-15 11:49:06 -05:00
eileencodes
d179383284
Move db and shard selector initalizer to Railties
In #45162 it was discovered that the multi_db generator that was created
for 7.0 doesn't work correctly because that file is loaded _after_ the
initializer in active record is run. I tried moving everything to an
after_initialize but the middleware stack is frozen at that point. I
also attempted to fix this in #45353 but it just didn't feel right to
have to deprecate this behavior that _should_ work.

I then realized that most of the middleware in Rails is installed in the
middleware stack file in railties. If I move the middleware installation
to this file, everything works as necessary.

The only caveat is we need to check if `config` responds to
`active_record` but I think that should be fine - we already do that in
the framework defaults configuration.

Fixes #45162
2022-06-15 12:26:27 -04:00
eileencodes
7f93661551
Lock minitest for now
CI runs bundle update so minitest got updated and my PR started failing
due to this change 6e06ac9d3e

I will relax the minitest requirement once the failing specs can be
fixed, but I don't want that to block this. It wasn't immediately
obvious to me what needs to change in our tests to get them passing.
There is also an open issue here
https://github.com/minitest/minitest/issues/912 regarding this change.
2022-06-15 12:24:41 -04:00
Petrik de Heus
06c116fe1a
Merge pull request #45359 from p8/guides/update-command-line-db-option
Update Command Line guide --database usage [ci-skip]
2022-06-15 07:48:25 +02:00
Hartley McGuire
1d5f9c3e17
Fix references to RequestHelpers methods in docs
These were extracted into the RequestHelpers module in 9bac470
2022-06-14 18:08:13 -04:00
Jean Boussier
4f6f3c9dec
Merge pull request #45346 from fatkodima/sqlite3-strict-mode
Add `:strict` option to default SQLite database.yml template
2022-06-14 23:01:30 +02:00
fatkodima
21a6dbd313 Enable strict strings mode for SQLite3Adapter
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2022-06-14 23:59:17 +03:00
Jonathan Hefner
962a1dd231
Merge pull request #45352 from ghiculescu/wherechain-docs
Improve `where` chaining docs [ci-skip]
2022-06-14 15:23:25 -05:00
Petrik
e5a06ecefe Update Command Line guide --database usage [ci-skip]
The current Command Line guide has an advanced section describing
specifying git as SCM and PostgreSQL as the database. This section is
easily overlooked: https://github.com/rails/rails/issues/44325

By moving whole "advanced" section under the `rails new` section, it's
easier to find. Also specifying the database is pretty common I guess
and not an "advanced" topic.

All mentions of the SCM option have been removed, as it seems to no
longer be an option and we always initialize with Git only.
2022-06-14 22:18:31 +02:00
Alex Ghiculescu
095036c9ab Improve where chaining docs
https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-where only discusses `where.not` in the "no argument" section. A `WhereChain` accepts `not`, `missing`, or `associated`, but you have to click through to https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods/WhereChain.html to learn that. So this PR just updates the docs in https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-where to discuss all the chaining options.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2022-06-14 14:52:32 -05:00
Rafael Mendonça França
4962e03683
Merge pull request #45280 from cbothner/run-transactional-callbacks-on-instances-most-likely-to-match-database-state
Run transactional callbacks on instances most likely to match DB state
2022-06-14 15:48:18 -04:00
Eileen M. Uchitelle
d6a41ee419
Merge pull request #45354 from etiennebarrie/skip-storage-and-mailer-if-job-is-skipped
Skip Active Storage and Action Mailer if Active Job is skipped
2022-06-14 13:53:01 -04:00
Cameron Bothner
936a862f3c
Run transactional callbacks on instances most likely to match DB state 2022-06-14 13:34:25 -04:00
Jonathan Hefner
7ea7f64c9b
Merge pull request #45342 from austenmadden/ar-relation-reset-cache-versions
Update AR Relation method to reset cache_version
2022-06-14 12:05:32 -05:00
Jonathan Hefner
4a55631119
Merge pull request #45329 from siaw23/add_notes_to_quit
Add notes on how to exit the debugger [ci-skip]
2022-06-14 11:12:53 -05:00
Étienne Barrié
9578865329 Skip Active Storage and Action Mailer if Active Job is skipped
If you use either of these frameworks, Active Job is used. That means
that only skipping Active Job will not really skip it, and whenever
app:update runs, Active Job will be added back.
2022-06-14 18:04:28 +02:00
Jonathan Hefner
0adc2347d9
Merge pull request #45332 from siaw23/api_doc_guidelines_improvement
Improve API Documentation Guidelines [ci-skip]
2022-06-14 10:58:47 -05:00
Eileen M. Uchitelle
9817c94fb4
Merge pull request #45277 from p8/guides/fix-guide-dropdown-on-home
Show Guides Index as selected for `/` on small screens [ci-skip]
2022-06-14 10:36:50 -04:00
Austen Madden
a237867e8f Reset cache_versions on relation
Currently, when #reset is called on a relation object it does not reset
the cache_versions ivar. This can lead to a confusing and buggy
situation where despite having the correct data the relation is still
reporting a stale cache_version. Resetting this ivar along with the
other relation state corrects this situation.

Update test assertion

Assert the specific cache_version matches the latest .all relation

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2022-06-14 10:21:01 -04:00
Eileen M. Uchitelle
6ee37a3917
Merge pull request #45351 from etiennebarrie/app_update_disabled_frameworks
Correctly check if frameworks are disabled when running `app:update`
2022-06-14 09:49:09 -04:00
Yasuo Honda
6d703793b6
Merge pull request #40224 from agrobbin/postgresql-exclusion-constraints
Add support for exclusion constraints (PostgreSQL-only)
2022-06-14 21:56:01 +09:00
Étienne Barrié
85a31f4cdc Correctly check if frameworks are disabled when running app:update
Co-authored-by: Paulo Barros <paulo@paulobarros.me>
2022-06-14 14:31:42 +02:00
Alex Robbin
1ceffeb4d9
adds support for exclusion constraints (PostgreSQL-only)
```ruby
add_exclusion_constraint :invoices, "daterange(start_date, end_date) WITH &&", using: :gist, name: "invoices_date_overlap"
remove_exclusion_constraint :invoices, name: "invoices_date_overlap"
```

See PostgreSQL's [`CREATE TABLE ... EXCLUDE ...`](https://www.postgresql.org/docs/12/sql-createtable.html#SQL-CREATETABLE-EXCLUDE) documentation for more on exclusion constraints.
2022-06-14 08:09:47 -04:00
Emmanuel Hayford
14e8939e28 Add notes on how to exit the debugger [ci-skip] 2022-06-14 00:20:14 +02:00
Emmanuel Hayford
0809dd3fca Improve API Documentation Guidelines [ci-skip] 2022-06-14 00:12:18 +02:00
Xavier Noria
3bcd48f6d8 Require Zeitwerk 2.6 2022-06-13 23:43:42 +02:00
Jonathan Hefner
bb680b9a92
Merge pull request #45333 from skipkayhil/refine-configuring-docs
Make secret_key_base doc more explicit [ci skip]
2022-06-13 16:36:54 -05:00
Hartley McGuire
7953c8670b
Make secret_key_base doc more explicit
This used to be `config.secret_key_base` but was changed to
`secrets.secret_key_base` in ae75289 and the `secrets.` prefix was
removed in ca18922 when credentials were added.

`secret_key_base` by itself doesn't really fit with the rest of this
section, so the header and description were changed to document the
config value explicitly, and a reference was added to the api docs for
the recommended approaches at setting its value.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2022-06-13 17:21:27 -04:00
Gannon McGibbon
effe504046
Merge pull request #45327 from gmcgibbon/job_generator_usage
Add more detailed description to job generator
2022-06-13 15:53:52 -05:00
Jonathan Hefner
53efecdddf
Merge pull request #45336 from siaw23/add_to_command_line_docs
Add info and fix command description [ci-skip]
2022-06-13 14:45:01 -05:00
Gannon McGibbon
5f57c7d352 Add more detailed description to job generator 2022-06-13 14:44:28 -05:00
Emmanuel Hayford
a3ffa9b908 Add info and fix command description [ci-skip] 2022-06-13 21:11:17 +02:00
Jean Boussier
2026d5ba3f
Merge pull request #45229 from ghiculescu/change-column-null-ux
`change_column_null` should raise if a non-boolean 3rd argument is provided
2022-06-13 21:01:22 +02:00