infobip / infobip-spring-data-querydsl

Infobip Spring Data Querydsl provides new functionality that enables the user to leverage the full power of Querydsl API on top of Spring Data repository infrastructure.
Apache License 2.0
281 stars 56 forks source link

Database Major Version Conditional Questions #85

Closed dpTablo closed 1 year ago

dpTablo commented 1 year ago

The current code for R2dbcSQLTemplatesConfiguration.

@ConditionalOnClass(Flyway.class)
@Configuration
public class R2dbcSQLTemplatesConfiguration {

    @ConditionalOnBean(Flyway.class)
    @Bean
    public SQLTemplates sqlTemplates(Flyway flyway) throws SQLException {
        var jdbcConnectionFactory = new JdbcConnectionFactory(flyway.getConfiguration().getDataSource(),
                                                              flyway.getConfiguration(),
                                                              null);
        var sqlTemplatesRegistry = new SQLTemplatesRegistry();
        var metaData = jdbcConnectionFactory.openConnection().getMetaData();

        var templates = sqlTemplatesRegistry.getTemplates(metaData);

        if (templates instanceof SQLServerTemplates || metaData.getDatabaseMajorVersion() > 11) {
            return new SQLServer2012Templates();
        }

        return templates;
    }

} 

The condition of the if in your code is strange. The two conditions are an OR operation.

With these conditions, the SQLServer2012Templates instance is registered as a bean when using Postgres 14.5. In my opinion, the two conditions should be an AND operation. please confirm this if condition code.

lpandzic commented 1 year ago

You are correct. It's a bug. Fixed it in 8.1.2