Linden
2ea78f1b1b
Merge branch 'refactor' into main
2022-02-14 22:23:28 +11:00
Linden
3cfa080cfc
fix(utils/typeCast): Ensure field.packet is defined
...
Apparently this can be undefined.
2022-02-11 05:15:29 +11:00
Linden
7096237ce2
refactor(utils/typeCast): Change BIT and BLOB types
...
BIT fields should only cast as boolean if they have a length of 1.
2022-02-10 17:23:42 +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
Linden
18eb6d1f29
feat(lib): Lua Language Server library definitions
2022-01-29 23:40:37 +11:00
Linden
0eb6e9c72c
chore(fxmanifest): add convar_category
...
Improve support when using FxDK, allowing convars to be set in the project settings window.
2022-01-11 16:13:33 +11:00
Linden
8f7fc7bee7
Update README.md
2021-12-31 01:20:47 +11:00
Linden
64fd6249ba
fix(utils): convertNamedPlaceholders requires parameters
...
Resolves unexpected behaviour when resources send concatenated queries containing : and @
i.e. esx_status case query
2021-12-29 04:18:02 +11:00
Linden
47a33bbba7
fix(db): parseArguments during try block
...
Error catching when unexpected data is passed to query string.
2021-12-29 03:28:16 +11:00
Linden
d54bcae363
fix(db): incorrect error reporting failed queries
...
When using callback functions and throwing an error (i.e. attempt to index a nil value), it would respond about an error in a nested ref call.
Don't catch callback errors.
2021-12-28 18:41:19 +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
9b8d6d6c56
update release workflows
2021-12-25 01:58:04 +11:00
Linden
00bfcd35cc
Relicense from GPL to LGPL
...
Since lib/MySQL is loaded into a resource as a module, it would technically require any resources linking to oxmysql to be licensed under GPLv3.
LGPL exists to provide this exception when dynamically linking modules.
2021-12-24 19:31:46 +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
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
f9c33be0fe
refactor: rename exports
...
Removes _callback suffix from exports and bring some exports out of deprecation (single, scalar, etc).
"Sync" exports still use _async.
2021-12-24 03:08:06 +11:00
Linden
452d1ad5ee
fix(execute): incorrect queryCount when sending single array
...
An array containing parameters, rather than arrays, is always a single query.
2021-12-23 19:50:21 +11:00
Linden
0537519c8a
chore: update readme info and include some sample queries
2021-12-23 15:21:14 +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
e5c5fc3b1b
refactor(execute): split into execute and query
...
query refers to the old execute function.
preparedStatement renamed to execute.
Parse arguments before establishing connection.
Utilise response function to determine and return correct values to the export.
execute now accepts an array of values when performing a single query, rather than requiring an array within an array.
2021-12-23 13:56:31 +11:00
Linden
860af3ff14
refactor(transaction): parse arguments prior to establishing connection
...
Rather then acquiring a connection, throwing an error, then closing the connection.
2021-12-23 13:51:20 +11:00
Linden
0afb32858d
refactor(utils): rename parser and add additional functions
...
Create a handler for ScheduleResourceTick.
Handle serverReady function and isReady state.
Rewrite parameter parser to wrap all export arguments, ensure parameter and callbacks, and improve placeholder resolution.
Setup a response function to handle export return values.
2021-12-23 13:47:25 +11:00
Linden
f5e25e3574
refactor(config): moved typeCast function into config
2021-12-23 13:42:12 +11:00
Linden
35f198f2b5
refactor(pool): cleanup connection options and createPool defaults
...
Additionally perform initial database connection as part of this module, rather than index.
2021-12-23 13:40:54 +11:00
Linden
17c4916010
refactor: replace webpack with esbuild
2021-12-23 13:35:43 +11:00
Linden
b7a17d9566
refactor(patches): remove redundant code
...
mysql2 calls some code, namely _resolveNamedPlaceholders, that is handled by oxmysql before the query is executed.
Other changes:
Calculate query execution time as part of the Query command.
Check for undefined parameters during placeholder resolution.
2021-12-23 13:29:29 +11:00
Linden
4e29905179
fix(execute): check resourcestate is 'started' to resolve promise
2021-12-10 10:55:27 +00:00
Linden
78ce45f1de
refactor(patch/named-placeholders): performance tweaks
...
Little bit of micro-optimisation to increase speed of placeholder resolution by 2x
2021-12-10 11:19:27 +11:00
Linden
193da3e6c7
refactor(execute): execute queries after first tick
...
Force queries to wait until the server has ticked before sending anything.
2021-12-10 11:18:15 +11:00
Linden
cd2e73953f
test: re-enable slow query warnings
2021-12-10 11:17:02 +11:00
Linden
3928415930
test: revert recent changes
...
People are experiencing errors that I've been unable to reproduce, but 1.8.3 apparently works fine.
Revert changes that were made.
This disables slow query warnings for now.
2021-12-08 07:43:25 +11:00
Linden
b27662d138
Update issue templates
2021-12-07 10:58:27 +11:00
Linden
45b90c4ad3
fix: performance tweaks
...
Moved getConnection and ScheduleResourceTick above the try block.
Moved connection.release into the finally block
Increased default connection timeout to 1 minute.
2021-12-06 17:55:50 +11:00
Linden
87a5123117
fix: JS sync exports check
...
Since JS is such a bad language it throws an error when doing `variable !== undefined`, so wrap the whole thing in a try block and catch the error.
2021-12-04 03:22:53 +11:00
Linden
94fe76340e
fix: undefined values
...
Various mistakes from 1.8.1
2021-12-02 19:32:38 +11:00
Linden
b7763141b7
fix(transactions): resolve error when executing transaction
2021-12-02 08:19:22 +11:00
Linden
bf2d729a39
feat: mysql2 patch-package
2021-12-01 03:46:05 +11:00
Linden
a352273b08
refactor(execute): await connection to send query
...
Waiting for the connection to become available lets us move executiontime back into the resource.
2021-12-01 03:42:44 +11:00
Linden
e685ff5f4c
refactor: minor cleanup and formatting
2021-12-01 02:52:48 +11:00
Linden
dbe107e669
refactor: enable JS exports for more recent artifacts
...
We still don't have a bump in recommended artifact, so for now check for the existence of new(ish) native.
2021-12-01 02:51:05 +11:00
Linden
3e266ec952
chore: update dependencies
2021-12-01 00:41:29 +11:00
Linden
cd2b5db342
Update fxmanifest.lua
2021-11-30 04:05:22 +11:00
Linden
f3fc016f31
refactor(pool): new createConnection function
...
Remove the connection string parsing and send the URI directly, if it exists. For semicolon connection strings, check for and replace aliases.
2021-11-25 20:29:02 +11:00
Linden
381627266f
chore: update version
2021-11-15 09:10:57 +11:00
Linden
f779ba4228
chore: update packages
2021-11-15 09:10:37 +11:00
Linden
b004ec943d
refactor(pool): permit extra user and password aliases
2021-11-15 09:09:52 +11:00
Linden
647243f1cf
fix(lib): incorrect safeArgs for Sync.transaction (callback)
...
Additionally no longer sending Resource argument since oxmysql can handle that already.
2021-11-11 18:06:36 +11:00
Linden
12e9ccbc8a
feat(lua): update http link and version checking
2021-10-31 08:32:27 +11:00
Linden
2a9b14ce54
chore(lua): update fxmanifest version
2021-10-31 07:18:55 +11:00
Linden
f7949db0d3
chore(workflow): update run tasks
2021-10-31 07:17:45 +11:00
Linden
2a14ab1e21
refactor(webpack): update patterns and do not minify
2021-10-31 06:48:30 +11:00
Linden
9de50f684f
refactor(lua): remove file check and move to subdirectory
2021-10-31 06:48:00 +11:00
Linden
2c90290c84
fix(wrapper): check if oxmysql.js exists via io function
2021-10-29 09:26:01 +11:00
Linden
9fc06c2132
refactor(versioncheck): remove module and perform check with Lua
...
Unnecessary dependency with functionality that can be easily handled via PerformHttpRequest.
Since the check references fxmanifest instead, we will no longer maintain the version in package.json.
2021-10-29 08:14:39 +11:00
Linden
def891268b
feat(wrapper): throw an error when no build exists
...
Many people refuse to download releases, instead opting for the source code. Throw an error and include a link to the direct download.
2021-10-29 07:08:36 +11:00
Linden
4913d6e50a
chore: Version bump
2021-10-24 02:15:10 +11:00
Linden
ca8cef4e26
refactor(prepare): Rename prepared export to prepare
2021-10-24 02:13:55 +11:00
Linden
2a8f4b1ea9
feat: Add an export to call prepared statements ( #54 )
...
* feat: Add an export to call prepared queries
- Utilises pool.execute (rather than query) to actually prepare parameters through mysql.
This is intended for appropriately built queries utilising placeholders and parameters, and should only be used on frequently repeated queries.
* refactor(prepare): Clean up results and add total execution time
* feat(prepare): Send scalar response for a single value
* fix(prepare): Check if result exists before getting keys
2021-10-23 09:05:01 +11:00
Linden
1d0a5bcfd9
Update issue templates
2021-10-23 08:55:54 +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
f7ed2d5b60
chore: Bump version
2021-10-19 04:41:55 +11:00
Linden
ec9d787be4
fix: Resolve null length on some queries
...
- Ensure parameters when checking length, and update dependencies for mysql2 patch
2021-10-19 04:26:08 +11:00
Linden
abf259543d
chore: Update version and dependencies
2021-10-18 02:19:09 +11:00
Linden
9d8a29388c
fix(parser): Only assign null values if placeholders were found
2021-10-18 01:52:22 +11:00
Linden
00f9d0449c
fix(regex): Prevent converting JSON in queries into placeholders
...
- When a JSON string is entered as part of a query, rather than a parameter, it is assumed to define a named placeholder - this will check for quotations and ignore it
2021-10-18 01:51:37 +11:00
Linden
a46b586832
Merge pull request #51 from darksaid98/main
...
fix(parse): Resolve nil parameters when using `['@key'] = val`
2021-10-17 04:16:04 +11:00
Linden
b1babdbc09
chore: Update version
2021-10-17 02:04:09 +11:00
Linden
f8f97344fd
Merge pull request #50 from darksaid98/varatstart
...
fix: Parameter keys beginning with ':' & '@'
2021-10-17 01:58:24 +11:00
Linden
fe1d6e6b05
fix(config): Reset colour after version check message
2021-10-16 10:46:29 +11:00
Linden
c1f5bb3375
chore: Version bump
2021-10-16 10:43:27 +11:00
Linden
d4e367baaf
fix(lib): Allow transactions to utilise safeArgs function
...
- Also updates luadocs
2021-10-16 10:24:00 +11:00
Linden
ce87bc488c
fix(parser): Allow queries with multiple placeholders and no parameters
...
- '...?, ?, ?', {nil, nil, nil} will set all placeholders to null
2021-10-16 10:20:35 +11:00
Linden
dc55401b78
fix: Return boolean for TINYINT
2021-10-16 10:20:35 +11:00
Linden
3b55e890a8
fix: Display correct query execution time
2021-10-16 10:20:35 +11:00
Linden
bacd9c171d
chore: Point mysql2 dependency to fork
...
I'd like some control over incoming changes to fit our use-case, and patch-package doesn't quite fulfil our needs.
2021-10-16 10:20:35 +11:00
Linden
29d28197bb
chore: Version bump dependencies
2021-10-16 10:20:35 +11:00
Linden
4646c6f027
fix: Assign object entries to array
...
Assigning the entries to an array first permits comparing the lengths and setting undefined entries as null
2021-10-16 10:20:35 +11:00
Linden
30a391031b
fix: Resolve error when parameter length does not match
...
- Throws a more specific error when receiving mismatch for column and value counts
- Resolves error when final parameter is nil
2021-10-16 10:20:35 +11:00
Linden
22de50c081
Apply mysql2 patch
...
- Remove extra _resolveNamedPlaceholders call from query
- Apply several patches by github/testn (pending merge); refer to pull requests #1408 , #1402 , #1401 , #1400
- Optimise query.row call
- Cache lazy-evaluated field
- Optimise string decoding
- Avoid leaking TextRow/BinaryRow
2021-10-16 10:20:35 +11:00
Linden
d0730c5e9b
feat: Add support for nil parameters
...
- Throws an error if no params are defined when using named parameters, otherwise seems okay
2021-10-16 10:20:35 +11:00
Linden
b781f0ca45
feat(lib): Setup support for lua docs
2021-10-15 18:41:17 +11:00
Linden
31959beb85
fix(manifest): Disable server_only
...
- Until dependencies can be used for server only resources, disable this to prevent clients failing to load.
2021-10-11 03:22:55 +11:00
Linden
de2c731295
chore: Update comments for function return values
2021-10-08 15:58:11 +11:00
Linden
1266f4a7b6
chore: Update dependencies and version bump
2021-10-08 11:17:50 +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
5b55c81046
chore: Update readme
2021-10-08 05:47:34 +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
Linden
1ec52903ca
feat: Add support for semicolon connection strings
2021-10-07 06:26:07 +11:00
Linden
7e5d4cce06
chore: Version bump and set to production
2021-09-27 10:13:36 +10:00
Linden
681b39692a
fix(pool): Increase default connection timeout
...
- Servers taking a while to start may experience a timeout; this should alleviate the issue
2021-09-27 10:13:11 +10:00
Linden
273a4a8a89
Merge pull request #27 from gixels/main
...
Implemented the ability to change the port.
2021-09-23 05:03:27 +10:00
Linden
c5f150e003
improvement: Only display warnings if callback is defined
...
- Non-function callbacks will display a warning.
- This makes the third argument optional for async queries.
2021-09-19 04:25:42 +10:00
Linden
5e6547611b
refactor: safeCallback provides a warning, rather than an error
...
- The query does in fact proceed, but does not send a result
2021-09-18 11:08:21 +10:00
Linden
be221b70d3
feat: Enable JS sync exports if wrapper.lua is not loaded
2021-09-18 10:28:40 +10:00
Linden
f7dea332de
improvement: Provide information when callback fails
2021-09-18 10:27:16 +10:00
Linden
d2758de972
tweak: Query execution times are less precise unless using debug mode
2021-09-18 10:24:06 +10:00