Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array_includes doesn't accept a collection or array as input parameter #45468

Open
Serkan80 opened this issue Jan 9, 2025 · 1 comment
Open
Labels
area/hibernate-orm Hibernate ORM area/panache kind/bug Something isn't working

Comments

@Serkan80
Copy link

Serkan80 commented Jan 9, 2025

Describe the bug

I've the following Panache Entity, and I'm tring to use the array_includes function, however it doesn't accept an array as a parameter.

@Entity
class MyEntity extends PanacheEntity {

    @Array(length = 20)
    public String[] accounts;

  // doesn't work
  public static boolean accountNotExists_v1(String[] users) {
         return count("array_includes(accounts, ?1)", users) == 0;
    }

 // does work
  public static boolean accountNotExists_v2(String[] users) {
        var arrayParam = Arrays.stream(users)
                .map("'%s'"::formatted)
                .collect(joining(",", "array(", ")")); => will return 'array('user1', 'user2', ...)

        return count("array_includes(accounts, %s)".formatted(arrayParam)) == 0;
    }
}

I think the issue is with Hibernate and the documentation doesn't mention anything on the usage.

Expected behavior

I'd expect that passing an array or a collection, should work.

Actual behavior

I've to manually transform it into this form: array('val1', 'val2', ...), and pass it as a string and this is cumbersome.

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

3.15.2 & Hibernate 6.6.x

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@Serkan80 Serkan80 added the kind/bug Something isn't working label Jan 9, 2025
Copy link

quarkus-bot bot commented Jan 9, 2025

/cc @FroMage (panache), @loicmathieu (panache)

@geoand geoand added the area/hibernate-orm Hibernate ORM label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/panache kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants