scala - How do I correctly compare Options members in Slick? -



scala - How do I correctly compare Options members in Slick? -

i'm doing things addresses, , fellow member subpremise(apartment/condo #) causes retrieves miss. have concerns subpremise beingness part of unique index constraint, given can null.

failure filter:

tablequery.filter(c=> (c.longitude === r.longitude && c.latitude === r.latitude) || (c.streetnumber === r.streetnumber && c.route === r.route && c.subpremise === r.subpremise && c.neighborhoodid === r.neighborhoodid))

successful filter: (by removung subpremise)

tablequery.filter(c=> (c.longitude === r.longitude && c.latitude === r.latitude) || (c.streetnumber === r.streetnumber && c.route === r.route && c.neighborhoodid === r.neighborhoodid))

i've included definitions below s.t. if there contributing factor i've missed, noticed.

case class address(id:option[long],streetnumber:short,route:string,subpremise:option[string],neighborhoodid:fk,latitude:option[double],longitude:option[double]) class addresses(tag: tag) extends table[address](tag, "addresses") logging { def id = column[long]("id", o.primarykey, o.autoinc) def streetnumber = column[short]("street_number") def route = column[string]("route",o.notnull) def subpremise = column[option[string]]("subpremise") def neighborhoodid = column[long]("neighborhood",o.notnull) def latitude = column[option[double]]("latitude") def longitude = column[option[double]]("longitude") //constraints def idx = index("idx_streetnum_route_subpremise_neighborhood", (streetnumber,route,subpremise,neighborhoodid), unique = true) def gps = index("gps", (latitude,longitude), unique = true) //foreign key def neighborhood = foreignkey("neighborhood_fk", neighborhoodid, neighborhoods.tablequery)(_.id) def * = (id.?,streetnumber,route,subpremise,neighborhoodid,latitude,longitude) <> (address.tupled,address.unapply) }

the reply utilize next check.

( //option scenario both defined (c.subpremise.isdefined && r.subpremise.isdefined && c.subpremise === r.subpremise) || //option scenario both empty (c.subpremise.isempty && r.subpremise.isempty) )

scala database-design database-schema optional slick-2.0

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -