src/Driver/Postgres/Schema/PostgresColumn.php
private static function resolveConstrains(
        DriverInterface $driver,
        $tableOID,
        PostgresColumn $column
    ) {
        $query = "SELECT conname, consrc FROM pg_constraint WHERE conrelid = ? AND contype = 'c' AND "
            . "(consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ?)";

        $constraints = $driver->query($query, [
            $tableOID,
            '(' . $column->name . '%',
            '("' . $column->name . '%',
            '(("' . $column->name . '%',
            '(("' . $column->name . '%',
            //Postgres magic
            $column->name . '::text%',
            '%(' . $column->name . ')::text%'
        ]);

        foreach ($constraints as $constraint) {
            if (preg_match('/ARRAY\[([^\]]+)\]/', $constraint['consrc'], $matches)) {
                $enumValues = explode(',', $matches[1]);
                foreach ($enumValues as &$value) {
                    if (preg_match("/^'?(.*?)'?::(.+)/", trim($value, ' ()'), $matches)) {
                        //In database: 'value'::TYPE
                        $value = $matches[1];
                    }

                    unset($value);
                }

                $column->enumValues = $enumValues;
                $column->constrainName = $constraint['conname'];
                $column->constrained = true;
            }
        }
    }
private static function resolveConstrains(
        DriverInterface $driver,
        $tableOID,
        PostgresColumn $column
    ) {
        $query = "SELECT conname, consrc FROM pg_constraint WHERE conrelid = ? AND contype = 'c' AND "
            . "(consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ?)";

        $constraints = $driver->query($query, [
            $tableOID,
            '(' . $column->name . '%',
            '("' . $column->name . '%',
            '(("' . $column->name . '%',
            '(("' . $column->name . '%',
            //Postgres magic
            $column->name . '::text%',
            '%(' . $column->name . ')::text%'
        ]);

        foreach ($constraints as $constraint) {
            if (preg_match('/ARRAY\[([^\]]+)\]/', $constraint['consrc'], $matches)) {
                $enumValues = explode(',', $matches[1]);
                foreach ($enumValues as &$value) {
                    if (preg_match("/^'?(.*?)'?::(.+)/", trim($value, ' ()'), $matches)) {
                        //In database: 'value'::TYPE
                        $value = $matches[1];
                    }

                    unset($value);
                }

                $column->enumValues = $enumValues;
                $column->constrainName = $constraint['conname'];
                $column->constrained = true;
            }
        }
    }
private static function resolveConstrains ( DriverInterface $ driver , $ tableOID , PostgresColumn $ column ) { $ query = "SELECT conname, consrc FROM pg_constraint WHERE conrelid = ? AND contype = 'c' AND " . "(consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ?)" ; $ constraints = $ driver -> query ( $ query , [ $ tableOID , '(' . $ column -> name . '%' , '("' . $ column -> name . '%' , '(("' . $ column -> name . '%' , '(("' . $ column -> name . '%' , //Postgres magic $ column -> name . '::text%' , '%(' . $ column -> name . ')::text%' ] ) ; foreach ( $ constraints as $ constraint ) { if ( preg_match ( '/ARRAY\[([^\]]+)\]/' , $ constraint [ 'consrc' ] , $ matches ) ) { $ enumValues = explode ( ',' , $ matches [ 1 ] ) ; foreach ( $ enumValues as & $ value ) { if ( preg_match ( "/^'?(.*?)'?::(.+)/" , trim ( $ value , ' ()' ) , $ matches ) ) { //In database: 'value'::TYPE $ value = $ matches [ 1 ] ; } unset ( $ value ) ; } $ column -> enumValues = $ enumValues ; $ column -> constrainName = $ constraint [ 'conname' ] ; $ column -> constrained = true ; } } }
Resolving enum constrain and converting it into proper enum values set.

@param DriverInterface $driver
@param string|int      $tableOID
@param PostgresColumn  $column
Resolving enum constrain and converting it into proper enum values set .