Skip to content

fix: add missing space before WHERE in DeviceMapper.update (#2239) - #2241

Merged
648540858 merged 1 commit into
648540858:2.7.3from
CieveMe:fix/2239-deviceMapper-update-space
Oct 20, 2026
Merged

648540858 merged 1 commit into
648540858:2.7.3from
CieveMe:fix/2239-deviceMapper-update-space

Conversation

@CieveMe

@CieveMe CieveMe commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #2239

What was wrong

On the 2.7.3 branch, DeviceMapper.update() renders the statement with the WHERE keyword glued to the previous parameter:

UPDATE wvp_device SET ..., server_id=?WHERE device_id=?

PostgreSQL rejects it:

org.postgresql.util.PSQLException: ERROR: trailing junk after parameter at or near "$22WHERE"

This path runs during startup: SipRunner iterates over every device with on_line = true and calls deviceMapper.update(). So any deployment that ever had an online device fails on every restart ("Application run failed"), and with restart: always it loops forever.

Root cause

src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java on 2.7.3:

                ", server_id=#{serverId}" +
                "WHERE device_id=#{deviceId}"+

The two literals are adjacent, so javac folds them into one static text node and MyBatis has no <if> boundary where it could insert a separator. There is literally no whitespace in the compiled annotation value.

Regression: introduced by b0b5a0f5 (2025-05-22, 国标级联调整注册逻辑), which removed the <if> wrappers from this UPDATE. It was fixed on master by 3845c032 (2025-05-29, 修复 sql 语法错误), but 2.7.3 HEAD is b1ff1ef (2025-05-26) — three days earlier — so the fix never reached this branch.

Change

Add the missing space. The block is now identical to master. No other change, no formatting noise.

How to verify

  1. Statement level (PostgreSQL):
PREPARE t AS UPDATE wvp_device SET server_id=$1WHERE device_id=$2;
-- ERROR:  trailing junk after parameter at or near "$1WHERE"

PREPARE t2 AS UPDATE wvp_device SET server_id=$1 WHERE device_id=$2;
-- PREPARE
  1. Compiled-annotation level (no database needed):
mvn -DskipTests compile
javap -v -p -cp target/classes com.genersoft.iot.vmp.gb28181.dao.DeviceMapper | grep serverId
  • before this patch: server_id=#{serverId}WHERE device_id=#{deviceId}
  • after this patch: server_id=#{serverId} WHERE device_id=#{deviceId}
  1. End to end: deploy 2.7.3 against PostgreSQL, let one GB28181 device register successfully (so wvp_device.on_line = true), then restart wvp. Before the patch it fails at startup; after the patch it starts normally.

Scope and notes

  • Base branch: 2.7.3. master already contains this fix (3845c032).
  • dev/1400 carries the same defect: its DeviceMapper.java:146-147 is identical, and its HEAD 3dfea4ed (2025-07-10) is after the master fix, so it simply never received it. Happy to send the same one-line change against dev/1400 if that is the branch you prefer to take patches on.
  • What I actually ran: mvn -DskipTests compile succeeds before and after the change, plus the compiled-annotation comparison in step 2. I did not run a full deployment against a real device.

@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown

@CieveMe is attempting to deploy a commit to the 648540858's projects Team on Vercel.

A member of the Team first needs to authorize it.

@648540858
648540858 merged commit dd92a31 into 648540858:2.7.3 Oct 20, 2026
1 check failed
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.

2 participants