Skip to content

Commit

Permalink
Merge pull request #14 from 365talents/release-3.1.2-fork4
Browse files Browse the repository at this point in the history
Release 3.1.2-fork4
  • Loading branch information
ducher authored Oct 21, 2024
2 parents 7a5e1e7 + 6757ff4 commit 57a3033
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 20,306 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
Expand All @@ -26,10 +26,10 @@ jobs:
run: npm ci

- name: Run docker compose
run: docker-compose up -d
run: docker compose up -d

- name: Setup test db
run: node setup-test-db.js

- name: Run tests
run: npm test
run: npm test
4 changes: 2 additions & 2 deletions doc/guide/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ git clone [email protected]:<your-account>/objection.js.git objection

3. **Run `npm install` at the root of the repo**

4. **Run `docker-compose up` at the root of the repo**
4. **Run `docker compose up` at the root of the repo**
- If you have local databases running, shut them down or port binding will conflict.

5. **Create test users and databases by running `node setup-test-db` at the root of the repo**
Expand All @@ -53,7 +53,7 @@ git clone [email protected]:<your-account>/objection.js.git objection
You can run the tests on a subset of databases by setting the `DATABASES` env variable

```bash
# Only run tests on sqlite. No need for docker-compose.
# Only run tests on sqlite. No need for docker compose.
DATABASES=sqlite3 npm test
```

Expand Down
9 changes: 9 additions & 0 deletions doc/release-notes/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Changelog
## 3.1.2-fork4

### What's new

- Fix ModelObject TS helper and toJSON return type
- Deprecate methods taking modifiers or relations as arguments when written as string, use real functions or objects instead
- Fix JSON accessors for PostgreSQL
- Fix CI and unit tests

## 3.1.2-fork3

### What's new
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ services:
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
mysql:
image: 'mysql:5'
image: 'mysql:8.1.0'
container_name: 'objection_mysql'
ports:
- '3306:3306'
environment:
- 'MYSQL_ALLOW_EMPTY_PASSWORD=yes'
MYSQL_HOST: "localhost"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
12 changes: 8 additions & 4 deletions lib/queryBuilder/ReferenceBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,18 @@ class ReferenceBuilder {
bindings.push(this.fullColumn(builder));

if (this._parsedExpr.access.length > 0) {
const extractor = this._cast ? '->>' : '->';
if (isMySql(builder.knex())) {
const accessor = '->';
const extractor = this._cast ? '->>' : accessor;
if (isMySql(builder.unsafeKnex())) {
const jsonFieldRef = this._parsedExpr.access.map((field) => field.ref).join('.');
return `??${extractor}'$.${jsonFieldRef}'`;
}
// case postgresql
const jsonFieldRef = this._parsedExpr.access.map((field) => `'${field.ref}'`).join('->');
return `??${extractor}${jsonFieldRef}`;
const jsonFieldRefs = this._parsedExpr.access.map(
(field) => `${typeof field.ref === 'string' ? `'${field.ref}'` : field.ref}`,
);
const lastRef = jsonFieldRefs.pop();
return `??${['', ...jsonFieldRefs].join(accessor)}${extractor}${lastRef}`;
} else {
return '??';
}
Expand Down
Loading

0 comments on commit 57a3033

Please sign in to comment.