Commit Graph
68 Commits
Author SHA1 Message Date
Linden 6c8934f906 perf(execute): ignore results if cb is undefined
Do not parse results when a callback argument was not received.
Minor improvements to response parsing.
2022-03-27 08:37:11 +11:00
Linden f82fa72643 fix(execute): incorrect execution time for multiple queries
When sending bulk-statements using prepare, the execution time
would always be calculated based on the start of the first query.

This would mistakenly report successive queries as taking longer,
and possibly report slow queries (i.e. when saving all players).
2022-03-27 08:32:39 +11:00
Linden 9fec9cccba refactor(execute): don't use transactions for SELECT statements 2022-03-27 07:11:00 +11:00
Linden d34bbc45f5 fix(execute): properly await all query responses 2022-03-26 00:58:27 +11:00
Linden 3582e72122 refactor(execute): use transactions and parse values
Parse each value while iterating prepared statements, ensuring
objects are remapped to arrays and NULL values are properly
inserted.

Utilise transactions to rollback changes in the event of an error.
2022-03-25 19:00:29 +11:00
Linden dea98f7c5b refactor(database): move from mysql2/promise to callback api
Micro-optimisation for rawQuery. rawExecute and rawTransaction will
still utilise the promise api (pool.promise()).
2022-03-25 06:07:57 +00:00
Linden dd05cb8e68 refactor(database): response is always a callback now 2022-03-25 05:38:18 +00:00
Linden 86d85dfa00 fix(execute): handle nil parameters in prepared statements
Lua tables are msgpacked with the 'without_hole' setting, resulting
in an object. rawQuery already handles this and converts an object
into an array (filling null where appropriate).

Give rawExecute the same treatment.
2022-03-25 04:41:39 +00:00
Linden afc04fc553 fix(db): move query responses to their own try block
Other resources with script errors (notably "attempt to index a nil value") would mistakenly report the query as failed, and people would assume ANY reported errors were because of oxmysql, even through it was their own awful script.

No errors should be thrown in oxmysql when an error occurs in a function reference.
2022-03-07 15:13:07 +11:00
Linden 895d08ef0f fix(db): Define pool type 2022-03-02 22:56:47 +11:00
Linden e0a2a41870 fix(db/rawTransaction): Await scheduleTick 2022-03-02 22:56:07 +11:00
Linden 6d96c1104b refactor(db): Delay connection until first tick 2022-02-28 16:00:30 +11:00
Linden ec53b3282d refactor(utils/scheduleTick): Await database connection 2022-02-25 17:11:28 +11:00
Linden 2d28c447ec fix(db/rawExecute): Parse multiple returned rows 2022-02-24 10:59:12 +11:00
Linden 2ea78f1b1b Merge branch 'refactor' into main 2022-02-14 22:23:28 +11:00
Linden 4975a17a31 fix(db/execute): Parse responses during prepare
Prepare should return the most appropriate result type (scalar, single, query, update, etc.)
2022-02-10 16:57:28 +11:00
dunak-debug 3a1462e0c0 fix(execute): Parse parameters as intended 2022-01-04 16:10:27 +01:00
dunak-debug 4498dddbac WIP: Rewrite to TS & Cleanup 2021-12-26 02:21:46 +01:00