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

Specifying column types #183

Open
agguser opened this issue Apr 12, 2022 · 3 comments
Open

Specifying column types #183

agguser opened this issue Apr 12, 2022 · 3 comments

Comments

@agguser
Copy link

agguser commented Apr 12, 2022

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

@noborus
Copy link
Owner

noborus commented Apr 13, 2022

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.

@agguser
Copy link
Author

agguser commented Apr 14, 2022

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

@noborus
Copy link
Owner

noborus commented Apr 15, 2022

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

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

No branches or pull requests

2 participants