Ошибка: ER_PARSE_ERROR: у вас есть ошибка в синтаксисе SQL; Дата Время - PullRequest
1 голос
/ 13 июля 2020

Код обновляет пользователя, добавляя идентификаторы других пользователей в строку, когда я передаю объект этой функции, который удовлетворяет получаемым мной значениям

 async addToPlayerGame(queueItem) {
    // update the row with the userId and start round1
    this.gameState = process.env.GAME_ROUND1;
    let sql = `UPDATE gamequeue SET secondPlayer=${
      this.firstPlayer
    }, gameState=${this.gameState} 
    WHERE firstPlayer=${queueItem.firstPlayer} AND secondPlayer=${
      queueItem.secondPlayer
    } AND createdAt=${new Date(queueItem.createdAt)} AND playerType=${
      queueItem.playerType
    }`;

    return await query(sql);
  }
async function query(sql) {
  try {
    result = await db.query(sql);
    return { err: null, result: result };
  } catch (error) {
    return { err: error.toString(), result: null };
  }
}

Но при этом я получаю эту ошибку

"Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Jul 13 2020 17:42:49 GMT+0530 (India Standard Time) AND playerType=1' at line 2"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...