Skip to content

Commit

Permalink
Avoid SQL error when fetching view config for zero-layer dataset (#6912)
Browse files Browse the repository at this point in the history
  • Loading branch information
fm3 authored Mar 13, 2023
1 parent be44b11 commit 0f6233f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/models/user/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,18 @@ class UserDataSetLayerConfigurationDAO @Inject()(sqlClient: SqlClient, userDAO:
def findAllByLayerNameForUserAndDataset(layerNames: List[String],
userId: ObjectId,
dataSetId: ObjectId): Fox[Map[String, LayerViewConfiguration]] =
for {
rows <- run(q"""select layerName, viewConfiguration
if (layerNames.isEmpty) {
Fox.successful(Map.empty[String, LayerViewConfiguration])
} else {
for {
rows <- run(q"""select layerName, viewConfiguration
from webknossos.user_dataSetLayerConfigurations
where _dataset = $dataSetId
and _user = $userId
and layerName in ${SqlToken.tupleFromList(layerNames)}""".as[(String, String)])
parsed = rows.flatMap(t => Json.parse(t._2).asOpt[LayerViewConfiguration].map((t._1, _)))
} yield parsed.toMap
parsed = rows.flatMap(t => Json.parse(t._2).asOpt[LayerViewConfiguration].map((t._1, _)))
} yield parsed.toMap
}

def updateDatasetConfigurationForUserAndDatasetAndLayer(
userId: ObjectId,
Expand Down

0 comments on commit 0f6233f

Please sign in to comment.