trdsql
trdsql copied to clipboard
Specifying column types
Please add an option to auto-detect column types (e.g. -itype
), or specify numeric column types (e.g. -inum c2,c3
).
Currently, it seems that column types are not auto-detected, which may cause wrong order, e.g.
$ d='a,1
b,2
c,11'
$ <<<$d trdsql -a -
The table name is -.
The file type is CSV.
Data types:
+-------------+------+
| column name | type |
+-------------+------+
| c1 | text |
| c2 | text |
+-------------+------+
…
$ <<<$d trdsql 'select * from - order by c2'
a,1
c,11
b,2
$ <<<$d trdsql 'select * from - order by cast(c2 as number)'
a,1
b,2
c,11
Thank you for the issue. I think it should be cast explicitly. The mistake of automatically converting a number to a number type is repeated many times. This is either already the wrong value or will be the wrong value.
Then, please add an option to specify column types (e.g. -types integer:c2,c3
).
I don't think it's a good idea to just add options so far.