Skip to content

Commit

Permalink
removed blob/text default value checks, implemented unquote of defaul…
Browse files Browse the repository at this point in the history
…t values on TEXT/BLOB fields
  • Loading branch information
manfred-w committed Mar 5, 2024
1 parent 1ca6543 commit 0e00958
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/Propel/Generator/Platform/MysqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,6 @@ public function getColumnDDL(Column $col): string
if ($def && $def->isExpression()) {
throw new EngineException('DATE columns cannot have default *expressions* in MySQL.');
}
} elseif ($sqlType === 'TEXT' || $sqlType === 'BLOB') {
if ($domain->getDefaultValue()) {
throw new EngineException('BLOB and TEXT columns cannot have DEFAULT values. in MySQL.');
}
}

$ddl = [$this->quoteIdentifier($col->getName())];
Expand Down
9 changes: 8 additions & 1 deletion src/Propel/Generator/Reverse/MysqlSchemaParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,14 @@ public function getColumnFromRow(array $row, Table $table): Column
}

// BLOBs can't have any default values in MySQL
$default = preg_match('~blob|text~', $nativeType) ? null : $row['Default'];

$default = $row['Default'];
if (!empty($default)) {
if (preg_match('~blob|text~', $nativeType)) {
// mariadb has extra single quotes on TEXT type default values, but not on other types
$default = preg_replace('@^\'(.*)\'$@', '$1', $row['Default']);
}
}

$propelType = $this->getMappedPropelType($nativeType);
if (!$propelType) {
Expand Down

0 comments on commit 0e00958

Please sign in to comment.