Bug #33704

SQL parser does not support NULL as default value

Added by Xavier Perseguers over 10 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Should have
Category:
Database API (Doctrine DBAL)
Target version:
Start date:
2012-02-06
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
4.6
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When preparing a database schema with proper referential integrity, one typically has to choose NULL as default value for foreign keys:

CREATE TABLE tx_myext_domain_model_member (
    uid int(11) NOT NULL auto_increment,
    pid int(11) DEFAULT '0' NOT NULL,

    some_fk int(11) DEFAULT NULL,

However, database analyzer does not support NULL as default value and shows an empty string ('') instead, thus suggesting that the underlying table structure is invalid and should be adapted.

#1

Updated by Markus Klein over 10 years ago

I had a look at these things a while ago. I discovered that the MySQL driver for PHP actually doesn't tell you the difference between a default '' and defaul NULL. It always returns '' (with type string).
So I'm not entirely sure, whether we can really fix this.

#2

Updated by Xavier Perseguers over 10 years ago

I have the 3-line fix. I just have to test it with DBAL.

#3

Updated by Gerrit Code Review over 10 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/8861

#4

Updated by Markus Klein over 10 years ago

I had a very similar fix and it didn't work with native mysql access. (I didn't test with DBAL back then.)
I hope yours is working better.

#5

Updated by Xavier Perseguers over 10 years ago

It works fine with native MySQL for me.

#6

Updated by Markus Klein over 10 years ago

Just for the sake of completeness, this was the discussion about default values:
http://lists.typo3.org/pipermail/typo3-english/2011-December/078504.html

And the referenced mysql ticket:
http://bugs.mysql.com/bug.php?id=34198

#7

Updated by Gerrit Code Review over 10 years ago

Patch set 1 for branch TYPO3_4-6 has been pushed to the review server.
It is available at http://review.typo3.org/8879

#8

Updated by Xavier Perseguers over 10 years ago

  • Status changed from Under Review to Resolved
  • Target version set to 4.6.5
  • % Done changed from 0 to 100
#9

Updated by Riccardo De Contardi almost 5 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF