Skip to content

Commit

Permalink
[backend] Upgrading to latest spring boot version
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimfacion committed Nov 21, 2024
1 parent 8ef7f30 commit 54ec76e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.openbas.migration;

import java.sql.SQLException;
import java.sql.Statement;
import org.flywaydb.core.api.migration.BaseJavaMigration;
import org.flywaydb.core.api.migration.Context;
import org.springframework.stereotype.Component;

@Component
public class V3_48__Adding_wrapper_functions extends BaseJavaMigration {

@Override
public void migrate(Context context) throws SQLException {
Statement migrator = context.getConnection().createStatement();
migrator.execute(
"""
CREATE FUNCTION array_to_string_wrapper(a anyelement, b text)
RETURNS TEXT AS
$$
SELECT array_to_string(a, b)
$$ LANGUAGE SQL;
""");
migrator.execute(
"""
CREATE FUNCTION array_position_wrapper(a anyelement, b text)
RETURNS INT AS
$$
SELECT array_position(a, b)
$$ LANGUAGE SQL;
""");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private static Expression<String[]> lowerArray(Expression<?> paths, CriteriaBuil

private static Expression<Boolean> arrayPosition(
Expression<String[]> paths, CriteriaBuilder cb, Expression<String> text) {
return cb.function("array_position", Boolean.class, paths, text);
return cb.function("array_position_wrapper", Boolean.class, paths, text);
}

private static Expression<String> lower(Expression<String> paths, CriteriaBuilder cb) {
Expand All @@ -307,7 +307,7 @@ private static Expression<String[]> stringToArray(Expression<String> paths, Crit
}

private static Expression<String> arrayToString(Expression<?> paths, CriteriaBuilder cb) {
return cb.function("array_to_string", String.class, paths, cb.literal(" && "));
return cb.function("array_to_string_wrapper", String.class, paths, cb.literal(" && "));
}

private static Expression<String[]> avals(Expression<String> paths, CriteriaBuilder cb) {
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.6.2.Final</version>
</dependency>
</dependencies>

<build>
Expand Down

0 comments on commit 54ec76e

Please sign in to comment.