xo / usql

Universal command-line interface for SQL databases
MIT License
8.82k stars 346 forks source link

\ss returns error for existing table #383

Closed pashagolub closed 1 year ago

pashagolub commented 1 year ago

It's impossible to use schema qualified names in \ss command

$ go install github.com/xo/usql@master
go: downloading github.com/xo/usql v0.13.2-0.20221206074426-030c5c6a58f5
...

$ usql postgresql://pasha@127.0.0.1/timetable?sslmode=disable
...
pg:pasha@127/timetable=> \dt
         List of relations
  Schema   |      Name      | Type
-----------+----------------+-------
 public    | location       | table
 timetable | active_chain   | table
 timetable | active_session | table
 timetable | chain          | table
 timetable | execution_log  | table
 timetable | log            | table
 timetable | migration      | table
 timetable | parameter      | table
 timetable | task           | table
(9 rows)
pg:pasha@127/timetable=> \ss timetable.log
Did not find any relation named "timetable.log".
pg:pasha@127/timetable=> \ss "timetable"."log"
Did not find any relation named "timetable.log".
pg:pasha@127/timetable=> \ss location
                                         Column stats
 Schema |  Table   | Name | Average width | Nulls fraction | Distinct values | Dist. fraction
--------+----------+------+---------------+----------------+-----------------+----------------
 public | location | name |            13 |              0 |            2350 | 0.1997
(1 row)
nineinchnick commented 1 year ago

This is a duplicate of #364, I agree it's a pretty unfortunate error message.

nineinchnick commented 1 year ago

If you try running \ss public.location it should work. usql does a very basic pattern parsing to extract the schema name, so it might not work with quotes: https://github.com/xo/usql/blob/master/drivers/metadata/writer.go#L824

nineinchnick commented 1 year ago

Fixed in eea1b686d381b705f979f966a8f6d76eb3da3737