mcneilco / acas

http://mcneilco.com/acas.html
GNU General Public License v3.0
12 stars 5 forks source link

Postgres dialect detection broken on Postgres > 9 #820

Open brianbolt opened 3 years ago

brianbolt commented 3 years ago

We check in various places in acas-roo-server for the database type by doing:

import org.hibernate.dialect.PostgreSQL9Dialect;
        if (dialect instanceof PostgreSQL9Dialect) {

This is broken if the postgres database is anything but postgres 9.

There is one place this is used:

Affects container inventory (get location tree): https://github.com/mcneilco/acas-roo-server/blob/2f327299562a7de40d0e510d767a15c4d9887707/src/main/java/com/labsynch/labseer/service/ContainerServiceImpl.java#L3546

These 2 places have a fix already in place for this:

if (dialect instanceof PostgreSQLDialect || dialect instanceof PostgreSQL9Dialect) {

Label sequence decrement sequence: https://github.com/mcneilco/acas-roo-server/blob/410fef9a8d7ae071e3db9a9efec5f5f9026b72b2/src/main/java/com/labsynch/labseer/domain/LabelSequence.java#L194

Label sequence fetchCurrentValue: https://github.com/mcneilco/acas-roo-server/blob/410fef9a8d7ae071e3db9a9efec5f5f9026b72b2/src/main/java/com/labsynch/labseer/domain/LabelSequence.java#L229

brianbolt commented 3 years ago

From my reading of the code, it doesn't looks like this would just cause exceptions rather than giving bad data.

All 3 functions throw exceptions when the dialect is incorrect rather than defaulting to some bad behavior.