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

Keywords in column names are not supported due to missing escaping support #67

Open
Christoph-W opened this issue Oct 20, 2020 · 4 comments

Comments

@Christoph-W
Copy link

Given a database system view with column names being keywords can not be handled by JDBDT.
It is possible to create table tables meta data:

partitionsTable = JDBDT.table("USER_TAB_PARTITIONS")
    .columns("TABLE_NAME", "PARTITION_NAME", "HIGH_VALUE", "\"INTERVAL\"")
    .build(database)

But using it during data preparation

JDBDT.builder(partitionsTable)
    .sequence(...)
    .nullValue("\"INTERVAL\"")

fails with org.jdbdt.InvalidOperationException: Invalid column name: '"INTERVAL"'.
Using .remainingColumnsNull() does not reuse the metadata correctly ending in not escaped column name usage with Syntax error in SQL statement.
Also alternative escaping with ` fails. Even enabling of Option.CASE_SENSITIVE_COLUMN_NAMES did not help.

@edrdo
Copy link
Member

edrdo commented Oct 20, 2020

@Christoph-W This is a tricky edge case where the behavior should be highly dependent on the database engine at stake; which one are you using? Have you tried using nullValue("INTERVAL") (I guess it should not work) ? Try also: 1) defining the column name in the definition of partitionsTable as "\"interval\"" rather than "\"INTERVAL\"" with Option.CASE_SENSITIVE_COLUMN_NAMES enabled and 2) later use "interval" in data set builder operations.

@Christoph-W
Copy link
Author

The following combination seems to be the single valid solution:

database.enable(Option.CASE_SENSITIVE_COLUMN_NAMES);
partitionsTable = JDBDT.table("USER_TAB_PARTITIONS")
    .columns("TABLE_NAME", "PARTITION_NAME", "HIGH_VALUE", "\"interval\"")
    .build(database);
...
JDBDT.builder(partitionsTable)
    .sequence(...)
    .nullValue("\"interval\"")

It does not seem reasonable to me to discard the support of upper case keywords in column and/or table names.
Finally, I would be happy if I could find hints in the documentation that keywords can only be escaped if they are written in lower case.

@edrdo
Copy link
Member

edrdo commented Oct 20, 2020

It does not seem reasonable to me to discard the support of upper case keywords in column and/or table names.
I would be happy if I could find hints in the documentation that keywords can only be escaped if they are written in lower case.

@Christoph-W Yes that's how it works and the documentation is not explicit. The overall scheme for escaped column names is currently fragile.

@edrdo edrdo added this to the 1.3.1 milestone Oct 20, 2020
@edrdo edrdo modified the milestones: 1.3.1, 1.4.0 Dec 14, 2020
@edrdo edrdo modified the milestones: 1.4.0, future development Jan 23, 2021
@edrdo
Copy link
Member

edrdo commented Jan 23, 2021

@Christoph-W I have been examining this issue, trying to improve support for the upcoming 1.4.0 release but a small incremental fix at this time is not possible. The overall scheme will have to be re-examined in a future release.

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

No branches or pull requests

2 participants