Frage

Ich lese die SQueryL Dokumentation auf Aktualisierung und ich sehe:

update(songs)(s =>
  where(s.title === "Watermelon Man")
  set(s.title := "The Watermelon Man",
      s.year  := s.year.~ + 1)
)

Ich hatte eine harte Zeit, um die ~ Methode aus dem SQueryL Quellcode zu finden, und der verknüpfte Dokumentation offensichtlich mir nicht sagen, was es entweder tut. Hat jemand darauf zu erklären?

War es hilfreich?

Lösung

I recall reading about the tilde operator not too long ago on the Schema Definition Page. It is about disambiguating between a primitive and a custom type, although (as I am just beginning to learn Scala) it still sounds a bit vague to me ;). To quote a little piece

...

important : in PrimitiveTypes mode there can be ambiguities between numeric operators

When using org.squeryl.PrimitiveTypeMode, the compiler will treat an expression like the one in the next example as a Boolean. The .~ function is needed to tell the compiler that the left side is a node of TypedExpressionNode[Int] which will cause the whole expression to be a LogicalBoolean which is what the where clause takes :

...

Hope that helps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top