renamed notnull to notNull in ORM
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils\Database\Orm;
|
||||
|
||||
@@ -45,14 +45,14 @@ class Converter
|
||||
);
|
||||
|
||||
/*
|
||||
* //pair espo:doctrine
|
||||
* //pair Espo => ORM
|
||||
*/
|
||||
protected $fieldAccordances = array(
|
||||
'type' => 'type',
|
||||
'dbType' => 'dbType',
|
||||
'maxLength' => 'len',
|
||||
'len' => 'len',
|
||||
'notnull' => 'notnull',
|
||||
'notNull' => 'notNull',
|
||||
'autoincrement' => 'autoincrement',
|
||||
'notStorable' => 'notStorable',
|
||||
'link' => 'relation',
|
||||
@@ -60,7 +60,7 @@ class Converter
|
||||
'unique' => 'unique',
|
||||
'index' => 'index',
|
||||
/*'conditions' => 'conditions',
|
||||
'additionalColumns' => 'additionalColumns', */
|
||||
'additionalColumns' => 'additionalColumns', */
|
||||
'default' => array(
|
||||
'condition' => '^javascript:',
|
||||
'conditionEquals' => false,
|
||||
@@ -199,7 +199,7 @@ class Converter
|
||||
|
||||
case 'foreignId':
|
||||
$fieldParams = array_merge($fieldParams, $this->idParams);
|
||||
$fieldParams['notnull'] = false;
|
||||
$fieldParams['notNull'] = false;
|
||||
break;
|
||||
|
||||
case 'foreignType':
|
||||
@@ -304,12 +304,12 @@ class Converter
|
||||
$fieldParams = Util::merge($fieldParams, $fieldTypeMeta['database']);
|
||||
}
|
||||
|
||||
//if defined 'notnull => false' and 'required => true', then remove 'notnull'
|
||||
if (isset($fieldParams['notnull']) && !$fieldParams['notnull'] && isset($fieldParams['required']) && $fieldParams['required']) {
|
||||
unset($fieldParams['notnull']);
|
||||
} //END
|
||||
//if defined 'notNull => false' and 'required => true', then remove 'notNull'
|
||||
if (isset($fieldParams['notNull']) && !$fieldParams['notNull'] && isset($fieldParams['required']) && $fieldParams['required']) {
|
||||
unset($fieldParams['notNull']);
|
||||
} //END
|
||||
|
||||
|
||||
|
||||
$fieldDefs = $this->getInitValues($fieldParams);
|
||||
|
||||
//check if field need to be saved in database
|
||||
@@ -448,23 +448,23 @@ class Converter
|
||||
protected function getInitValues(array $fieldParams)
|
||||
{
|
||||
$values = array();
|
||||
foreach($this->fieldAccordances as $espoType => $doctrineType) {
|
||||
foreach($this->fieldAccordances as $espoType => $ormType) {
|
||||
|
||||
if (isset($fieldParams[$espoType])) {
|
||||
|
||||
if (is_array($doctrineType)) {
|
||||
if (is_array($ormType)) {
|
||||
|
||||
$conditionRes = false;
|
||||
if (!is_array($fieldParams[$espoType])) {
|
||||
$conditionRes = preg_match('/'.$doctrineType['condition'].'/i', $fieldParams[$espoType]);
|
||||
$conditionRes = preg_match('/'.$ormType['condition'].'/i', $fieldParams[$espoType]);
|
||||
}
|
||||
|
||||
if (!$conditionRes || ($conditionRes && $conditionRes === $doctrineType['conditionEquals']) ) {
|
||||
if (!$conditionRes || ($conditionRes && $conditionRes === $ormType['conditionEquals']) ) {
|
||||
$value = is_array($fieldParams[$espoType]) ? json_encode($fieldParams[$espoType]) : $fieldParams[$espoType];
|
||||
$values = Util::merge( $values, Util::replaceInArray('{0}', $value, $doctrineType['value']) );
|
||||
$values = Util::merge( $values, Util::replaceInArray('{0}', $value, $ormType['value']) );
|
||||
}
|
||||
} else {
|
||||
$values[$doctrineType] = $fieldParams[$espoType];
|
||||
$values[$ormType] = $fieldParams[$espoType];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils\Database\Orm\Fields;
|
||||
|
||||
@@ -36,8 +36,8 @@ class LinkParent extends \Espo\Core\Utils\Database\Orm\Base
|
||||
),
|
||||
$field['name'].'Type' => array(
|
||||
'type' => 'foreignType',
|
||||
'notnull' => false,
|
||||
'index' => $field['name'],
|
||||
'notNull' => false,
|
||||
'index' => $field['name'],
|
||||
),
|
||||
$field['name'].'Name' => array(
|
||||
'type' => 'varchar',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils\Database\Schema;
|
||||
|
||||
@@ -35,11 +35,11 @@ class Converter
|
||||
|
||||
protected $typeList;
|
||||
|
||||
//pair espo::doctrine
|
||||
//pair ORM => doctrine
|
||||
protected $allowedDbFieldParams = array(
|
||||
'len' => 'length',
|
||||
'default' => 'default',
|
||||
'notnull' => 'notnull',
|
||||
'notNull' => 'notnull',
|
||||
'autoincrement' => 'autoincrement',
|
||||
'unique' => 'unique',
|
||||
);
|
||||
@@ -87,14 +87,14 @@ class Converter
|
||||
$GLOBALS['log']->debug('Schema\Converter - Start: building schema');
|
||||
|
||||
//check if exist files in "Tables" directory and merge with ormMetadata
|
||||
$ormMeta = Util::merge($ormMeta, $this->getCustomTables());
|
||||
$ormMeta = Util::merge($ormMeta, $this->getCustomTables());
|
||||
|
||||
//unset some keys in orm
|
||||
if (isset($ormMeta['unset'])) {
|
||||
$ormMeta = Util::unsetInArray($ormMeta, $ormMeta['unset']);
|
||||
unset($ormMeta['unset']);
|
||||
} //END: unset some keys in orm
|
||||
|
||||
|
||||
|
||||
$schema = $this->getSchema();
|
||||
|
||||
@@ -115,7 +115,7 @@ class Converter
|
||||
switch ($fieldParams['type']) {
|
||||
case 'id':
|
||||
$primaryColumns[] = Util::toUnderScore($fieldName);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
$fieldType = isset($fieldParams['dbType']) ? $fieldParams['dbType'] : $fieldParams['type'];
|
||||
@@ -130,13 +130,13 @@ class Converter
|
||||
}
|
||||
|
||||
//add unique
|
||||
if ($fieldParams['type']!= 'id' && isset($fieldParams['unique'])) {
|
||||
if ($fieldParams['type']!= 'id' && isset($fieldParams['unique'])) {
|
||||
$uniqueColumns = $this->getKeyList($columnName, $fieldParams['unique'], $uniqueColumns);
|
||||
} //END: add unique
|
||||
|
||||
//add index. It can be defined in entityDefs as "index"
|
||||
if (isset($fieldParams['index'])) {
|
||||
$indexList = $this->getKeyList($columnName, $fieldParams['index'], $indexList);
|
||||
$indexList = $this->getKeyList($columnName, $fieldParams['index'], $indexList);
|
||||
} //END: add index
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ class Converter
|
||||
if (!empty($uniqueColumns)) {
|
||||
foreach($uniqueColumns as $uniqueItem) {
|
||||
$tables[$entityName]->addUniqueIndex($uniqueItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check and create columns/tables for relations
|
||||
@@ -171,7 +171,7 @@ class Converter
|
||||
if (!isset($tables[$tableName])) { //no needs to create the table if it already exists
|
||||
$tables[$tableName] = $this->prepareManyMany($entityName, $relationParams, $tables);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'belongsTo':
|
||||
$foreignEntity = $relationParams['entity'];
|
||||
@@ -288,8 +288,8 @@ class Converter
|
||||
/**
|
||||
* Get key list (index, unique). Ex. index => true OR index => 'somename'
|
||||
* @param string $columnName Column name (underscore field name)
|
||||
* @param bool | string $keyValue
|
||||
* @return array
|
||||
* @param bool | string $keyValue
|
||||
* @return array
|
||||
*/
|
||||
protected function getKeyList($columnName, $keyValue, array $keyList)
|
||||
{
|
||||
@@ -314,7 +314,7 @@ class Converter
|
||||
|
||||
foreach($fileList as $fileName) {
|
||||
$fileData = $this->getFileManager()->getContents( array($this->customTablePath, $fileName) );
|
||||
if (is_array($fileData)) {
|
||||
if (is_array($fileData)) {
|
||||
$customTables = Util::merge($customTables, $fileData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
"advanced":true
|
||||
},
|
||||
"database":{
|
||||
"notnull":false
|
||||
"notNull":false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
"advanced":false
|
||||
},
|
||||
"database":{
|
||||
"notnull":false
|
||||
"notNull":false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
"advanced":true
|
||||
},
|
||||
"database":{
|
||||
"notnull":false
|
||||
"notNull":false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user