forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix casting PG money with comma as radix point
The `/^-?\D*+[\d.]+,\d{2}$/` regexp in the guard does not guarantee a match for the subsequent `gsub!`. For example, when casting `"3,50"`. Thus `gsub!` could return `nil`, and the chained `sub!` call would raise `NoMethodError`. This commit splits up the call chain. It also replaces `gsub!` with `delete!` and `sub!` with `tr!` since regexps are unnecessary for these cases. Co-authored-by: Jonathan Hefner <[email protected]>
- Loading branch information
1 parent
a475175
commit bcd3589
Showing
2 changed files
with
19 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters