Repository navigation
fix(oracle): use bind parameters in describeTable and showConstraints - #18499
wikirik-agent wants to merge 8 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
a693d00 to
f4e04be
Compare
f30d1a4 to
45c2d7c
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
Oracle hard parses every distinct SQL text. Because the table name was inlined, every showIndex call (which Model.sync runs for each model) was hard parsed against the dictionary views, which takes hundreds of milliseconds on Oracle 23. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Moves the showIndex SQL builder to an internal module instead of adding a public showIndexesQueryWithBind method to OracleQueryGenerator, and tests the bind parameters through queryInterface.showIndex. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
45c2d7c to
329d510
Compare
f4e04be to
859faa2
Compare
…aller binds Co-Authored-By: Claude Opus 5.5 <[email protected]>
859faa2 to
91fc571
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Follow-up to the showIndex change: the describeTable and showConstraints dictionary queries (including the foreign key lookup used by sync and dropAllTables) also inlined the table name, so Oracle hard parsed them on every call. The abstract query interface post-processes the results of these queries, so running them moves to overridable methods on AbstractQueryInterfaceInternal, which the Oracle dialect overrides. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Oracle now passes the schema to describeTable as a bind parameter, so the schema is in the logged parameters instead of the SQL. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…omments Co-Authored-By: Claude Opus 5.5 <[email protected]>
91fc571 to
3b5d699
Compare
9139c6f to
2b072b6
Compare
|
Folded into #18498: describeTable and showConstraints now use the same approach as showIndex there (parameterStyle: BIND on the Oracle query generator, run through AbstractQueryInterfaceInternal), so the two PRs no longer need to be reviewed separately. |
Description of Changes
Stacked on #18498; this is the follow-up mentioned there.
#18498 made Oracle's
showIndexuse bind parameters, so Oracle no longer hard parses that dictionary query for every table.describeTableandshowConstraintsinline the table name in the same way. That includes the foreign-key lookup thatsync()runs for models with cyclic references and thatsequelize.drop()/dropAllTables()run for dialects that don't drop with cascade.These two can't be overridden in the Oracle query interface the way
showIndexwas, becauseAbstractQueryInterfacepost-processes their results. This PR adds a small internal seam instead:AbstractQueryInterfaceInternal(not public API) getsdescribeTableRaw()andshowConstraintsRaw(), which run the query and return the unprocessed result.AbstractQueryInterface#describeTable/#showConstraintscall them and keep all of their post-processing and error handling. For other dialects, nothing changes.OracleQueryInterfaceInternaloverrides both to build the queries with bind parameters, using the SQL builders that now live in the internalcatalog-queries.tsmodule next to the one from fix: use bind parameters in the Oracle catalog queries #18498.describeTableQuery()/showConstraintsQuery()/getForeignKeysQuery()use the same builders with escaped literals, so their output does not change.showConstraintsQuery()still goes throughgetForeignKeysQuery()for foreign keys, so overriding that method keeps working.Local numbers against a fresh
gvenzl/oracle-free:23.26.3-slimcontainer,test/integration/associations/**(276 tests):mainThe
#18498column is estimated from the savedshowIndextime; it was not measured on its own.test/unit/query-interface/describe-table.test.tsandshow-constraints.test.tstest the same way as #18498, on every dialect: the SQL sent with the binds put back must equal the query generator'sdescribeTableQuery()/showConstraintsQuery(), including the foreign-key variant. SQLite3 is the exception forshowConstraints, because it reads its constraints from theCREATE TABLEstatement. Only Oracle sends bind parameters, and a caller-providedbindcan't override them. Locally, the Oraclequery-interface,model,model/syncandassociationsintegration tests pass (447). OnelistTablestest failed once because Oracle'slistTablesQueryhas noORDER BY; that flake is unrelated to this PR, and the test passed on rerun. The core unit tests pass for Oracle, Postgres, MSSQL and SQLite3.In CI, after rebasing onto main (6995f15), the "Integration Tests" step of oracle latest had a median of 288 s (159–324 s across 3 Node versions), against 928 s on main and 259 s with #18498 alone. CI runners are too noisy to separate this PR's local ~18 s gain from #18498's effect.
As with #18498, logged
describeTable/showConstraintsSQL now shows placeholders instead of the names unlesslogQueryParametersis enabled;test/integration/model.test.jswas updated for this. Oracle'stableExistsQuery(run on every non-forcesync) still inlines the table name and could get the same treatment in a follow-up.List of Breaking Changes
None.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests