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

Incorrect error message when column is unexpectedly NULL #560

Open
simondean opened this issue Jun 23, 2023 · 1 comment
Open

Incorrect error message when column is unexpectedly NULL #560

simondean opened this issue Jun 23, 2023 · 1 comment

Comments

@simondean
Copy link

Are you looking for help?

No

Anorm Version (2.5.x / etc)

2.7.0 (latest version)

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

Use uname -a if on Linux.

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

Adopt JDK 11

Library Dependencies

N/A

Expected Behavior

Please describe the expected behavior of the issue, starting from the first action.

  1. Use the scalar[Int].single on a column that unexpectedly contains a NULL
  2. An error is thrown that says the column unexpectedly contains a null

Actual Behavior

  1. Use the scalar[Int].single on a column that unexpectedly contains a NULL
  2. This error is thrown: anorm.AnormException: '.completed_average' not found, available columns: completed_average, completed_average
  3. The error makes it look like there was an issue with column name or column alias etc. The actual issue was that the column unexpectedly contains a NULL and the scalar[Option[Int]].single needs to be used instead

The issue seems to be with this code in Anorm:

  @inline private def parseColumn[T](
      row: Row,
      name: String,
      c: Column[T],
      input: (Any, MetaDataItem)
  ): Either[SqlRequestError, T] = c.tupled(input).left.map {
    case UnexpectedNullableFound(_) =>
      ColumnNotFound(name, row)

    case cause => cause
  }

The UnexpectedNullableFound error is incorrectly mapped to the ColumnNotFound error

Reproducible Test Case

Please provide a PR with a failing test.

If the issue is more complex or requires configuration, please provide a link to a project on Github that reproduces the issue.

@simondean simondean changed the title Misleading error message when column is unexpectedly NULL Incorrect error message when column is unexpectedly NULL Jun 23, 2023
@gaeljw
Copy link
Member

gaeljw commented Jan 26, 2024

I've been facing this a few times as well. I'm used to it now but would be better if fixed indeed :)

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

No branches or pull requests

2 participants