Bug Report #4393

MySQL enum doesn't handle values with parentheses

Added by Alexey Serikov 4 months ago. Updated 4 months ago.

Status:Closed Start date:01/09/2012
Priority:Normal Due date:
Assignee:Chris Bandy % Done:

100%

Category:-
Target version:Kohana v3.x - v3.1.5
Resolution:fixed Points:1

Description

My inserts didn't work until tracked this down:

I have a field in my database. This field's Type looks like "enum('student','professional','retired','other (see description)')".
Kohana_Database::_parse_type, when parsing this thing, returns "enum')" as its type, and "'student','professional','retired','other (see description" as its length.

I am sure, including parentheses while defining a field type is not the best practice, but when dealing with legacy code and especially database structures, it's good to know that everything else is working as it's supposed to.

To work this around I came with

else if (strpos($type, 'enum') === 0 || strpos($type, 'set') === 0) {
list($type, $len) = explode('(', $type, 2);
$len = '('.$len;
return( array($type, $len) );
}

just underneath the first if in that method.


Related issues

blocks Database - Bug Report #4394: MySQL enum doesn't handle values with parentheses Kohana v3.x - v3.2.1 Closed 01/09/2012

Associated revisions

Revision a7e8d984
Added by Chris Bandy 4 months ago

MySQL: Handle ENUM values with parentheses. Fixes #4393

History

Updated by Woody Gilk 4 months ago

  • Status changed from New to Assigned
  • Assignee set to Chris Bandy

Updated by Chris Bandy 4 months ago

  • Target version set to v3.1.5

Updated by Chris Bandy 4 months ago

  • Resolution set to fixed

Updated by Chris Bandy 4 months ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Updated by Jeremy Bush 4 months ago

  • Subject changed from Enum glitch to MySQL enum doesn't handle values with parentheses

Also available in: Atom PDF