Skip to content

Commit

Permalink
Fix explicit transaction read-only attr over default isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix committed Feb 4, 2025
1 parent 85f807a commit e3dde38
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions edb/ir/statypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,3 +801,13 @@ def get_translation_map(cls) -> Mapping[TransactionIsolationEnum, str]:
TransactionIsolationEnum.Serializable: "serializable",
TransactionIsolationEnum.RepeatableRead: "repeatable read",
}

def to_qltypes(self) -> qltypes.TransactionIsolationLevel:
from edb.edgeql import qltypes
match self._val:
case TransactionIsolationEnum.Serializable:
return qltypes.TransactionIsolationLevel.SERIALIZABLE
case TransactionIsolationEnum.RepeatableRead:
return qltypes.TransactionIsolationLevel.REPEATABLE_READ
case _:
raise AssertionError(f"unexpected value: {self._val!r}")
1 change: 1 addition & 0 deletions edb/lib/cfg.edgeql
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ ALTER TYPE cfg::AbstractConfig {
CREATE REQUIRED PROPERTY default_transaction_isolation
-> sys::TransactionIsolation
{
CREATE ANNOTATION cfg::affects_compilation := 'true';
CREATE ANNOTATION cfg::backend_setting :=
'"default_transaction_isolation"';
CREATE ANNOTATION std::description :=
Expand Down
9 changes: 8 additions & 1 deletion edb/server/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2167,7 +2167,14 @@ def _compile_ql_transaction(
hint=f"specify READ ONLY access mode",
)
sqls += f' ISOLATION LEVEL {iso.value}'
if ql.access is None:
else:
iso_config: statypes.TransactionIsolation = _get_config_val(
ctx, "default_transaction_isolation"
)
iso = iso_config.to_qltypes()
if iso is not qltypes.TransactionIsolationLevel.SERIALIZABLE:
sqls += f' {qltypes.TransactionAccessMode.READ_ONLY.value}'
elif ql.access is None:
access_mode: statypes.TransactionAccessMode = _get_config_val(
ctx, "default_transaction_access_mode"
)
Expand Down

0 comments on commit e3dde38

Please sign in to comment.