Skip to content

Commit

Permalink
fix nullTransform example code
Browse files Browse the repository at this point in the history
  • Loading branch information
kdhyo committed Nov 1, 2024
1 parent a59285c commit 31d1cd0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion documentation-website/Writerside/topics/Data-Types.topic
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@
<code-block lang="kotlin">
class MealTimeNullTransformer : ColumnTransformer&lt;LocalTime, Meal?&gt; {
override fun wrap(value: LocalTime): Meal? = when {
value.hour == 0 &amp;&amp; value.minute == 0 -&gt; null
value.hour &lt; 10 -&gt; Meal.BREAKFAST
value.hour &lt; 15 -&gt; Meal.LUNCH
else -&gt; Meal.DINNER
Expand All @@ -928,7 +929,7 @@
}

object Meals : Table() {
val mealTime: Column&lt;Meal?&gt; = time(&quot;meal_time&quot;).transform(MealTimeNullTransformer())
val mealTime: Column&lt;Meal?&gt; = time(&quot;meal_time&quot;).nullTransform(MealTimeNullTransformer())
}
</code-block>
</chapter>
Expand Down

0 comments on commit 31d1cd0

Please sign in to comment.