Doctrine considers empty string as null (I mean Oracle)

We are on the last stretch of our project and we need to deliver soon.

Sometimes, we have to make concessions and compromises in order to make sure to deliver in time.
This means coding something that is not necessarly clean.

We wanted to use a column that could have 3 different significations.
The column was already a varchar2 and we needed to keep it that way for legacy reasons.

The possible values we wanted were:

  • value was a positive float (I already said it was a varchar2, yuk) which represent a salary
  • value was null which represented that the user did not want to disclosed the salary.
  • value was an empty string which represent a salary to be discussed.

The problem was that when using Doctrine to insert/update the field when using an empty string, it would insert/update a null instead.

We first thought the problem was Doctrine but we later found out the problem was Oracle.
As far as Oracle is concerned, an empty string and null are totally the same thing.

Maybe I am too used to MySQL but this seems like a WTF to me.

So we cannot do our dirty hack. Using empty string and null to mean something different is not kosher.

I realized that this oracle "feature" have a consequence. If we were using MySQL than it would mean that an empty string would also be considered null (for compatibility reasons).
(http://www.doctrine-project.org/projects/orm/1.2/docs/manual/configurati...)

Thoughts?

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • You may post PHP code. You should include <?php ?> tags.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options