Ticket #711 (closed defect: fixed)

Opened 18 months ago

Last modified 16 months ago

Doctrine::generateModelsFromDb does not recognize MySQL 'bit' type

Reported by: karlkatzke Owned by: somebody
Priority: critical Milestone: 0.10.3
Component: Other Version: 0.10.0
Severity: Keywords:
Cc: Has Test:
Status: Has Patch:

Description (last modified by karlkatzke) (diff)

With a table that has a 'bit' datatype, I get an error that 'bit' datatype is an unknown database attribute type.

[04-Jan-2008 18:55:12] PHP Fatal error:  Uncaught exception 'Doctrine_DataDict_Exception' with message 'unknown database attribute type: bit' in /Users/karlkatzke/work/corpworlds/library/Doctrine-Beta2/Doctrine-1.0.0/lib/Doctrine/DataDict/Mysql.php:379
Stack trace:
#0 /Users/karlkatzke/work/corpworlds/library/Doctrine-Beta2/Doctrine-1.0.0/lib/Doctrine/Import/Mysql.php(128): Doctrine_DataDict_Mysql->getPortableDeclaration(Array)
#1 /Users/karlkatzke/work/corpworlds/library/Doctrine-Beta2/Doctrine-1.0.0/lib/Doctrine/Import.php(218): Doctrine_Import_Mysql->listTableColumns('log_logins')
#2 /Users/karlkatzke/work/corpworlds/library/Doctrine-Beta2/Doctrine-1.0.0/lib/Doctrine.php(671): Doctrine_Import->importSchema('/Users/karlkatz...', Array)
#3 /Users/karlkatzke/work/corpworlds/html/export.php(13): Doctrine::generateModelsFromDb('/Users/karlkatz...')
#4 {main}
  thrown in /Users/karlkatzke/work/corpworlds/library/Doctrine-Beta2/Doctrine-1.0.0/lib/Doctrine/DataDict/Mysql.php on line 379

This is in 1.0 beta 2.

BIT is a valid mysql datatype as fo 5.0.3, according to  http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

Table creation SQL:

CREATE TABLE  `corpworlds`.`log_logins` (
  `id` int(11) NOT NULL auto_increment,
  `datetime` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `login` varchar(40) default NULL,
  `user_id` int(10) default NULL,
  `ip_address` varchar(25) NOT NULL,
  `browser` varchar(100) default NULL,
  `os` varchar(100) default NULL,
  `success` bit(1) NOT NULL default '',
  PRIMARY KEY  (`id`),
  KEY `fk_user_id_logins` (`user_id`),
  CONSTRAINT `fk_user_id_logins` FOREIGN KEY (`user_id`) REFERENCES `acl_users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Log of all logins that happened.'

Change History

  Changed 18 months ago by karlkatzke

I'm sorry, I incorrectly stated the version as 1.0 beta 3; it's 1.0 beta 2.

  Changed 18 months ago by karlkatzke

I'm not sure how to generate patches as I didn't download from Subversion, but this fixed it for me:

39c39
<                           'BLOB', 'BOTH', 'BY',
---
>                           'BLOB', 'BOTH', 'BY', 'BIT',
227a228,229
>             case 'bit':
>               return 'BIT';
377a380,382
>             case 'bit':
>                 $type[] = 'bit';
>             break;
470c475
< }
 No newline at end of file
---
> }

  Changed 18 months ago by karlkatzke

  • description modified (diff)

Oh, and more extensive testing of this is *definitely* needed. For instance, the default value is a '' ... a bitwise false, and I can see that in the model dump it put "'default' => '00'," ... which may or may not work too hot.

follow-up: ↓ 6   Changed 18 months ago by jwage

hmm, what file did you make these changes in?

  Changed 18 months ago by jwage

  • milestone changed from beta3 to 1.0

in reply to: ↑ 4   Changed 18 months ago by karlkatzke

Replying to jwage:

hmm, what file did you make these changes in?

I left my laptop at home today, but IIRC: trunk/lib/Doctrine/DataDict/Mysql.php

  Changed 16 months ago by jwage

  • version set to Trunk
  • milestone changed from 1.0 to 0.10.3

  Changed 16 months ago by jwage

  • version changed from Trunk to 0.10

  Changed 16 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [3927]) fixes #711 - Added mysql bit column type support.

Note: See TracTickets for help on using tickets.