本文整理汇总了Golang中github.com/senarukana/rationaldb/schema.Table类的典型用法代码示例。如果您正苦于以下问题:Golang Table类的具体用法?Golang Table怎么用?Golang Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Table类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getInsertPKValues
func getInsertPKValues(pkColumnNumbers []int, rowList *Node, tableInfo *schema.Table) (pkValues []interface{}) {
pkValues = make([]interface{}, len(pkColumnNumbers))
for index, columnNumber := range pkColumnNumbers {
if columnNumber == -1 {
pkValues[index] = tableInfo.GetPKColumn(index).Default
continue
}
values := make([]interface{}, rowList.Len())
for j := 0; j < rowList.Len(); j++ {
if columnNumber >= rowList.At(j).At(0).Len() { // NODE_LIST->'('->NODE_LIST
panic(NewParserError("Column count doesn't match value count"))
}
node := rowList.At(j).At(0).At(columnNumber) // NODE_LIST->'('->NODE_LIST->Value
value := node.execAnalyzeValue()
if value == nil {
log.Warn("insert is too complex %v", node)
return nil
}
values[j] = asInterface(value)
}
if len(values) == 1 {
pkValues[index] = values[0]
} else {
pkValues[index] = values
}
}
return pkValues
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:28,代码来源:execution.go
示例2: buildValueList
// buildValueList builds the set of PK reference rows used to drive the next query.
// It uses the PK values supplied in the original query and bind variables.
// The generated reference rows are validated for type match against the PK of the table.
func buildValueList(tableInfo *schema.Table, pkValues []interface{}, bindVars map[string]interface{}) [][]sqltypes.Value {
length := -1
for _, pkValue := range pkValues {
if list, ok := pkValue.([]interface{}); ok {
if length == -1 {
if length = len(list); length == 0 {
panic(NewTabletError(FAIL, "empty list for values %v", pkValues))
}
} else if length != len(list) {
panic(NewTabletError(FAIL, "mismatched lengths for values %v", pkValues))
}
}
}
if length == -1 {
length = 1
}
valueList := make([][]sqltypes.Value, length)
for i := 0; i < length; i++ {
valueList[i] = make([]sqltypes.Value, len(pkValues))
for j, pkValue := range pkValues {
if list, ok := pkValue.([]interface{}); ok {
valueList[i][j] = resolveValue(tableInfo.GetPKColumn(j), list[i], bindVars)
} else {
valueList[i][j] = resolveValue(tableInfo.GetPKColumn(j), pkValue, bindVars)
}
}
}
return valueList
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:32,代码来源:codex.go
示例3: applyFilterWithPKDefaults
func applyFilterWithPKDefaults(tableInfo *schema.Table, columnNumbers []int, input []sqltypes.Value) (output []sqltypes.Value) {
output = make([]sqltypes.Value, len(columnNumbers))
for colIndex, colPointer := range columnNumbers {
if colPointer >= 0 {
output[colIndex] = input[colPointer]
} else {
output[colIndex] = tableInfo.GetPKColumn(colIndex).Default
}
}
return output
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:11,代码来源:codex.go
示例4: buildINValueList
// buildINValueList builds the set of PK reference rows used to drive the next query
// using an IN clause. This works only for tables with no composite PK columns.
// The generated reference rows are validated for type match against the PK of the table.
func buildINValueList(tableInfo *schema.Table, pkValues []interface{}, bindVars map[string]interface{}) [][]sqltypes.Value {
if len(tableInfo.PKColumns) != 1 {
panic("unexpected")
}
valueList := make([][]sqltypes.Value, len(pkValues))
for i, pkValue := range pkValues {
valueList[i] = make([]sqltypes.Value, 1)
valueList[i][0] = resolveValue(tableInfo.GetPKColumn(0), pkValue, bindVars)
}
return valueList
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:14,代码来源:codex.go
示例5: testTables
func testTables() *schema.Table {
t := new(schema.Table)
t.Name = "user"
t.AddColumn("id", "int", sqltypes.NULL, "", true)
t.AddColumn("name", "string", sqltypes.NULL, "", false)
index := t.AddIndex("PRIMARY")
index.AddColumn("id", 0)
t.PKColumns = []int{0}
return t
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:12,代码来源:schema_info.go
示例6: buildSecondaryList
// buildSecondaryList is used for handling ON DUPLICATE DMLs, or those that change the PK.
func buildSecondaryList(tableInfo *schema.Table, pkList [][]sqltypes.Value, secondaryList []interface{}, bindVars map[string]interface{}) [][]sqltypes.Value {
if secondaryList == nil {
return nil
}
valueList := make([][]sqltypes.Value, len(pkList))
for i, row := range pkList {
valueList[i] = make([]sqltypes.Value, len(row))
for j, cell := range row {
if secondaryList[j] == nil {
valueList[i][j] = cell
} else {
valueList[i][j] = resolveValue(tableInfo.GetPKColumn(j), secondaryList[j], bindVars)
}
}
}
return valueList
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:18,代码来源:codex.go
示例7: execAnalyzeSelectExpressions
func (node *Node) execAnalyzeSelectExpressions(table *schema.Table) (selects []int) {
selects = make([]int, 0, node.Len())
for i := 0; i < node.Len(); i++ {
if name := node.At(i).execAnalyzeSelectExpression(); name != "" {
if name == "*" {
for colIndex := range table.Columns {
selects = append(selects, colIndex)
}
} else if colIndex := table.FindColumn(name); colIndex != -1 {
selects = append(selects, colIndex)
} else {
panic(NewParserError("Column %s not found in table %s", name, table.Name))
}
} else {
// Complex expression
return nil
}
}
return selects
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:20,代码来源:execution.go
注:本文中的github.com/senarukana/rationaldb/schema.Table类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论