kristijanhusak / vim-dadbod-ui

Simple UI for https://github.com/tpope/vim-dadbod
MIT License
1.54k stars 94 forks source link

Table names truncated at 20 characters for oracle #237

Open nlinaje opened 6 months ago

nlinaje commented 6 months ago

After the plugin connects to the oracle database and puts all tables in the tree, some of the tables get truncated.

The plugin truncates it at 20 characters, but the maximum number of characters in Oracle is 30. (Versions <=12.2)

I changed the line: \ 'COLUMN table_name FORMAT a25', to \ 'COLUMN table_name FORMAT a30', to be able to see the full table names in my database in the tree window (as I am using version 12.2)

Additionally, there are other columns which are not using the maximum number of characters allowed by Oracle. This table is a summary of what I found out: table version >12.2 version <=12.2 set by plugin (schemas.vim) set by plugin (helpers)
owner 128 bytes 30 bytes a20 a20
table_name 128 bytes 30 bytes a25 a20
column_name 128 bytes 30 bytes a25 a20
constraint_type 128 bytes 30 bytes - a20
index_name 128 bytes 30 bytes - a20

Link to oracle documentation: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Database-Object-Names-and-Qualifiers.html#GUID-75337742-67FD-4EC0-985F-741C93D918DA

Setting the format to big values have drawbacks. For example, setting the columns to 128 in the helpers, makes the preview window in some cases (i.e. "references") unusable, as each column has 128 chars for data being between 10 and 20 chars.

From my point of view, the table_name and owner in schemas.vim should be changed to 30 chars (or 128 for versions >12.2) so that the tree can be created correctly. The column_name could be set to 30 chars too. In the helpers I would leave it with 20 or maximum set it to 30.

kristijanhusak commented 6 months ago

@Iron-E added initial support for some Oracle stuff.

@Iron-E , can you provide some feedback on this PR? Thanks!

dbmatheus commented 6 months ago

I agree with @nlinaje in this one, I was having the same issue with the Schemas / Tables navigation because I have a customer with table names bigger than 25 characters.

Thanks!

Iron-E commented 4 months ago

@Iron-E added initial support for some Oracle stuff.

@Iron-E , can you provide some feedback on this PR? Thanks!

Sorry for the long time without a response!

I seem to recall the decision for a20 was purely viaual, and if that isn't working for users today then I agree it should be changed (especially if the max name length has increased so much 😅).

Perhaps an option would work here? I don't recall the vim-dadbod-ui architecture off the top of my head, but it could be beneficial (if possible) to allow for max lengths across adapters (e.g. g:db_ui_trim = {'columns': 35}, and just default to no max length.