-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from narma/zio_refactoring_and_finish_null_values
Zio refactoring and finish null values
- Loading branch information
Showing
11 changed files
with
206 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/scala/zio/cassandra/session/cql/UnexpectedNullValue.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package zio.cassandra.session.cql | ||
|
||
import com.datastax.oss.driver.api.core.cql.Row | ||
import com.datastax.oss.driver.api.core.data.UdtValue | ||
|
||
import scala.util.control.NoStackTrace | ||
|
||
sealed trait UnexpectedNullValue extends Throwable | ||
|
||
case class UnexpectedNullValueInColumn(row: Row, index: Int) extends RuntimeException() with UnexpectedNullValue { | ||
override def getMessage: String = { | ||
val cl = row.getColumnDefinitions.get(index) | ||
val table = cl.getTable.toString | ||
val column = cl.getName.toString | ||
val keyspace = cl.getKeyspace.toString | ||
val tpe = cl.getType.asCql(true, true) | ||
|
||
s"Read NULL value from $keyspace.$table column $column expected $tpe. Row ${row.getFormattedContents}" | ||
} | ||
} | ||
|
||
case class UnexpectedNullValueInUdt(row: Row, index: Int, udt: UdtValue, fieldName: String) | ||
extends RuntimeException() | ||
with UnexpectedNullValue { | ||
override def getMessage: String = { | ||
val cl = row.getColumnDefinitions.get(index) | ||
val table = cl.getTable.toString | ||
val column = cl.getName.toString | ||
val keyspace = cl.getKeyspace.toString | ||
val tpe = cl.getType.asCql(true, true) | ||
|
||
val udtTpe = udt.getType(fieldName) | ||
|
||
s"Read NULL value from $keyspace.$table inside UDT column $column with type $tpe. NULL value in $fieldName, expected type $udtTpe. Row ${row.getFormattedContents}" | ||
} | ||
|
||
} | ||
|
||
object UnexpectedNullValueInUdt { | ||
private[cql] case class NullValueInUdt(udtValue: UdtValue, fieldName: String) extends NoStackTrace | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters