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

Native transformations between numerals and int #2

Open
mkgrgis opened this issue Apr 5, 2023 · 2 comments
Open

Native transformations between numerals and int #2

mkgrgis opened this issue Apr 5, 2023 · 2 comments

Comments

@mkgrgis
Copy link

mkgrgis commented Apr 5, 2023

Feature requests

  1. Now there is only select roman_in(to_char(generate_series(0, 10001), '99999')::cstring) transformation. What about roman_in(smallint) or roman_in(int)?

  2. If there is unicode-encoding (see some constants here) what about ↁ = 5000, ↂ = 10000, ↇ = 50000, ↈ = 100000 for input and output? Also there is less compact forms IƆƆ = 5000, CCIƆƆ = 10000, IƆƆƆ = 50000, CCCIƆƆƆ = 100000 at least for input.
    Note: unfortunately SELECT 'ↈ'::roman is incorrect now.

  3. In Unicode also there is special roman forms

U+2160 | Ⅰ 2160 | Ⅴ 2164 | Ⅹ 2169 | Ⅼ 216C | Ⅽ 216D | Ⅾ 216E | Ⅿ 216F
U+2170 | ⅰ 2170 | ⅴ 2174 | ⅹ 2179 | ⅼ 217C | ⅽ 217D | ⅾ 217E | ⅿ 217F
U+2180 | ↀ 2180 | ↁ 2181 | ↂ 2182 | Ↄ 2183 | ↅ 2185 | ↆ 2186 | ↇ 2187 | ↈ 2188

But it's incorrect input now: SELECT 'Ⅹ'::roman. What about support of this forms at least for input?

  1. Cast functions to smallint and int. There is internal numeric presentation, but no output.

Note: I comes with postgresql-numeral package from PGDG apt sever. Thanks for usefully SQL utility!

@df7cb
Copy link
Owner

df7cb commented Apr 21, 2023

Hi,

  1. the idea is that we override as few PG functions as possible, work with bigint, and rely on casts from the other numeric types. When implicit casts don't work, use explicit casts:
create table r (n smallint);
insert into r values (1);
select n::roman from r;
FEHLER:  42846: kann Typ smallint nicht in Typ roman umwandeln
select n::bigint::roman from r;
 n 
───
 I
  1. interesting, I didn't know these symbols yet. Will consider that the next time I touch the extension.

  2. use type casts.

@mkgrgis
Copy link
Author

mkgrgis commented Apr 21, 2023

Thanks, @df7cb !

  1. select generate_series(0, 10001)::bigint::roman works fine, but more SQL:2016 compatible is direct functions for int and smallint. Will it hard for You to add this functions by bigint example? Maybe select generate_series(0, 10001)::bigint::roman will be interesting as example in documentation / README ?
  2. Lies Sie bitte Große Zahlen und
  3. Darstellung in Unicode
  4. select r::bigint from t works, but also more SQL:2016 compatible are direct casts to int and smallint. Will it hard for You to add this functions by bigint example?

My notes about int and smallint in context SQL:2016 are also applicable to zahl and numeral.

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