专栏""在表格中宣布两次" status"在Propel 2中

时间:2015-01-16 14:10:40

标签: sql-server propel

我试图使用Propel 2从MSSQL数据库反向生成模式。我像往常一样设置了我的YAML配置文件:

dbname:
    adapter: mssql
    classname: Propel\Runtime\Connection\ConnectionWrapper
    dsn: "dblib:host=123.456.789.012;dbname=dbname"
    user: username
    password: password
    attributes:

当我运行命令propel reverse 'dbname'时,我收到错误:

[Propel\Generator\Exception\EngineException]
Column "" declared twice in table "Status"

这显然是扔在这里: https://github.com/propelorm/Propel2/blob/master/src/Propel/Generator/Model/Table.php#L499 @ r499

为什么Propel会尝试添加“空”'列?当我查看数据库表Status的设计时,我的SQL服务器管理工​​作室根本不显示空列,它只显示它包含的两列(uidname)。

编辑: 所以我开始深入研究Propel的代码,这里似乎出错了: https://github.com/propelorm/Propel2/blob/62859fd0ed3520b7d7afbbdeac113edaf160982b/src/Propel/Generator/Reverse/MssqlSchemaParser.php#L124

 protected function addColumns(Table $table)
    {
        $dataFetcher = $this->dbh->query("sp_columns '" . $table->getName() . "'");
        foreach ($dataFetcher as $row) {
            $name = $this->cleanDelimitedIdentifiers($row['COLUMN_NAME']);

$table->getName()正确返回正确的表名。当我打印dataFetcher时,它是一个PDO对象。然而: $row给出以下数组:

Array(
    [0] => My DBname
    [1] => My DBprefix
    [2] => Status
    [3] => uid
    [4] => 4
    [5] => int identity
    etc. no string indices hence COLUMN_NAME is empty.

1 个答案:

答案 0 :(得分:1)

(代表OP发布)

这是Propel MSSQL架构解析器中的一个错误:https://github.com/propelorm/Propel2/issues/863