Skip to content
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

Can Money be added as a supported DataType? #30

Open
JoLinWG opened this issue Aug 3, 2022 · 1 comment
Open

Can Money be added as a supported DataType? #30

JoLinWG opened this issue Aug 3, 2022 · 1 comment

Comments

@JoLinWG
Copy link

JoLinWG commented Aug 3, 2022

Is it possible for the Money DataType to be added? If not, does anyone have any tips on how to do this? I tried creating a formatter myself but with no luck.

Thanks.

@altaurog
Copy link
Owner

altaurog commented Aug 8, 2022

Hi @JoLinWG thanks for your interest in pgcopy! There really ought to be some documentation on adding new datatypes. It looks like money datatype is handled by the cash* functions in the postgresql codebase. Specifically, cash_recv seems to be deserializing a 64-bit integer. This datatype may be somewhat tricky, since it apparently is locale-dependent, but if you want to have a hand at it, I would start by doing a binary dump of a money value and see what it looks like, then try to figure out how lc_monetary factors in. If the import format is meant to look like an int, but the significance is locale-specific, my hunch is the best way to import would be to prepare the input data as integers in a way that reflects the locale setting. Perhaps in this case 'money' could be implemented the same way as 'int8'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants