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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

CanHas_One Relation


Go to End


3 Posts   1015 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, 1899 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)