当前位置: 首页>>代码示例>>Golang>>正文


Golang Table.GetPKColumn方法代码示例

本文整理汇总了Golang中github.com/senarukana/rationaldb/schema.Table.GetPKColumn方法的典型用法代码示例。如果您正苦于以下问题:Golang Table.GetPKColumn方法的具体用法?Golang Table.GetPKColumn怎么用?Golang Table.GetPKColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/senarukana/rationaldb/schema.Table的用法示例。


在下文中一共展示了Table.GetPKColumn方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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

示例2: 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

示例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: 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


注:本文中的github.com/senarukana/rationaldb/schema.Table.GetPKColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。