Sorry, the uncommented "todo not working" was left in by me so it wouldn't compile. It won't work when I fix that either, of course.
func getListField(db *sql.DB, table string, item string, field string) ( > string, error) { > tableName := listFieldToTableName(table, field) > if !TableExists(db, tableName) { > return "", errors.New(fmt.Sprintf("list field %s does not exist > in table %s", field, table)) > } > if !FieldExists(db, tableName, field) { > return "", errors.New(fmt.Sprintf("internal error, %s does not > have a field %s", tableName, field)) > } > todo not working > if HasListFieldValue(db, tableName, item, field) { > return "", errors.New(fmt.Sprintf("NULL list field %s of item %s > in table %s", field, item, table)) > } > rows, err := db.Query(fmt.Sprintf(`SELECT ? FROM "%s" WHERE Owner=?`, > tableName), field, item) > if err != nil { > return "", errors.New(fmt.Sprintf("list field %s of item %s in > table %s not found: %s", field, item, table, err)) > } > results := make([]string, 0) > for rows.Next() { > var datum sql.NullString > if err := rows.Scan(&datum); err != nil { > rows.Close() > return "", errors.New(fmt.Sprintf("cannot retrieve list field > %s of item %s in table %s: %s", field, item, table, err)) > } > if !datum.Valid { > rows.Close() > return "", errors.New(fmt.Sprintf("NULL for field %s of item > %s in table %s", field, item, table)) > } > results = append(results, datum.String) > } > rows.Close() > if err := rows.Err(); err != nil { > return "", errors.New(fmt.Sprintf("cannot retrieve list field %s > of item %s in table %s: %s", field, item, table, err)) > } > return strings.Join(results, "\n"), nil > } > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.