Skip to content

feat(import-engine): move engines out to their own import path, BREAKING CHANGE#454

Open
MrSwitch wants to merge 27 commits into
nextfrom
postgres-endpoint
Open

feat(import-engine): move engines out to their own import path, BREAKING CHANGE#454
MrSwitch wants to merge 27 commits into
nextfrom
postgres-endpoint

Conversation

@MrSwitch
Copy link
Copy Markdown
Owner

@MrSwitch MrSwitch commented May 23, 2026

Fixes #455

@MrSwitch MrSwitch changed the base branch from main to next May 23, 2026 08:05
@MrSwitch MrSwitch force-pushed the postgres-endpoint branch from 6cedd89 to 6c4e572 Compare May 23, 2026 08:26
@MrSwitch MrSwitch changed the title feat(postgres): move postgres out to it's own endpoint, BREAKING CHANGE feat(postgres): move postgres out to it's own import path, BREAKING CHANGE May 23, 2026
@MrSwitch MrSwitch force-pushed the postgres-endpoint branch from 52f69cd to d908c90 Compare May 28, 2026 22:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.js and src/mysql57.js factories that wrap new Dare() and setPrototypeOf to engine-specific prototypes overriding sql_json_array, sql_json_arrayagg, identifierWrapper, onDuplicateKeysUpdate, fulltextSearch, jsonFormatValue, etc.
  • Base src/index.js removes inline Postgres/MySQL-5 branches, replaces them with overridable prototype methods, and src/format/reducer_conditions.js + src/utils/group_concat.js + src/get.js now delegate to dareInstance.* instead of switching on engine.
  • Package exposes new ./postgres and ./mysql57 subpath exports; tests reorganised into test/specs/postgres/ and test/specs/mysql57/, with integration helpers/api.js picking the constructor based on DB_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.

Comment thread src/mysql57.js Outdated
Comment thread src/mysql57.js Outdated
Comment thread test/specs/mysql57/filter_reducer.spec.js Outdated
Comment thread src/postgres.js Outdated
Comment thread package.json
Comment thread package.json
Comment thread src/utils/group_concat.js Outdated
@MrSwitch MrSwitch changed the title feat(postgres): move postgres out to it's own import path, BREAKING CHANGE feat(import-engine): move postgres out to it's own import path, BREAKING CHANGE May 31, 2026
@MrSwitch MrSwitch requested a review from Copilot May 31, 2026 13:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 of request.sql", but src/postgres.js does not implement any such conversion — there is no text property 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);

Comment thread src/index.js
Comment thread test/specs/postgres/patch.spec.js
@MrSwitch MrSwitch force-pushed the postgres-endpoint branch 2 times, most recently from 4f5b412 to a579120 Compare May 31, 2026 19:02
@MrSwitch MrSwitch force-pushed the postgres-endpoint branch from a579120 to cd9f081 Compare May 31, 2026 20:18
@MrSwitch MrSwitch force-pushed the postgres-endpoint branch from d5302f6 to e7fc85c Compare June 2, 2026 22:51
@MrSwitch MrSwitch force-pushed the postgres-endpoint branch from 10e8c0d to 4e1ff31 Compare June 4, 2026 05:35
@MrSwitch MrSwitch requested a review from Copilot June 4, 2026 06:01
@MrSwitch MrSwitch changed the title feat(import-engine): move postgres out to it's own import path, BREAKING CHANGE feat(import-engine): move engines out to their own import path, BREAKING CHANGE Jun 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 43 changed files in this pull request and generated 4 comments.

Comment thread src/postgres16.js
Comment on lines +114 to +118
return `
ON CONFLICT (${existing.filter(item => !keys.includes(item)).join(',')})
DO UPDATE
SET ${keys.map(name => `${this.identifierWrapper(name)}=EXCLUDED.${this.identifierWrapper(name)}`).join(',')}
`;
Comment thread src/index.js
Comment thread test/specs/mysql57/filter_reducer.spec.js
Comment thread test/specs/postgres/fulltext_parser.spec.js
@MrSwitch MrSwitch force-pushed the postgres-endpoint branch from 237e127 to 2efd4fa Compare June 4, 2026 06:51
@MrSwitch MrSwitch force-pushed the postgres-endpoint branch from 2efd4fa to 792fd78 Compare June 4, 2026 06:54
@MrSwitch MrSwitch force-pushed the postgres-endpoint branch from ff4feda to 1050f9b Compare June 4, 2026 21:50
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