As an example, if the employee table has 3 columns (f_name, l_name, and title), where f_name and l_name together form the primary key. Then a row with values John (f_name), Doe (l_name), Software Engineer (title) would generate a blank node label _:person_John_Doe using values from the primary key c
(info *sqlTable, values []interface{})
| 33 | // would generate a blank node label _:person_John_Doe using values from the primary key columns |
| 34 | // in the alphabetic order, that is f_name, l_name in this case. |
| 35 | func (g *usingColumns) generate(info *sqlTable, values []interface{}) string { |
| 36 | if g.primaryKeyIndices == nil { |
| 37 | g.primaryKeyIndices = getColumnIndices(info, func(info *sqlTable, column string) bool { |
| 38 | return info.columns[column].keyType == primary |
| 39 | }) |
| 40 | } |
| 41 | |
| 42 | // use the primary key indices to retrieve values in the current row |
| 43 | var parts []string |
| 44 | parts = append(parts, info.tableName) |
| 45 | for _, columnIndex := range g.primaryKeyIndices { |
| 46 | strVal, err := getValue(info.columns[columnIndex.name].dataType, |
| 47 | values[columnIndex.index]) |
| 48 | if err != nil { |
| 49 | logger.Fatalf("Unable to get string value from primary key column %s", columnIndex.name) |
| 50 | } |
| 51 | parts = append(parts, strVal) |
| 52 | } |
| 53 | |
| 54 | return fmt.Sprintf("_:%s", strings.Join(parts, separator)) |
| 55 | } |
| 56 | |
| 57 | // A usingCounter generates blank node labels using a row counter |
| 58 | type usingCounter struct { |
nothing calls this directly
no test coverage detected