merged branch K-Phoen/propel-type-guesser (PR #8883)
This PR was merged into the master branch.
Discussion
----------
[PropelBridge] PropelTypeGuesser can now recognize columns by their phpName
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Until now, the `PropelTypeGuesser` could only find columns by their name.
Example: `created_at` was recognized but `createdAt` wasn't.
This PR adds the ability to match column's phpNames (in a case-insensitive way).
Commits
-------
764e915
[PropelBridge] PropelTypeGuesser can now recognize columns by their phpName
This commit is contained in:
commit
c6a963ddf3
@ -169,5 +169,9 @@ class PropelTypeGuesser implements FormTypeGuesserInterface
|
||||
if ($table && $table->hasColumn($property)) {
|
||||
return $this->cache[$class.'::'.$property] = $table->getColumn($property);
|
||||
}
|
||||
|
||||
if ($table && $table->hasColumnByInsensitiveCase($property)) {
|
||||
return $this->cache[$class.'::'.$property] = $table->getColumnByInsensitiveCase($property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,11 @@ class ItemQuery
|
||||
'updated_at' => \PropelColumnTypes::TIMESTAMP,
|
||||
);
|
||||
|
||||
private $caseInsensitiveMap = array(
|
||||
'isactive' => 'is_active',
|
||||
'updatedat' => 'updated_at',
|
||||
);
|
||||
|
||||
public function getTableMap()
|
||||
{
|
||||
// Allows to define methods in this class
|
||||
@ -57,6 +62,30 @@ class ItemQuery
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method from the TableMap API
|
||||
*/
|
||||
public function hasColumnByInsensitiveCase($column)
|
||||
{
|
||||
$column = strtolower($column);
|
||||
|
||||
return in_array($column, array_keys($this->caseInsensitiveMap));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method from the TableMap API
|
||||
*/
|
||||
public function getColumnByInsensitiveCase($column)
|
||||
{
|
||||
$column = strtolower($column);
|
||||
|
||||
if (isset($this->caseInsensitiveMap[$column])) {
|
||||
return $this->getColumn($this->caseInsensitiveMap[$column]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method from the TableMap API
|
||||
*/
|
||||
|
@ -114,6 +114,8 @@ class PropelTypeGuesserTest extends Propel1TestCase
|
||||
array('value', 'text', Guess::MEDIUM_CONFIDENCE),
|
||||
array('price', 'number', Guess::MEDIUM_CONFIDENCE),
|
||||
array('updated_at', 'datetime', Guess::HIGH_CONFIDENCE),
|
||||
array('isActive', 'checkbox', Guess::HIGH_CONFIDENCE),
|
||||
array('updatedAt', 'datetime', Guess::HIGH_CONFIDENCE),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user