Skip to content

Adopt active_record.postgresql_adapter_decode_dates = true (currently overridden to false) #1295

Description

@philayres

Background

As part of the Rails 8 upgrade (#1015), advancing config.load_defaults to 7.2 adopts the Rails 7.2 default:

  • active_record.postgresql_adapter_decode_dates = true

This causes date-typed columns returned via raw SQL (connection.exec_query, select_value, etc.) to be decoded as Ruby Date objects instead of String. Previously such values came back as strings.

Why this is temporarily overridden

Test coverage for raw-SQL date decoding is incomplete. There are direct raw-SQL paths that bypass the ActiveRecord type layer, e.g.:

  • app/models/admin/migration_generator.rb (connection.exec_query)
  • app/models/full_text_search/tsvector_writer.rb (conn.exec_query)
  • app/models/nfs_store/manage/archived_file.rb (connection.exec_query)

In addition, report and dynamic-model SQL is configuration-driven, so the test suite cannot see all consumers of raw date values. To keep behaviour attributable during the Rails 8 upgrade, we have explicitly pinned the old behaviour:

# config/application.rb
config.active_record.postgresql_adapter_decode_dates = false

Goal

Remove the override and adopt the Rails 7.2 default (= true) once we have verified all raw-SQL date consumers behave correctly with Date objects.

Acceptance criteria

  • Audit every raw-SQL execution path (exec_query, select_value, select_all, select_rows, find_by_sql) that can return a date-typed column.
  • Add specs asserting the returned Ruby type / correct handling for those paths.
  • Review configuration-driven report/dynamic-model SQL for date-string assumptions.
  • Remove the postgresql_adapter_decode_dates = false override from config/application.rb.
  • Full RSpec suite green with the default enabled.

Refs #1015

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions