slick icon indicating copy to clipboard operation
slick copied to clipboard

Let optional foreign key generator produce outer join

Open aryairani opened this issue 12 years ago • 22 comments

  type ID = Array[Byte] // Oracle RAW
  object Users extends Table[User]("TB_USER") {
    def id = column[ID]("ID",O.PrimaryKey)
    def agencyId = column[Option[ID]]("AGENCY_ID")
    def inactive = column[Boolean]("INACTIVE", O.Default(false))
    def disabled = column[Boolean]("IS_DISABLED", O.Default(true))
    def agency = foreignKey("FK_TB_USER_AGENCY_ID",agencyId,Agencies)(_.id.?)
  }
  object Agencies extends Table[Agency]("TB_AGENCY") {
    def id = column[ID]("ID",O.PrimaryKey)
    def dataOutOfDate = column[Boolean]("IS_DATA_OUT_OF_DATE")
  }
  val q = for {
    u <- Users
    s <- u.agency // agencyId is Option[ID]; let this produce an outer join
  } yield (u.disabled, u.inactive, s.dataOutOfDate.?.getOrElse(false))

aryairani avatar Jul 11 '13 05:07 aryairani

+1

siklosg avatar Dec 04 '13 20:12 siklosg

+1

frozenspider avatar Mar 28 '14 15:03 frozenspider

+1

vadimich avatar Mar 28 '14 15:03 vadimich

+1

jimdickinson avatar Mar 28 '14 15:03 jimdickinson

+1

cblage avatar Mar 28 '14 16:03 cblage

+1

ttyusupov avatar Mar 28 '14 16:03 ttyusupov

+1

pinge avatar Mar 28 '14 16:03 pinge

+1

PhilAndrew avatar May 14 '15 13:05 PhilAndrew

+1

0xdevalias avatar Oct 15 '15 01:10 0xdevalias

+1

pdolega avatar Nov 11 '15 23:11 pdolega

On a second thought - this definitely sounds as something useful on daily basis. Dealing with outer joins is a little bit painful right now.

However I got some doubts if it is really how monadic composition should behave ? I mean if we compare it to other monadic types we use with for comprehension - we would rather expect empty result as soon a we hit first empty value in comprehension, right ?

EDIT: On the second however we obviously operate here on DBIO so whether something is existing or nonexisting option is not relevant here...

pdolega avatar Dec 15 '15 09:12 pdolega

+1

jacktol avatar Apr 01 '16 14:04 jacktol

+1

sarahgerweck avatar Jul 07 '16 22:07 sarahgerweck

+1

dyross avatar Jul 08 '16 20:07 dyross

+1

lhns avatar Sep 07 '16 13:09 lhns

@trevorsibanda if you ever feel the itch for hacking on something, here is something that may fall into your ballpark ;)

cvogt avatar Sep 07 '16 23:09 cvogt

+1 hi guys, I guess no update here?

Ossip avatar Jan 11 '17 20:01 Ossip

+1

rpiaggio avatar Aug 07 '17 16:08 rpiaggio

+1

manfredi-giordano avatar Apr 02 '19 14:04 manfredi-giordano

+1

solverit avatar Apr 02 '19 15:04 solverit

+1

abdelrahmanmohamed avatar Sep 27 '22 14:09 abdelrahmanmohamed

PR welcome ;)

nafg avatar Sep 29 '22 23:09 nafg