Commit Graph
24 Commits
Author SHA1 Message Date
Linden 1b8bf6a081 refactor(lib/lua): safeargs type checks and cb reassignment 2022-07-12 13:33:53 +10:00
Linden 15884fbc82 refactor: error handling
Meant to push this before release.
Ensures errors are handled as before, regardless of using exports
or lib/mysql; for compatibility.
2022-06-18 16:32:07 +10:00
Linden bccd6a1035 fix: error handling when using callbacks
Only allow manual error handling when using the await/sync methods,
or when calling the default exports.

Async/Callback returns need to throw errors for compatibility.
2022-06-17 21:40:27 +10:00
Linden 7496cf0400 feat(lib): handle errors inside invoking resource
Make the source of the error more apparent.
2022-06-04 14:54:20 +10:00
Linden 57bf223a7d refactor(lib/lua): safeArgs error messages 2022-04-18 23:08:59 +10:00
Linden b6f850dbd6 Revert "refactor(lib/MySQL): use coroutine instead of promise"
This reverts commit 7582973e4e.

Calling coroutine.yield causes issues with the Lua scrt's scheduling. Notably, calling Citizen.Wait will result in the thread never being resumed.
2022-03-23 03:35:05 +11:00
Linden 7582973e4e refactor(lib/MySQL): use coroutine instead of promise
Less overhead and garbage.
2022-03-19 16:51:14 +11:00
Linden 75eedcbb09 fix(lib): accept cb.__cfx_functionReference during safeArgs 2021-12-28 01:36:03 +11:00
Linden 893b802029 fix(lib): set correct alias for execute
MySQL-async syntax was calling the execute export rather than update.
2021-12-25 04:10:09 +11:00
Linden a12e6d8a94 fix(lib): safeArgs requires transaction for await 2021-12-24 17:37:21 +11:00
Linden 03b94c749f refactor(lib): MySQL.Sync and MySQL.Async shared __index method
Apply the same metatable and create both cb and promise variants when one is called.
Improve assertion error messages.
2021-12-24 17:35:27 +11:00
Dunak a047e21f51 fix(lib): Pass transaction to safeArgs 2021-12-23 22:37:50 +01:00
Linden e86bf26221 fix(lib): ensure safeArgs when using __call method
This asserts types and checks stored queries when sending a number.
2021-12-24 03:59:39 +11:00
Linden fc06cab6eb fix(lib): don't clear alias table
I'll fix that up later.
2021-12-24 03:51:18 +11:00
Linden 3fc3cfeecf feat(lib): setup new export wrappers with mysql-async aliases
i.e.
MySQL.Async.fetchAll = MySQL.query
MySQL.Sync.fetchAll = MySQL.query.await
MySQL.Async.fetchScalar = MySQL.scalar
MySQL.Sync.fetchScalar = MySQL.scalar.await

More information in issue #77
2021-12-24 03:31:36 +11:00
Linden 36dd8ddd14 refactor: utilise new exports and deprecate old ones
Exports now utilise more accurate names to reflect their behaviour, with less confusion for JS users (await executeSync is no more).

Exports return promises or callback results directly to reduce promise chaining.

Promise exports now fully utilise JS, with Lua being removed from the resource - version checking runs through JS instead.

Various improvements to lib/MySQL as well as introduction of a prepare wrapper.
2021-12-23 14:15:17 +11:00
Linden 9de50f684f refactor(lua): remove file check and move to subdirectory 2021-10-31 06:48:00 +11:00
Linden 5965442e48 refactor(lib): Update formatting for improved LDoc usage
- This makes it easier to see which function is being defined, but also allows LDocs / Emmy Annotations / whatever to display the full function name.
2021-10-19 08:50:42 +11:00
Linden d4e367baaf fix(lib): Allow transactions to utilise safeArgs function
- Also updates luadocs
2021-10-16 10:24:00 +11:00
Linden b781f0ca45 feat(lib): Setup support for lua docs 2021-10-15 18:41:17 +11:00
Linden de2c731295 chore: Update comments for function return values 2021-10-08 15:58:11 +11:00
H@merandLinden 93ff6bae45 fix: Incorrect exports used in sync functions for transaction, single, and insert
* Fix insert return worng value.

* fix: Use the correct functions for execute/fetchAll

Co-authored-by: Linden <[email protected]>
2021-10-08 14:00:47 +11:00
Linden a06cf65d10 feat(lib): safeArguments function to assert types
- Ensures each argument has the expected type
- Refactor each function for reduced code duplication
- Correctly check Store for number queries (Async functions did not retrieve string)
2021-10-08 05:51:07 +11:00
Linden 4b179191d4 feat: Imports file for "mysql-async" like usage
- Include `server_script '@oxmysql/lib/MySQL.lua'` in the resource manifest

Mostly untested
2021-10-07 07:42:03 +11:00