Skip to content

fix SQL parameter passing in setProps to save complex modifications#1786

Open
rock1565 wants to merge 2 commits into
esx-framework:mainfrom
rock1565:main
Open

fix SQL parameter passing in setProps to save complex modifications#1786
rock1565 wants to merge 2 commits into
esx-framework:mainfrom
rock1565:main

Conversation

@rock1565

Copy link
Copy Markdown

Description

改进了sql语句 使其更难出现问题

Motivation

使用复杂改装时常常无法保存我的改装 一路排查到这 为避免后续的人们遇到问题 所以我决定贡献

Implementation Details

MySQL.update.await 期望第二个参数是一个数组
但 setProps() 方法将它们作为单独的参数传递,导致 UPDATE 查询静默失败 在第170行给参数加上大括号就能解决

Usage Example

原来:
local affectedRows = MySQL.update.await("UPDATE `owned_vehicles` SET `vehicle` = ? WHERE `plate` = ? AND `owner` = ?", json.encode(newProps), vehicleData.plate, vehicleData.owner)
现在:
local affectedRows = MySQL.update.await("UPDATE owned_vehicles SET vehicle = ? WHERE plate = ? AND owner = ?",{ json.encode(newProps), vehicleData.plate, vehicleData.owner })

PR Checklist

  • [ y] My commit messages and PR title follow the Conventional Commits standard.
  • [ y] My changes have been tested locally and function as expected.
  • [ y] My PR does not introduce any breaking changes.
  • [ y] I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

@CLAassistant

CLAassistant commented Jun 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rock1565 rock1565 changed the title 使用改车插件时该语句导致状态无法更新 用更好的方式处理了 fix SQL parameter passing in setProps to save complex modifications Jun 11, 2026
@ASTROWwwW

ASTROWwwW commented Jun 22, 2026

Copy link
Copy Markdown

Nice catch on the param binding. One small thing though. This also strips the backticks off the identifiers (`owned_vehicles` `vehicle` etc). Works fine since none are reserved words but I'd keep them to match setPlate and setOwner right above and stay safe if a column ever clashes with a keyword.

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.

3 participants