Skip to content

Commit

Permalink
Added fix to db-based codegen for special FK labeling
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeho committed Oct 20, 2009
1 parent bb7ff26 commit 39d8b06
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions includes/qcodo/_core/codegen/QDatabaseCodeGen.class.php
Expand Up @@ -1056,9 +1056,9 @@ protected function GetForeignKeyForSqlRelationshipDefinition($strTableName, $str

// Add Constraint
$strPattern .= '(add[\s]+)?(constraint[\s]+';
$strPattern .= '[\[\`\'\"]?(' . $this->strPatternKeyName . ')[\]\`\'\"]?[\s]+)?';
$strPattern .= '[\[\`\'\"]?(' . $this->strPatternKeyName . ')[\]\`\'\"]?[\s]+)?[\s]*';
// Foreign Key
$strPattern .= 'foreign[\s]+key[\s]*\(';
$strPattern .= 'foreign[\s]+key[\s]*(' . $this->strPatternKeyName . ')[\s]*\(';
$strPattern .= '([^)]+)\)[\s]*';
// References
$strPattern .= 'references[\s]+';
Expand All @@ -1070,11 +1070,11 @@ protected function GetForeignKeyForSqlRelationshipDefinition($strTableName, $str
// Perform the RegExp
preg_match($strPattern, $strLine, $strMatches);

if (count($strMatches) == 8) {
$strColumnName = trim($strMatches[5]);
$strReferenceTableName = trim($strMatches[6]);
$strReferenceColumnName = trim($strMatches[7]);
$strFkName = $strMatches[4];
if (count($strMatches) == 9) {
$strColumnName = trim($strMatches[6]);
$strReferenceTableName = trim($strMatches[7]);
$strReferenceColumnName = trim($strMatches[8]);
$strFkName = $strMatches[5];
if (!$strFkName)
$strFkName = sprintf('virtualfk_%s_%s', $strTableName, $strColumnName);

Expand Down

0 comments on commit 39d8b06

Please sign in to comment.