vue-library
vue-library copied to clipboard
Having issues accessing the /books route locally
I believe the SQL query behind BooksService.findAndCountAll() is producing this error for me:
original: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0', '10'' at line 1
at Packet.asError (/home/nher1625/Development/vue-library/1-Project/backend-sql/node_modules/mysql2/lib/packets/packet.js:684:17)
at Query.execute (/home/nher1625/Development/vue-library/1-Project/backend-sql/node_modules/mysql2/lib/commands/command.js:28:26)
at Connection.handlePacket (/home/nher1625/Development/vue-library/1-Project/backend-sql/node_modules/mysql2/lib/connection.js:449:32)
at PacketParser.onPacket (/home/nher1625/Development/vue-library/1-Project/backend-sql/node_modules/mysql2/lib/connection.js:72:12)
at PacketParser.executeStart (/home/nher1625/Development/vue-library/1-Project/backend-sql/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.<anonymous> (/home/nher1625/Development/vue-library/1-Project/backend-sql/node_modules/mysql2/lib/connection.js:79:25)
at Socket.emit (events.js:311:20)
at addChunk (_stream_readable.js:294:12)
at readableAddChunk (_stream_readable.js:275:11)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlState: '42000',
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0', '10'' at line 1",
sql: "SELECT `id`, `isbn`, `title`, `author`, `numberOfCopies`, `stock`, `status`, `importHash`, `createdAt`, `updatedAt`, `deletedAt`, `createdById`, `updatedById` FROM `books` AS `book` WHERE ((`book`.`deletedAt` > '2020-03-21 19:49:43' OR `book`.`deletedAt` IS NULL)) ORDER BY `book`.`createdAt` DESC LIMIT '0', '10';"
},
sql: "SELECT `id`, `isbn`, `title`, `author`, `numberOfCopies`, `stock`, `status`, `importHash`, `createdAt`, `updatedAt`, `deletedAt`, `createdById`, `updatedById` FROM `books` AS `book` WHERE ((`book`.`deletedAt` > '2020-03-21 19:49:43' OR `book`.`deletedAt` IS NULL)) ORDER BY `book`.`createdAt` DESC LIMIT '0', '10';"
}
I've identified that the issue lies in the syntax of this query:
SELECT `id`, `isbn`, `title`, `author`, `numberOfCopies`, `stock`, `status`, `importHash`, `createdAt`, `updatedAt`, `deletedAt`, `createdById`, `updatedById` FROM `books` AS `book` WHERE ((`book`.`deletedAt` > '2020-03-21 19:49:43' OR `book`.`deletedAt` IS NULL)) ORDER BY `book`.`createdAt` DESC LIMIT '0', '10';
I experienced the same