Closed DavidePastore closed 10 years ago
NULL and empty string are different, so this wouldn't be appropriate, I think.
One way to handle it is to add NOT NULL DEFAULT ''
to your column definition in your database, so that you prevent NULLs on the data side.
@tag: The problem is that the field is of DATE type. If I set it to a NOT NULL DEFAULT ''
it will set to the 00:00:00
value.
There won't be any casting on NULL to an empty string for the reasons @tag states.
I am not sure why there is an issue with Twig, but a number of users have reported it as being a recursive call triggering it.
Unfortunately I have never experienced this bug despite using both Idiorm and Twig in projects so I have been unable to observe it.
I'll try to create a simple project where the problem arises.
I use Twig as well, and for various design reasons haven't encountered this error. Off the top of my head, I wonder whether a custom Twig filter might help with the issue as well.
This is a thread where there is the same problem.
This solution is a little forced.
The real problem is that the application crashes when you try to access to that field via twig. Even a simple check to see if the variable is defined leads to a crash.
I created this project to reproduce the same issue. Check it and the instructions in README.md.
Hi,
Same issue here :(
Thank you for all the effort you have put in here. Does anyone have any time to put together a pull request that fixes this issue? I am struggling to find the time to test this out.
I have a database with 'birth_date' column, which can be NULL or a date.
If I use plain 'echo' to output birth_day, it works in either case - as null and as a date.
If however I'm using Twig as a template engine and accessing birthday through Twig, it works ONLY when there is a date. If there is NULL, then application crashes and browser gives me back ERR_EMPTY_RESPONSE. Nothing more.
I'm pretty sure the problem occurs somewhere in the ORM, but I can't figure out how to solve it. I'd like to have just and empty string outputed in Twig if there's a NULL in db.
This isn't a problem of Twig because if I pass to it a null value, it simply doesn't print it.