Repository navigation
feat(core): add sql.random, improve Order typing - #18203
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a dialect-aware Random expression exposed as Changes
Sequence DiagramsequenceDiagram
participant Client
participant SqlRandom as sql.random
participant Dialect as AbstractDialect
participant QueryGen as QueryGenerator
participant DialectImpl as DialectImplementation
Client->>SqlRandom: use sql.random (in SELECT / DEFAULT)
activate SqlRandom
SqlRandom->>Dialect: supportsDialect(dialect) -> check randomFloatGeneration
Dialect-->>SqlRandom: supported / unsupported
alt supported
SqlRandom->>QueryGen: getRandomFloatFunctionCall()
QueryGen->>DialectImpl: return dialect-specific SQL fragment
DialectImpl-->>QueryGen: "RANDOM()" / "RAND()" / "DBMS_RANDOM.VALUE()" / ...
QueryGen-->>SqlRandom: SQL fragment
SqlRandom-->>Client: SQL random expression (embedded in query)
else unsupported
SqlRandom-->>Client: throw unsupported error
end
deactivate SqlRandom
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
No worries, I remember you doing this all the time. Good change |
WikiRik
left a comment
There was a problem hiding this comment.
We could benefit from (an update to) an integration test for sql.random
|
Crazy that we do not have an integration test for |
|
New changes:
|
|
And I now remember that I shouldn't approve before CI is passing. Luckily we added that integration test |
|
Thankfully it was a simple case of some dialects uppercasing identifiers by default |
* main: (200 commits) meta: update actions/upload-artifact action to v7.0.1 (sequelize#18212) meta: update sequelize AUTHORS (sequelize#18208) feat(cli): add migration generate, run, status & undo (sequelize#18193) feat(core): Drop the ability to specify the dialect as a string (sequelize#18204) feat: update some dialect adapters (sequelize#18189) feat(postgres): replace pg-hstore with inline hstore parser (sequelize#18151) feat(core): add `sql.random`, improve `Order` typing (sequelize#18203) meta: use Sequelize Bot for drafting PRs (sequelize#18201) meta: automatically mark unfinished PRs as draft (sequelize#18197) meta: update dependency @oclif/test to v4.1.18 (sequelize#18198) fix(core): replace @typeparam with @template in JSDoc (sequelize#18094) feat(core): Add support for UUID v7 (sequelize#17832) meta: update sequelize AUTHORS (sequelize#18190) meta: update dependency @oclif/plugin-help to ^6.2.43 (sequelize#18195) meta: update dependency esbuild to v0.28.0 (sequelize#18192) meta: update dependency @oclif/plugin-help to ^6.2.42 (sequelize#18191) meta: update dependency @oclif/core to ^4.10.5 (sequelize#18187) meta: update sequelize AUTHORS (sequelize#18158) feat: add Node 24 support, drop Node 18 (sequelize#18185) feat(core): add support for readonly attribute arrays (sequelize#18186) ...
Pull Request Checklist
Description of Changes
This PR adds
sql.randomas a replacement forsequelize.random. Unlike the latter,sql.randomis:I then migrated
order.test.jsto TypeScript, because I edited it to usesql.randominstead ofsequelize.random, which uncovered that the typings forOrderwas wrong, so I also fixed these typings.Finally, and sorry that this wasn't really related to this PR, I renamed all
sqlvariables that are actuallyqueryGenerator, because it was confusing to havesqlpoint to two different objects in our testsList of Breaking Changes
None
Summary by CodeRabbit
New Features
Deprecations
Bug Fixes
Tests