Support cascade deletion
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from .operation import *
|
||||
from .database import *
|
||||
|
||||
|
||||
def get_emitter_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
@@ -30,7 +30,7 @@ class Emitter(object):
|
||||
return { 'type': self.type, 'junction': self.junction, 'coefficient': self.coefficient }
|
||||
|
||||
|
||||
def set_emitter_cache(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
def set_emitter_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
old = Emitter(get_emitter(name, cs.operations[0]['junction']))
|
||||
raw_new = get_emitter(name, cs.operations[0]['junction'])
|
||||
|
||||
@@ -56,7 +56,7 @@ def set_emitter_cache(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_emitter(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_emitter_cache(name, cs))
|
||||
return execute_command(name, set_emitter_cmd(name, cs))
|
||||
|
||||
|
||||
class InpEmitter:
|
||||
@@ -90,3 +90,10 @@ def inp_out_emitter(name: str) -> list[str]:
|
||||
coefficient = obj['coefficient']
|
||||
lines.append(f'{junction} {coefficient}')
|
||||
return lines
|
||||
|
||||
|
||||
def delete_emitter_by_junction(name: str, junction: str) -> ChangeSet:
|
||||
row = try_read(name, f"select * from emitters where junction = '{junction}'")
|
||||
if row == None:
|
||||
return ChangeSet()
|
||||
return ChangeSet(g_update_prefix | {'type' : 'emitter', 'junction': junction, 'coefficient': None})
|
||||
|
||||
Reference in New Issue
Block a user