سؤال

I have a column that is nullable inside my database and I am performing this kind of comparison:

TableQuery[Tables.TableName].filter(
  x =>
    x.nullableStringColumn === optionString
).exists.run

However I am not getting the expected results, empty column should match None and filled column should match the string if equal

هل كانت مفيدة؟

المحلول

You should try

TableQuery[Tables.TableName].filter(
  x => (x.nullableStringColumn.isNull && optionString.isEmpty) ||
    (x.nullableStringColumn === optionString)
).exists.run
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top