diff --git a/src/Generator/ActiveRecord/Command.php b/src/Generator/ActiveRecord/Command.php index c71f2f48..93d6d3ec 100644 --- a/src/Generator/ActiveRecord/Command.php +++ b/src/Generator/ActiveRecord/Command.php @@ -24,7 +24,7 @@ public function __construct( private readonly string $namespace = 'App\\Model', #[Required] #[Regex( - pattern: '/^[a-z_][a-z0-9_]*$/i', + pattern: '/^[\w-]+\.?[\w-]*$/i', message: 'Invalid table name' )] #[TableExistsRule] diff --git a/src/Validator/TableExistsHandler.php b/src/Validator/TableExistsHandler.php index 6f550940..87fba40c 100644 --- a/src/Validator/TableExistsHandler.php +++ b/src/Validator/TableExistsHandler.php @@ -28,7 +28,12 @@ public function validate(mixed $value, object $rule, ValidationContext $context) $result = new Result(); - $tableSchema = $this->connection->getTableSchema($value); + try { + $tableSchema = $this->connection->getTableSchema($value); + } catch (\Yiisoft\Db\Exception\Exception $e) { + $result->addError($e->getMessage()); + return $result; + } if ($tableSchema === null) { $result->addError(sprintf('Table "%s" does not exist.', $value));