trdsql icon indicating copy to clipboard operation
trdsql copied to clipboard

Specifying column types

Open agguser opened this issue 2 years ago • 3 comments

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

agguser avatar Apr 12 '22 04:04 agguser

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.

noborus avatar Apr 13 '22 22:04 noborus

Then, please add an option to specify column types (e.g. -types integer:c2,c3).

agguser avatar Apr 14 '22 15:04 agguser

I don't think it's a good idea to just add options so far.

noborus avatar Apr 15 '22 00:04 noborus