question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect list of columns for table containing underscore

See original GitHub issue

System information:

  • Operating system (distribution) and version: both Windows and Linux
  • DBeaver version: 7.2.2 (issue present in previous versions too)
  • Additional extensions: none

Connection specification:

  • Database name and version: SAP HANA (both 2.0 and HANA Cloud)
  • Driver name: maven:/com.sap.cloud.db.jdbc:ngdbc, versions 2.4, 2.5, 2.6
  • Do you use tunnels or proxies (SSH, SOCKS, etc)? no

Describe the problem you’re observing:

A table with the name containing an underscore will display an incorrect list of columns, if there is another table with a letter instead of the underscore in the name.

Steps to reproduce, if exist:

  1. Create two tables, ABC and A_C.
  2. Double click on A_C, go to Properties, then Columns. You will see the columns from both tables, first the ones from ABC and then the ones from A_C.

The reason most likely is that underscore matches any letter in the SQL LIKE predicate: https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.05/en-US/20fa17f375191014a4d8d8cbfddfe340.html

If this is the case, other databases might also be affected, as this is not HANA-specific - it is also specified in the ANSI SQL standard. In general, a check for equality should be done using the = operator instead, while LIKE should be used for pattern matching only.

Include any warning/errors/backtraces from the logs

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
kai-morichcommented, Mar 24, 2021

the internal statement for DatabaseMetaData#getColumns contains

  WHERE 
     ( ($2) IS NULL  OR ($2) = '' OR C.SCHEMA_NAME LIKE ($2) ESCAPE '\')
     AND C.TABLE_NAME LIKE ($3) ESCAPE '\'
     AND C.COLUMN_NAME LIKE ($4) ESCAPE '\'

so \ is the escape character

1reaction
kai-morichcommented, Mar 24, 2021

Of course would be better if the JDBC driver would provide this option but this will take some time. Many JDBC drivers are incomplete so dbeaver has various places to compensate for missing properties like SQLDialect classes and driver plugin.xml

Read more comments on GitHub >

github_iconTop Results From Across the Web

JPA column with incorrect underscore - java - Stack Overflow
For me, my cameCase properties in my entity class were automatically getting generated to snake case columns of defined properties in DB table....
Read more >
How to work around Table and/or field names contain ...
There are two ways to workaround this and reference a table or field name that contains dashes/hyphens or starts with an underscore character....
Read more >
Invalid Column Name SQL: How to Use Columns Properly
Valid Table Name Rules in SQL. A valid SQL name for columns, tables, and databases must follow the rules below: Names must begin...
Read more >
ConvertJSONToSQL - Ignores underscore in update keys
Anybody has answer for this- I get this issue on PutDatabaseRecord as well. When I check java code of PutDatabaseRecord.
Read more >
Importing csv Table with Underscores - LaTeX Stack Exchange
Apparently it doesn't like being inside a table. Try \csvreader[longtable={|l|l|},table head=\hline,respect underscore=true,head to column names ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found