Fix dictionary_id type mismatch in addWordsHandler (v2.0.7)
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 35s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 35s
This commit is contained in:
@@ -917,8 +917,10 @@ func (a *App) addWordsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
for i, wordReq := range req.Words {
|
||||
var id int
|
||||
dictionaryID := defaultDictID
|
||||
var dictIDParam interface{} = nil
|
||||
if wordReq.DictionaryID != nil {
|
||||
dictionaryID = *wordReq.DictionaryID
|
||||
dictIDParam = dictionaryID
|
||||
// Проверяем, что словарь принадлежит пользователю
|
||||
var dictUserID int
|
||||
err := tx.QueryRow(`
|
||||
@@ -939,7 +941,7 @@ func (a *App) addWordsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
err := stmt.QueryRow(wordReq.Name, wordReq.Translation, wordReq.Description, wordReq.DictionaryID, dictionaryID, userID).Scan(&id)
|
||||
err := stmt.QueryRow(wordReq.Name, wordReq.Translation, wordReq.Description, dictIDParam, dictionaryID, userID).Scan(&id)
|
||||
if err != nil {
|
||||
log.Printf("Error inserting word %d (name='%s', dict_id=%d, user_id=%d): %v", i, wordReq.Name, dictionaryID, userID, err)
|
||||
sendErrorWithCORS(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
Reference in New Issue
Block a user