openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.71k forks source link

[JDBC Persistence] sqltype.tablePrimaryKey is ignored in jdbc config file #5745

Open jimduchek opened 5 years ago

jimduchek commented 5 years ago

Quick summary: setSqlTypes() in JdbcConfiguration.java sets all 'sqltype' configs to uppercase and appends 'ITEM'. This is fine when you're trying to set the value for, say, 'SWITCHITEM'. initSqlTypes() in JdbcBaseDAO.java -- 'tablePrimaryKey' and 'tablePrimaryValue' can therefore not be configured, as they are not all-uppercase, nor do they end in 'ITEM'.

Quickest fix would be to change to TABLEPRIMARYKEYITEM (and leave setSqlTypes() unchanged), but as these two values serve a slightly different purpose than all the others, I'm not sure that's the correct-est way.

drohhyn commented 5 years ago

Might be fixed by #5820

jimduchek commented 5 years ago

Might be fixed by #5820

At a quick glance at the code, it appears that indeed fixes this issue. Unfortunately I can't even remember why I needed this fixed! :laughing:

drohhyn commented 5 years ago

For me the main reason is that the wrong behavior led to a (wrong) timezone offset with postgres and grafana. I'll try the new version from #5820 in a few days.

jimduchek commented 5 years ago

Timezones! That was it for me too. :)