-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add non-composite custom money #1137
Conversation
TODO un-hard-code variable values
Codecov Report
@@ Coverage Diff @@
## master #1137 +/- ##
==========================================
+ Coverage 93.30% 93.39% +0.09%
==========================================
Files 112 113 +1
Lines 4269 4332 +63
==========================================
+ Hits 3983 4046 +63
Misses 286 286
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @brent!. I removed a stale print
statement in line db/types/operations/cast.py:314
db/types/operations/cast.py
Outdated
@@ -297,6 +311,7 @@ def create_cast_functions(target_type, type_body_map, engine): | |||
""" | |||
for type_, body in type_body_map.items(): | |||
query = assemble_function_creation_sql(type_, target_type, body) | |||
print(query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this print
statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that.
Fixes #1094
This adds a custom money type called
MATHESAR_TYPES.MATHESAR_MONEY
based on underlyingNUMERIC
storage.Technical details
Extra features over
NUMERIC
:a column of
MATHESAR_TYPES.MATHESAR_MONEY
will be reflected as such, notifying the UI that it should apply whatever display options are relevant.For casting from text types (
TEXT
,VARCHAR
,CHAR(n)
, etc.), many inputs which wouldn't be allowed forNUMERIC
are handled properly. Each ofis cast to the proper numeric value. Note that we allow currency symbols (non-numeric characters) at the beginning, end, or both of the numeric portion. We allow
(space) as group separators. We allow either
,
,.
, or,
or.
as decimal points (but the decimal point needs to be distinct from the group separator). For grouping, we handle both the international 3-digit group system or the lakh, crore, etc. system. There are some notable things we can't allow, since we're locale-agnostic when reading text as money, or other reasons:,
and.
are allowed for the group separator and decimal point respectively in the lakh systemIn any case where we handle the input, it will be translated appropriately into the DB's locale for parsing as a
NUMERIC
for storage.Checklist
Update index.md
).master
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin