当Node中的列数超过18时,蒸汽构建失败了吗?

时间:2016-10-18 03:29:45

标签: vapor

我在Vapor中使用带有“makeNode”功能的“Model”,当表列数小于14时,我可以成功构建并运行项目。 但是当我的表格列到19或20时,Vapor开始非常缓慢地构建,并最终报告失败。 我尝试过使用MySQL或MongoDB,两者都有同样的问题。所以当我需要使用包含20列的表时,我想知道如何解决这个问题。 以下是详细信息:

final class TableName: Model {
    var id: Node?
    var column1: Int
    var column2: Int
    var column3: String
    var column4: String
    var column5: String
    var column6: String
    var column7: String
    var column8: String
    var column9: String
    var column10: String
    var column11: String
    var column12: String
    var column13: String
    var column14: String
    var column15: String
    var column16: String
    var createdAt: Double
    var updatedAt: Double

    init(column1: Int, column2: Int, column3: String, column4: String, column5: String, column6: String, column7: String, column8, column9: String, column10: String, column11: String, column12: String, column13: String, column14: String, column15: String, column16: String, createdAt: Double, updatedAt: Double) {
        self.id = UUID().uuidString.makeNode()
        self.column1 = column1
        self.column2 = column2
        self.column3 = column3
        self.column4 = column4
        self.column5 = column5
        self.column6 = column6
        self.column7 = column7
        self.column8 = column8
        self.column9 = column9
        self.column10 = column10
        self.column11 = column11
        self.column12 = column12
        self.column13 = column13
        self.column14 = column14
        self.column15 = column15
        self.column16 = column16
        self.createdAt = createdAt
        self.updatedAt = updatedAt
    }

    init(node: Node, in context: Context) throws {
        id = try node.extract("id")
        column1 = try node.extract("column1")
        column2 = try node.extract("column2")
        // from 2~16, etc... don't repeat here...
        updatedAt = try node.extract("updatedAt")
        createdAt = try node.extract("createdAt")
    }

    // Issue happened here... 
    // when the amount less than about 10, results are ok and build fast, 
    // but will build slowly and slowly when the number goes more and more, 
    // even build failed when table columns goes to about 18~20.
    func makeNode(context: Context) throws -> Node {
        var node = try Node(node: [
            "id": id,
            "column1": column1,
            "column2": column2,
            "column3": column3,
            "column4": column4,
            "column5": column5,
            "column6": column6,
            "column7": column7,
            "column8": column8,
            "column9": column9,
            "column10": column10,
            "column11": column11,
            "column12": column12,
            "column13": column13,
            "column14": column14,
            "column15": column15,
            "column16": column16,
            "createdAt": createdAt,
            "updatedAt": updatedAt
            ])
        return node
    }
}

构建错误消息是:

  

由于信号导致命令失败:已杀死:9

所以,我很感激能给我任何解决这个问题的提示。谢谢。

1 个答案:

答案 0 :(得分:0)

这听起来像编译器中的错误。类型提示(添加as Foo等)是一种补救困惑编译器的好方法。

将错误的完整输出报告给https://bugs.swift.org将有助于团队尽快修复错误。