record keeps track of the mapping between referenced foreign columns and the blank node label Consider the "person" table fname varchar(50) lname varchar(50) company varchar(50) employee_id int primary key (fname, lname) index unique (company, employee_id) and it is referenced by the "salary" table
(info *sqlTable, values []interface{},
blankNode string)
| 113 | // _:person_John_Doe, which is used further to create the Dgraph link between a salary row |
| 114 | // and the person row |
| 115 | func (r *fkValuesRecorder) record(info *sqlTable, values []interface{}, |
| 116 | blankNode string) { |
| 117 | for _, cst := range info.cstSources { |
| 118 | // for each foreign key constraint, there should be a mapping |
| 119 | cstColumns := getCstColumns(cst) |
| 120 | cstColumnIndices := getColumnIndices(info, |
| 121 | func(info *sqlTable, column string) bool { |
| 122 | _, ok := cstColumns[column] |
| 123 | return ok |
| 124 | }) |
| 125 | |
| 126 | refLabel, err := createLabel(&ref{ |
| 127 | allColumns: info.columns, |
| 128 | refColumnIndices: cstColumnIndices, |
| 129 | tableName: info.tableName, |
| 130 | colValues: values, |
| 131 | }) |
| 132 | if err != nil { |
| 133 | if !quiet { |
| 134 | logger.Printf("ignoring the constraint because of error "+ |
| 135 | "when getting ref label: %+v\n", cst) |
| 136 | } |
| 137 | continue |
| 138 | } |
| 139 | r.refToBlank[refLabel] = blankNode |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | func getCstColumns(cst *fkConstraint) map[string]interface{} { |
| 144 | columnNames := make(map[string]interface{}) |
nothing calls this directly
no test coverage detected