feat(import-engine): move engines out to their own import path, BREAKING CHANGE#454
feat(import-engine): move engines out to their own import path, BREAKING CHANGE#454MrSwitch wants to merge 27 commits into
Conversation
6cedd89 to
6c4e572
Compare
52f69cd to
d908c90
Compare
There was a problem hiding this comment.
Pull request overview
Moves Postgres-specific (and MySQL 5.7-specific) behaviour out of src/index.js into dedicated entry points (dare/postgres and dare/mysql57), introducing subclass-style prototypes that override engine-specific SQL generation (JSON aggregation, identifier quoting, fulltext search, ON DUPLICATE/CONFLICT, etc.). The base Dare is simplified to MySQL 8 defaults, and tests are re-organised into per-engine folders. This addresses issue #455 by making engine differences extensible via prototype overrides rather than inline engine.startsWith(...) checks.
Changes:
- New
src/postgres.jsandsrc/mysql57.jsfactories that wrapnew Dare()andsetPrototypeOfto engine-specific prototypes overridingsql_json_array,sql_json_arrayagg,identifierWrapper,onDuplicateKeysUpdate,fulltextSearch,jsonFormatValue, etc. - Base
src/index.jsremoves inline Postgres/MySQL-5 branches, replaces them with overridable prototype methods, andsrc/format/reducer_conditions.js+src/utils/group_concat.js+src/get.jsnow delegate todareInstance.*instead of switching onengine. - Package exposes new
./postgresand./mysql57subpath exports; tests reorganised intotest/specs/postgres/andtest/specs/mysql57/, with integrationhelpers/api.jspicking the constructor based onDB_ENGINE.
Reviewed changes
Copilot reviewed 39 out of 40 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.js | Strips engine branches; adds sql_json_array, sql_json_arrayagg, jsonFormatValue, fulltextSearch, sql_keyword_like defaults |
| src/postgres.js | New PostgresDare subclass with Postgres-specific overrides |
| src/mysql57.js | New MySQL57Dare subclass — note prototype overrides are written to Dare.prototype |
| src/utils/group_concat.js | Delegates JSON array/aggregate generation to dareInstance |
| src/format/reducer_conditions.js | Uses dareInstance.fulltextSearch, sql_keyword_like, jsonFormatValue |
| src/get.js | Passes dareInstance to group_concat |
| package.json | Adds ./postgres and ./mysql57 exports; consolidates lint into test scripts |
| README.md | Documents new dare/postgres import path |
| test/specs/postgres/*.spec.js | New Postgres test suites split out from generic specs |
| test/specs/mysql57/*.spec.js | New MySQL 5.7 test suites split out from generic specs |
| test/specs/*.spec.js | Removes engine-specific blocks; large formatting/Prettier-style updates |
| test/integration/helpers/api.js | Dynamically selects the constructor from DB_ENGINE env var |
| test/integration/{json,getFieldKey,disparities,shortcut_map,get}.spec.js | Switch to defaultAPI() helper / engine default mysql:8.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 39 out of 40 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
README.md:47
- The README states the Postgres module "provides
request.text(with$1, $2, ...placeholders) instead ofrequest.sql", butsrc/postgres.jsdoes not implement any such conversion — there is notextproperty generated and?placeholders are not converted to$1, $2, .... Either implement the feature or remove/correct this documentation so users aren't misled.
The Postgres module automatically sets the engine to `postgres:16` and provides `request.text` (with `$1, $2, ...` placeholders) instead of `request.sql`.
```js
// Define the handler dare.execute for handing database requests
dare.execute = async (request) => {
// Execute query using prepared statements
// use request.sql, whilst in postgres use request.text
return dbconn.query(request.sql, request.values);
4f5b412 to
a579120
Compare
a579120 to
cd9f081
Compare
d5302f6 to
e7fc85c
Compare
10e8c0d to
4e1ff31
Compare
| return ` | ||
| ON CONFLICT (${existing.filter(item => !keys.includes(item)).join(',')}) | ||
| DO UPDATE | ||
| SET ${keys.map(name => `${this.identifierWrapper(name)}=EXCLUDED.${this.identifierWrapper(name)}`).join(',')} | ||
| `; |
237e127 to
2efd4fa
Compare
2efd4fa to
792fd78
Compare
ff4feda to
1050f9b
Compare
Fixes #455