turbot / steampipe-plugin-csv

Use SQL to instantly query data from CSV files. Open source CLI. No DB required.
https://hub.steampipe.io/plugins/turbot/csv
Apache License 2.0
19 stars 4 forks source link

Use of camelCase in columns causes error #32

Closed dboeke closed 2 years ago

dboeke commented 2 years ago

Describe the bug Attempting to query a column with camelCase column name results in a column camelCase does not exist error

Steampipe version (steampipe -v) v0.16.0

Plugin version (steampipe plugin list) csv: v0.3.0

To reproduce

> .inspect camels
+-------------+-------+-------------------------------------------------------+
| column      | type  | description                                           |
+-------------+-------+-------------------------------------------------------+
| CapitalCase | text  | Field 3.                                              |
| UPPERCASE   | text  | Field 2.                                              |
| _ctx        | jsonb | Steampipe context in JSON form, e.g. connection_name. |
| camelCase   | text  | Field 0.                                              |
| lowecase    | text  | Field 1.                                              |
+-------------+-------+-------------------------------------------------------+
> select * from camels;
+-----------+-----------+-----------+-------------+---------------------------+
| camelCase | lowercase | UPPERCASE | CapitalCase | _ctx                      |
+-----------+-----------+-----------+-------------+---------------------------+
| no        | yes       | no        | no          | {"connection_name":"csv"} |
+-----------+-----------+-----------+-------------+---------------------------+
> select camelCase from camels;
Error: column "camelcase" does not exist (SQLSTATE 42703)

> select camelcase from camels;
Error: column "camelcase" does not exist (SQLSTATE 42703)

> select lowercase from camels;
+-----------+
| lowercase |
+-----------+
| yes       |
+-----------+

> select UPPERCASE from camels;
Error: column "uppercase" does not exist (SQLSTATE 42703)

> select CapitalCase from camels;
Error: column "capitalcase" does not exist (SQLSTATE 42703)

Expected behavior Should be able to query based the columns using correct case.

Additional context Add any other context about the problem here.

cbruno10 commented 2 years ago

@dboeke Can you please try wrapping columns that contain non-lowercase letters in double quotes, e.g., select "camelCase" from camels;, select "UPPERCASE" from camels;.

Postgres treats identifiers as case insensitive normally, but when wrapping them in double quotes, it treats them as case sensitive.

github-actions[bot] commented 2 years ago

'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.'