Skip to content

fix(es_extended/server/functions): persist items added via AddItems - #1813

Closed
seltonmt012 wants to merge 1 commit into
esx-framework:devfrom
seltonmt012:fix/additems-db-insert
Closed

fix(es_extended/server/functions): persist items added via AddItems#1813
seltonmt012 wants to merge 1 commit into
esx-framework:devfrom
seltonmt012:fix/additems-db-insert

Conversation

@seltonmt012

Copy link
Copy Markdown

ESX.AddItems adds the items to ESX.Items but they never end up in the database.

MySQL.prepare batch mode wants an array of positional parameter arrays, but toInsert is a list of keyed tables, so the ? placeholders get nothing and the INSERT silently does nothing. In-game it looks fine because ESX.Items is filled from the same keyed tables, but after a restart the items are gone since they were never saved.

Fixed by building a positional parameters array before the prepared insert.

Tested locally on artifact 25770 with MariaDB: added an item through AddItems and confirmed the row is now written to the items table.

Closes #1768

  • My commit messages and PR title follow the Conventional Commits standard.
  • My changes have been tested locally and function as expected.
  • My PR does not introduce any breaking changes.
  • I have provided a clear explanation of what my PR does.

MySQL.prepare.await batch mode expects an array of positional parameter
arrays, but toInsert holds keyed tables, so the placeholders received no
values and the INSERT silently did nothing. Items still showed up in-game
because ESX.Items was populated from the keyed tables, but nothing was
written to the items table. Build a positional parameters array for the
prepared insert.

Closes esx-framework#1768
@seltonmt012

Copy link
Copy Markdown
Author

Got an answer on Discord: contributions should target the branch that becomes the next release, so v1.14.1 instead of dev. Redoing this one on top of v1.14.1, closing here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant