I have an optional foreign key defined for an event that relates to EventType. I want to query for all events, even those events that have the event type None (null). This is the foreign key defined for the event.
def eventTypeId = column[Option[Long]]("event_type_id")
def eventType = foreignKey("event_type", eventTypeId, EventTypes.eventTypes)(_.id)
My initial query is as follows, but it only returns records that have a foreign key, since a foreign key is optional. How?
(for {
p <- events
e <- p.eventType
} yield (p, e))
I want to see all events with AND without a foreign key.
Phil source
share