Skip to content

Commit

Permalink
Add a Date decoder to the pg adapter to type cast dates
Browse files Browse the repository at this point in the history
at the connection level

Fix rails#51448

Type cast columns of type `date` to ruby `Date` when running a raw
query through `ActiveRecord::Base.connection.select_all`.
  • Loading branch information
JoeDupuis committed Apr 3, 2024
1 parent 3d418c0 commit 4040d06
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@ def add_pg_decoders
"bool" => PG::TextDecoder::Boolean,
"timestamp" => PG::TextDecoder::TimestampUtc,
"timestamptz" => PG::TextDecoder::TimestampWithTimeZone,
"date" => PG::TextDecoder::Date,
}

known_coder_types = coders_by_name.keys.map { |n| quote(n) }
Expand Down

0 comments on commit 4040d06

Please sign in to comment.