Linden
37a3a7cd0a
fix(config): don't set connection info with falsey key
...
When using the semicolon connection string, a trailing semicolon
displays an error about an invalid configuration option.
2023-07-12 00:09:00 +10:00
Linden
b2387fc33a
refactor: minor tweaks and cleanup
...
Primarily moving connectionOptions fully to config.
Removed exported resource name.
Include error code and number when database connection fails.
2023-07-12 00:05:29 +10:00
Linden
197b92891a
refactor(database): query profiling
2023-07-11 18:40:03 +10:00
Linden
ef7f4156df
chore: update dependencies
...
mysql2 patch no longer includes types, profiling, or connection attributes.
2023-07-11 17:23:56 +10:00
Linden
fa0068e798
refactor(database): use mysql2/promise
...
Better code-flow.
Other minor changes to config.
Remove profiling (temp).
2023-07-11 16:33:01 +10:00
Linden
0caaec43e4
fix(utils/parseExecute): only set undefined parameters to null
...
Falsey values (e.g. empty string) should not be set as null.
2023-07-06 12:56:44 +10:00
Linden
8a340d60e3
refactor(utils/parseExecute): allow other methods through prepare calls
2023-07-06 12:52:14 +10:00
Linden
e1b0ff7299
fix(lib/lua): missing rawExecute.await
...
Resolves #185 .
2023-06-20 08:05:35 +10:00
Linden
9a990ca4bd
chore(lib): bump package version
2023-06-18 05:05:56 +10:00
Linden
1829ded03c
fix: don't throw errors outside of promises
2023-06-18 04:14:33 +10:00
Linden
c97a07a377
feat: isReady and awaitConnection exports
2023-06-13 02:42:54 +10:00
Linden
11b21f8ed2
refactor(db): rename serverReady variable
2023-06-13 02:23:33 +10:00
Linden
2ad0539107
refactor(lib/lua): reorganise and rewrite function factory
2023-06-13 02:18:19 +10:00
Linden
e8f1abcab7
feat(rawExecute): "prepare" alternative without unpacking
...
See #179 . Always return an array of row results (or null).
Parameters are now optional (though preferred).
2023-06-06 14:37:05 +10:00
Linden
fe9c684bf0
chore: readme
2023-05-18 18:46:23 +10:00
Linden
be8580396c
chore: patch mysql2
2023-03-07 15:44:14 +11:00
Linden
b772cd2bd2
chore: update dependencies
...
Include last changes for node package.
2023-03-07 02:13:49 +11:00
Linden
61d78dc893
chore(lib): typos
2023-01-28 16:30:35 +11:00
Linden
571691c2f5
Update README.md
2023-01-28 16:25:43 +11:00
Linden
e67557992e
chore: update dependencies & patches
...
Something will probably break.
2023-01-20 16:23:40 +11:00
Linden
5a949b9546
fix(database): throw Error before creating promise
...
Promises, even when resolved/rejected immediately after their creation, will
destroy any useful information from a stack trace when used over
events/exports.
Since some people still use the exports rather than MySQL/lib.lua, and for
some reason don't know the correct syntax for Lua exports (i.e. using
exports.oxmysql.query instead of the CORRECT exports.oxmysql:query) it's
comically common for an "untraceable" error to get spit out.
Will this help? No. Will everyone expect me to solve their issues? Yes.
Go update your scripts to use MySQL/lib.lua and we can all get along
stress-free.
2022-11-18 08:58:43 +11:00
Linden
4bff0109ca
fix(config): update mysql_debug when using oxmysql_debug command
...
Polling change isn't very compatible with this; will change in the future, but
for now keep it simple.
2022-11-08 18:06:52 +11:00
Linden
bc8a874743
refactor(database): waitForConnection
2022-11-08 17:29:05 +11:00
Linden
2a5e110e29
fix(database/rawExecute): append extra null values
2022-11-08 16:57:51 +11:00
Linden
283e3194cf
fix(utils/parseExecute): incorrect parameter reassignment
2022-11-08 16:57:02 +11:00
Linden
25f8feb793
fix(execute): handle nil values in nested arrays
...
Lua tables are msgpacked with the "without_hole" setting.
Nested tables being sent with "prepare" failed to account for
nil values in tables unpacking into objects.
2022-11-08 15:17:01 +11:00
Linden
b5190f98e9
refactor(src/config): poll convars
2022-11-07 16:58:56 +11:00
Linden
70a464fb83
fix(src/config): only parse JSON for valid connection fields
...
Should have set valid keys in the first place.
Resolves #147
2022-11-03 05:08:00 +11:00
Linden
c292cb44b0
refactor(lib/define): improve Lua types
2022-10-12 18:35:01 +11:00
Linden
b604a3c356
fix(src/config): parse JSON objects in connection string
...
Some connection properties take an object/array (i.e. ssl, flags).
2022-09-21 14:10:23 +10:00
Linden
8fe63bc88a
chore: update dependencies and patch
2022-09-21 13:57:55 +10:00
Linden
6b0e20aed3
chore: include .yarn.installed
...
Since the cfx yarn resource will forcibly try to run for resources even if
they don't want it or support it, I'll add this dumb file when using source code.
2022-08-24 20:22:45 +10:00
Linden
ff00cd0e82
fix(utils/parseArguments): check parameter truthiness
2022-08-24 18:41:05 +10:00
Linden
77f0d32e07
fix(update): correct semver comparison
2022-08-23 20:14:58 +10:00
Linden
f0dd9ce1a6
fix(utils): named placeholders check
...
Should always check parameters is an object (and not an array).
2022-08-13 17:12:48 +10:00
Linden
71c32f9d2f
tweak(utils): check if namedPlaceholders are enabled
...
Named placeholders were being converted regardless of config flag.
2022-08-13 16:23:47 +10:00
Linden
521aa8f03d
refactor: move connectionOptions to config
...
We'll also ensure namedPlaceholders is boolean and export the object.
2022-08-13 16:22:45 +10:00
Linden
7796c80f69
feat(config): add command to modify mysql_debug
...
Allow toggling debug prints for specific resources during runtime.
2022-08-12 19:47:30 +10:00
Linden
c92d1f3219
tweak(logger): mysql_debug array-check
...
If the convar output is an array, check if the query was invoked by
a resource in mysql_debug.
2022-08-12 18:56:22 +10:00
Linden
fca0b66fc8
tweak(config): accept a JSON array for mysql_debug
2022-08-12 18:54:32 +10:00
Linden
211d678b8d
chore(fxmanifest): update description
...
oxmysql has always worked with RedM, but habit leads to FiveM bias.
2022-08-09 03:03:57 +10:00
Linden
8ea5aad876
ci(release): version bumper
2022-07-28 14:54:38 +10:00
Linden
613570167c
feat: provide exports for ghmattimysql
...
Rather than people weirdly renaming the resource, just provide event
handlers for ghmattimysql exports.
2022-07-28 14:48:23 +10:00
Linden
1477812b38
refactor(lib/lua): improve definitions
...
Improve return types and support callbacks.
2022-07-12 14:23:39 +10:00
Linden
1b8bf6a081
refactor(lib/lua): safeargs type checks and cb reassignment
2022-07-12 13:33:53 +10:00
Linden
31212e0198
refactor(lib/ts): improve typing and methods
2022-07-12 00:47:06 +10:00
Linden
bdd4814f06
fix(update): return if current version is higher than release
...
The version checker will report a "major update" if fxmanifest's version
is higher than the latest release (a tag has not been pushed).
2022-06-26 22:56:25 +10:00
Linden
d80615bddc
fix(db): handle errors during callbacks
...
Handles errors that would previously disappear into the void or show as 'undefined'.
In Lua this would only occur if yielding during the query callback response.
Cross runtime error handling is suffering.
2022-06-26 04:02:50 +10:00
Linden
db0f29db42
fix(utils/parseTransaction): check for array
2022-06-26 04:01:11 +10:00
Linden
5fc56caddf
fix(db/rawQuery): handle uncaught promise
...
oxmysql is unexpectedly catching errors thrown by the Lua runtime
when an error occurs during a function reference.
This lead to an 'undefined' error being thrown, specifically when
yielding a thread during the function reference.
Not really an oxmysql bug, so this should just be a temporary workaround.
2022-06-24 14:14:37 +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
a709f67e99
chore: version bump
2022-06-18 14:19:50 +10:00
Linden
a76ce68e9c
fix(db): supportBigNumbers
...
BIGINT columns will lose precision at a certain length.
This connection flag will typecast to a string in those situations.
Resolves #121 .
2022-06-18 14:14:03 +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
21e73c17b8
refactor(db/execute): mysql2 callback api
...
Attempt #2 ; last attempt had some connection issue.
Minor performance improvement, more noticeable with bulk queries.
2022-06-16 18:09:09 +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
340ca48012
refactor: error handling
...
Add boolean to disable throwing error for query.
Reject promises when using _async exports.
Return errors as strings instead of Error (fails to serialise).
Fixes #122
2022-06-04 14:50:49 +10:00
Linden
2e751a3537
chore: version bump
2022-05-16 04:46:26 +10:00
Linden
db5fe3e557
fix(utils/parseExecute): executeType fails when query has multiple lines
2022-05-15 03:25:41 +10:00
Linden
56729ef9c1
fix(db): ignore errors during ref call
2022-05-12 08:49:29 +10:00
Linden
7752b7fc12
chore: update packages
2022-05-12 08:48:18 +10:00
Linden
fc0c025db2
Update README.md
2022-04-30 04:37:05 +10:00
Linden
fda3cab3b5
chore: version bump
2022-04-30 04:14:28 +10:00
Linden
5d69db51da
refactor(database): new URI parser
2022-04-30 04:13:31 +10:00
Linden
c07fa4a451
refactor(transaction): support new transaction syntax
...
Adds a third accepted syntax for transactions, distinct from the mysql-async
compatible implementations.
2022-04-21 13:25:40 +10:00
Linden
da83eff989
revert(execute): transaction api
...
Somebody, somewhere, will experience compatibility issues with any
change made to oxmysql.
2022-04-21 12:07:47 +10:00
Linden
57bf223a7d
refactor(lib/lua): safeArgs error messages
2022-04-18 23:08:59 +10:00
Linden
23bcf90885
refactor(update): add convar for mysql_versioncheck
...
For those who don't like to be reminded of updates.
Also don't report errors during fetch, since it doesn't matter to users.
2022-04-03 06:14:21 +11:00
Linden
050eef58b9
fix(execute): revert to promise api
...
Several reports of increased chances to hit a deadlock since v2.2.2, and
three reports of a timeout during prepare since v2.2.4.
Simpler to revert to the old prepare function and api (with improvements)
than to work out the solution.
Look into rewriting prepare in the future or including the mariadb connector,
which doesn't suffer from the same perf issues.
2022-04-03 06:10:13 +11:00
Linden
fa1cdcc668
fix(execute): incorrect response parsing
...
Fixes several regressions and issues from ef0dfaa .
Sending a single parameter would set 'single' to true, ignoring multiple
results from the database and returning 'null'.
SELECT should not trigger transactions, not the other way around.
Results should not be parsed when no callback is defined.
2022-04-03 03:52:07 +11:00
Linden
9511af734b
chore: update version
2022-04-03 01:27:51 +11:00
Linden
9ef9b0d8c9
fix(utils/typeCast): typeerror
...
BLOB's with a value of null cannot be iterated, resulting in an
error while trying to return [...field.buffer()].
Minor change to weird typecasting on date values.
2022-04-02 19:52:58 +11:00
Linden
c9e402ccdc
fix(query): less verbose errors
2022-04-02 01:37:56 +11:00
Linden
defe3afb75
refactor(index): redundant code
2022-03-30 05:55:48 +11:00
Linden
ef0dfaac84
refactor(execute): remove mysql2 promise api
...
Changing from promises to callbacks gives ~20% increased performance.
Single prepared statements won't use transactions (no extra overhead).
2022-03-30 05:54:54 +11:00
Linden
7b01898959
refactor(transaction): individual transaction logging
...
I should bother patching mysql2 types, but idc
2022-03-27 08:55:20 +11:00
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
920252f138
chore: update packages
2022-03-25 19:13:25 +11:00
Linden
d45e98f38e
chore: update version and workflows
2022-03-25 19:01:06 +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
901e6c0baa
refactor(index): simpler creation of async exports
2022-03-25 05:32:11 +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
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
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
7b4ae91dbe
chore: remove annoying commit lint and husky
2022-03-07 15:10:22 +11:00
Linden
4bbbe1efc2
refactor(index): cease resistance against 0 iq fivem community
...
Why did I think maintaining this type of resource would be a good idea?
2022-03-03 19:51:00 +11:00
Linden
98b4f108e8
chore: update dependencies and commit lint
2022-03-03 00:04:27 +11:00
Linden
cd62fdd904
refactor(utils/parseArguments): Reduce redundant assignments
...
More in-line with 1.9.3 parser; reduced garbage and improved performance. Should handle JSON better.
2022-03-02 23:24:52 +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
9e50d8ddd0
fix(utils/parseArguments): Missing type check
2022-02-28 16:01:08 +11:00
Linden
6d96c1104b
refactor(db): Delay connection until first tick
2022-02-28 16:00:30 +11:00
Linden
31d971837d
fix(update): Catch errors when fetching GitHub API
2022-02-25 17:23:46 +11:00
Linden
ec53b3282d
refactor(utils/scheduleTick): Await database connection
2022-02-25 17:11:28 +11:00