src/Builder/TypeTableBuilder.php
public function prepareGeneratedFieldStatement(FieldInterface $source_field, ValueExtractorInterface $extractor)
    {
        $generated_field_name = $this->getConnection()->escapeFieldName($extractor->getFieldName());

        switch ($extractor->getValueCaster()) {
            case ValueCasterInterface::CAST_INT:
                $field_type = 'INT';
                break;
            case ValueCasterInterface::CAST_FLOAT:
                $field_type = 'DECIMAL(12, 2)';
                break;
            case ValueCasterInterface::CAST_BOOL:
                $field_type = 'TINYINT(1) UNSIGNED';
                break;
            case ValueCasterInterface::CAST_DATE:
                $field_type = 'DATE';
                break;
            case ValueCasterInterface::CAST_DATETIME:
                $field_type = 'DATETIME';
                break;
            case ValueCasterInterface::CAST_JSON:
                $field_type = 'JSON';
                break;
            default:
                $field_type = 'VARCHAR(191)';
        }

        $expression = $this->prepareGeneratedFieldExpression(
            $this->getConnection()->escapeFieldName($source_field->getName()),
            var_export($extractor->getExpression(), true),
            $extractor->getValueCaster(),
            $this->getConnection()->escapeValue($extractor->getDefaultValue())
        );
        $storage = $extractor->getStoreValue() ? 'STORED' : 'VIRTUAL';

        return trim("$generated_field_name $field_type AS ($expression) $storage");
    }
public function prepareGeneratedFieldStatement(FieldInterface $source_field, ValueExtractorInterface $extractor)
    {
        $generated_field_name = $this->getConnection()->escapeFieldName($extractor->getFieldName());

        switch ($extractor->getValueCaster()) {
            case ValueCasterInterface::CAST_INT:
                $field_type = 'INT';
                break;
            case ValueCasterInterface::CAST_FLOAT:
                $field_type = 'DECIMAL(12, 2)';
                break;
            case ValueCasterInterface::CAST_BOOL:
                $field_type = 'TINYINT(1) UNSIGNED';
                break;
            case ValueCasterInterface::CAST_DATE:
                $field_type = 'DATE';
                break;
            case ValueCasterInterface::CAST_DATETIME:
                $field_type = 'DATETIME';
                break;
            case ValueCasterInterface::CAST_JSON:
                $field_type = 'JSON';
                break;
            default:
                $field_type = 'VARCHAR(191)';
        }

        $expression = $this->prepareGeneratedFieldExpression(
            $this->getConnection()->escapeFieldName($source_field->getName()),
            var_export($extractor->getExpression(), true),
            $extractor->getValueCaster(),
            $this->getConnection()->escapeValue($extractor->getDefaultValue())
        );
        $storage = $extractor->getStoreValue() ? 'STORED' : 'VIRTUAL';

        return trim("$generated_field_name $field_type AS ($expression) $storage");
    }
public function prepareGeneratedFieldStatement ( FieldInterface $ source_field , ValueExtractorInterface $ extractor ) { $ generated_field_name = $ this -> getConnection ( ) -> escapeFieldName ( $ extractor -> getFieldName ( ) ) ; switch ( $ extractor -> getValueCaster ( ) ) { case ValueCasterInterface :: CAST_INT : $ field_type = 'INT' ; break ; case ValueCasterInterface :: CAST_FLOAT : $ field_type = 'DECIMAL(12, 2)' ; break ; case ValueCasterInterface :: CAST_BOOL : $ field_type = 'TINYINT(1) UNSIGNED' ; break ; case ValueCasterInterface :: CAST_DATE : $ field_type = 'DATE' ; break ; case ValueCasterInterface :: CAST_DATETIME : $ field_type = 'DATETIME' ; break ; case ValueCasterInterface :: CAST_JSON : $ field_type = 'JSON' ; break ; default : $ field_type = 'VARCHAR(191)' ; } $ expression = $ this -> prepareGeneratedFieldExpression ( $ this -> getConnection ( ) -> escapeFieldName ( $ source_field -> getName ( ) ) , var_export ( $ extractor -> getExpression ( ) , true ) , $ extractor -> getValueCaster ( ) , $ this -> getConnection ( ) -> escapeValue ( $ extractor -> getDefaultValue ( ) ) ) ; $ storage = $ extractor -> getStoreValue ( ) ? 'STORED' : 'VIRTUAL' ; return trim ( "$generated_field_name $field_type AS ($expression) $storage" ) ; }
Prpeare generated field statement.

@param  FieldInterface          $source_field
@param  ValueExtractorInterface $extractor
@return string
Prpeare generated field statement .