Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

CanHas_One Relation


Reply


3 Posts   489 Views

Avatar
melatonin

Community Member, 6 Posts

25 March 2014 at 2:53am

Hi i am searching on a nullable has_one relation.
What is the solution to realize it?

Thank you.

Avatar
melatonin

Community Member, 6 Posts

29 March 2014 at 2:01am

anybody an idea?

Avatar
swaiba

Forum Moderator, 1799 Posts

2 April 2014 at 4:33am

Hi melatonin,

AFAIK the has_one Relationship will populated with 0, not NULL.
But if you want to identify this with SQL, specifically MySQL, you can use...

SELECT * FROM MyTable WHERE MyField IS NULL;
OR
SELECT * FROM MyTable WHERE COALESCE(MyField,0) = 0

(COALESCE means it goes through all param left to right and returns the first param that is NOT NULL)