Skip to content
New issue

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

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

Already on GitHub? # to your account

Option[List] type goes wrong in db when filter with a condition #541 #3165

Open
sxh-lsc opened this issue Jan 9, 2025 · 0 comments
Open

Comments

@sxh-lsc
Copy link

sxh-lsc commented Jan 9, 2025

Version: "4.8.4"
Module: quill-jdbc-zio
Database: postgresql

Steps to reproduce the behavior

I use a condition to do my filter, which is like :

case class DatesetSearchCondition(
  ids: Option[List[Long]] = None,
  name: Option[String] = None,
  scenario: Option[String] = None,
  isOfficial: Option[Boolean] = None,
  creator: Option[String] = None,
  dataSource: Option[String] = None,
  branch: Option[String] = None,
  from: Option[Int] = Some(0),
  size: Option[Int] = Some(10)
)
def sql = quote { (cond: DatesetSearchCondition) =>
  query[Datasets]
    .filter(d =>
        cond.name.forall(cn => d.name like s"%$cn%") &&
        cond.creator.forall(_ == d.creator) &&
        cond.isOfficial.forall(f => f == d.isOfficial.getOrElse(false)) &&
        cond.scenario.forall(_ == d.scenario) &&
        cond.dataSource.forall(_ == d.dataSource) &&
        cond.branch.forall(cb => d.name like s"$cb%")
    )
    .filter(d => cond.ids.forall(_.contains(d.id)))
    .sortBy(_.id)(Ord.descNullsLast)
    .drop(cond.from.getOrElse(0))
    .take(cond.size.getOrElse(10))
}

It goes well when ids is defined, when I check the build information the sql about ids is d.id = ANY(?). And the other fields were also executed smoothly.
However, when ids is None, the db will goes wrong with database goes wrong: ERROR: could not determine data type of parameter $xxx
I speculate that this problem is caused by an abnormal null pointer or something similar.
I want to ask, is this an expected error? How can I fix my code to make it work again?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant