Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.1.2-fork4 #14

Merged
merged 8 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading