Skip to content

Commit 92cd9c0

Browse files
authored
Merge pull request #3180 from SeedCompany/edgedb/bump
2 parents 26bf577 + 4836cac commit 92cd9c0

File tree

4 files changed

+7
-35
lines changed

4 files changed

+7
-35
lines changed

edgedb.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[edgedb]
2-
server-version = "5.0-beta.2"
2+
server-version = "5.0-rc.1"

src/components/authentication/authentication.edgedb.repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class AuthenticationEdgeDBRepository
1212
{
1313
private readonly db: EdgeDB;
1414
constructor(db: EdgeDB) {
15-
this.db = db.outsideOfTransactions().withOptions(disableAccessPolicies);
15+
this.db = db.withOptions(disableAccessPolicies);
1616
}
1717

1818
async waitForRootUserId() {

src/core/edgedb/edgedb.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class EdgeDB {
6969
* await EdgeDB.run(...);
7070
* });
7171
*/
72-
get usingOptions() {
72+
get usingOptions(): OptionsContext['usingOptions'] {
7373
return this.optionsContext.usingOptions.bind(this.optionsContext);
7474
}
7575

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,25 @@
11
import { Injectable, OnModuleDestroy } from '@nestjs/common';
22
import { AsyncLocalStorage } from 'async_hooks';
3-
import { EdgeDBError, Executor, Session } from 'edgedb';
4-
import { getPreviousList, ServerException } from '~/common';
5-
import { OptionsContext } from './options.context';
3+
import { EdgeDBError, Executor } from 'edgedb';
4+
import { getPreviousList } from '~/common';
65
import { Client } from './reexports';
76

87
@Injectable()
98
export class TransactionContext
109
extends AsyncLocalStorage<Executor>
1110
implements OnModuleDestroy
1211
{
13-
constructor(
14-
private readonly client: Client,
15-
private readonly optionsContext: OptionsContext,
16-
) {
12+
constructor(private readonly client: Client) {
1713
super();
1814
}
1915

2016
async inTx<R>(fn: () => Promise<R>): Promise<R> {
2117
const errorMap = new WeakMap<Error, Error>();
2218

23-
const txSession = this.optionsContext.current.session;
24-
2519
try {
2620
return await this.client.transaction(async (tx) => {
27-
const txx = new Proxy(tx, {
28-
get: (target: typeof tx, p: string, receiver: any) => {
29-
const current = this.optionsContext.current.session;
30-
ensureCompatibleSession(txSession, current);
31-
return Reflect.get(target, p, receiver);
32-
},
33-
});
34-
3521
try {
36-
return await this.run(txx, fn);
22+
return await this.run(tx, fn);
3723
} catch (error) {
3824
// If the error "wraps" an EdgeDB error, then
3925
// throw that here and save the original.
@@ -63,17 +49,3 @@ export class TransactionContext
6349
this.disable();
6450
}
6551
}
66-
67-
function ensureCompatibleSession(txSession: Session, current: Session) {
68-
// This should work, but is bugged right now.
69-
// https://github.com/edgedb/edgedb/issues/7138
70-
// It's hard to reason about, so I'm making sure it errors loud.
71-
if (
72-
txSession.config.apply_access_policies !==
73-
current.config.apply_access_policies
74-
) {
75-
throw new ServerException(
76-
'Access policies cannot be toggled within a transaction',
77-
);
78-
}
79-
}

0 commit comments

Comments
 (0)