Hi,
I am working on contributing a DBDictionary for HerdDB (
https://github.com/diennea/herddb).

Currently in HerdDBDirectory I have to set
setDelimitIdentifiers(true);
this is because HerdDB uses Apache Calcite and Calcite has a long list of
reserved words like 'User', 'Value'.

In some real applications this configuration is good and it works very well
but I am not able to make OpenJPA integration tests pass (using
-Ptest-custom profile), in particular the first show stopper is in
TestPersistence.

I have found this little problem about SelectImpl, the patch is trivial, I
just have to add a test case.
https://github.com/apache/openjpa/pull/68

But now I have a harder problem.

With setDelimitIdentifiers(true) TestPersistence fails on the second test
method (the first passes, testQuery) because SchemaTool does not understand
that the column AllFieldTypes#arrayOfStrings is already present on the
table.

This is because in SchemaTool at this line:
https://github.com/apache/openjpa/blob/master/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java#L608

the variable colName holds this value: `arrayOfStrings` (delimited, as the
DBDictionary as delimitAll=true) but dbTable variable (that represents DB
metadata) contains all column names delimited but lowercased (as HerdDB
returns all metadata in lower case) and dbTable.getColumn returns null,
because when we compare delimited DBIdentifiers the comparison is not case
sensitive.

I have played a lot with DBDictionary#schemaCase
and DBDictionary#delimitedCase, forcing SCHEMA_CASE_LOWER, but each
combination leads to errors.

I have tried to tweak the generation of DBIdentifiers in the
various AbstractFieldStrategy implementations but anything I touch I break
some existing test case.

I have also tried to work with 'reservedWords' but it looks like that the
reservedWordsSet is not taken into account when writing DDL and DML (I
didn't test SELECTs) code (looking at RowImpl#getInsertSQL for instance)

So here a couple of questions for you experts:
1) Is it good to set setDelimitIdentifiers(true) ? I don't find any
DBDictionary that sets this feature on
2) If I can't delimit every identifier, is there a way to tell a list of
reserved words to be always delimited ? shall I simply
tweak DBDictionary#toDBName ?


Thanks in advance
Enrico

Reply via email to