HY-love-sleep opened a new pull request, #7178:
URL: https://github.com/apache/shenyu/pull/7178
### What this fixes
Closes #6693.
`ai-proxy-api-key-sqlmap.xml` hardcoded MySQL's fractional `NOW(3)` in six
places (`insert`, `insertSelective`, `update`, `updateSelective`,
`updateEnableBatch`). `proxy_api_key_mapping` is created by every supported
dialect (`db/init/{mysql,pg,oracle,og,ob}/…`), and no other mapper in the
repository uses `NOW(3)`, so the AI proxy key CRUD path breaks on
PostgreSQL/OpenGauss/Oracle:
- `db/init/pg/create-table.sql` and `db/init/og/create-table.sql` — `now(3)`
is not a function, the statement fails;
- `db/init/oracle/schema.sql` — there is no `NOW()` at all;
- `db/init/mysql/schema.sql` — the column is already `timestamp(3) NOT NULL
DEFAULT CURRENT_TIMESTAMP(3)` (with `ON UPDATE CURRENT_TIMESTAMP(3)`), so the
explicit value was redundant even on MySQL.
The mapper now binds the entity fields (`#{dateCreated, jdbcType=TIMESTAMP}`
/ `#{dateUpdated, jdbcType=TIMESTAMP}`), consistent with every other mapper,
and `AiProxyApiKeyServiceImpl` sets them, following the existing runtime-insert
precedent (`AbstractDiscoveryProcessor:202`):
- `create` sets `dateCreated` and `dateUpdated`;
- `update` sets `dateUpdated`;
- `enabled` passes a timestamp to `updateEnableBatch`, whose signature
gained the `dateUpdated` parameter.
`AiProxyConnectionServiceImpl` only reads this mapper, so
`AiProxyApiKeyServiceImpl` is the only write path.
### Why CI did not catch it
The admin tests run against H2 in MySQL mode, and H2 accepts it:
```
$ java -cp h2-2.3.232.jar org.h2.tools.Shell -url
'jdbc:h2:mem:probe;MODE=MySQL' -sql "SELECT NOW(3)"
LOCALTIMESTAMP(3)
2026-09-23 14:01:34.435
```
There was also no test coverage for this mapper, so the statement text
itself was never exercised.
### Tests
`AiProxyApiKeyServiceImplTest` gains three cases asserting the timestamps
handed to the mapper (a null would violate the `NOT NULL` column):
`testCreateSetsTimestamps`, `testUpdateSetsUpdatedTimestamp`,
`testEnabledPassesUpdatedTimestamp`. The existing `updateEnableBatch` stubbing
was updated for the new parameter.
```
./mvnw -pl shenyu-admin test -Dtest=AiProxyApiKeyServiceImplTest
Tests run: 12, Failures: 0, Errors: 0, Skipped: 0
You have 0 Checkstyle violations.
BUILD SUCCESS
```
### Not in this PR
- `insertSelective` and `update` have no caller today; they are changed for
consistency only.
- No schema or upgrade script is needed — the columns already exist in every
dialect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]