本文整理汇总了Golang中github.com/cloudwan/gohan/schema.Schema.Properties方法的典型用法代码示例。如果您正苦于以下问题:Golang Schema.Properties方法的具体用法?Golang Schema.Properties怎么用?Golang Schema.Properties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudwan/gohan/schema.Schema
的用法示例。
在下文中一共展示了Schema.Properties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Context("Relation column name", func() {
It("Generate foreign key with default column name when relationColumn not available", func() {
table, _ := sqlConn.GenTableDef(server, false)
Expect(table).To(ContainSubstring("REFERENCES `networks`(id)"))
})
It("Generate foreign key with given column same as relationColumn from property", func() {
server.Properties = append(server.Properties, schema.NewProperty(
"test",
"test",
"",
"test",
"string",
"subnet",
"cidr",
"",
"varchar(255)",
false,
false,
false,
nil,
nil,
false,
))
table, _, err := sqlConn.AlterTableDef(server, false)
Expect(err).ToNot(HaveOccurred())
Expect(table).To(ContainSubstring("REFERENCES `subnets`(cidr)"))
})
})
Context("With default cascade option", func() {
示例2:
Expect(table).To(ContainSubstring("REFERENCES `networks`(id) on delete cascade);"))
table = sqlConn.GenTableDef(subnet, false)
Expect(table).ToNot(ContainSubstring("REFERENCES `networks`(id) on delete cascade);"))
})
})
Context("Properties modifed", func() {
It("Generate proper alter table statements", func() {
server.Properties = append(server.Properties, schema.NewProperty(
"test",
"test",
"",
"test",
"string",
"",
"",
"varchar(255)",
false,
false,
false,
nil,
nil,
))
table, err := sqlConn.AlterTableDef(server, true)
Expect(err).ToNot(HaveOccurred())
Expect(table).To(ContainSubstring("alter table`servers` add (`test`varchar(255));"))
})
})
})
})