| 172 | |
| 173 | @dataclass(order=True) |
| 174 | class DiffEntry: |
| 175 | key: api.Pointer |
| 176 | order: int |
| 177 | insertion: bool |
| 178 | row: dict[str, api.Value] |
| 179 | |
| 180 | @staticmethod |
| 181 | def create( |
| 182 | pk_table: pw.Table, |
| 183 | pk_columns: dict[str, api.Value], |
| 184 | order: int, |
| 185 | insertion: bool, |
| 186 | row: dict[str, api.Value], |
| 187 | instance: api.Value | None = None, |
| 188 | ) -> DiffEntry: |
| 189 | key = DiffEntry.create_id_from(pk_table, pk_columns, instance=instance) |
| 190 | return DiffEntry(key, order, insertion, row) |
| 191 | |
| 192 | def final_cleanup_entry(self): |
| 193 | return DiffEntry(self.key, self.order + 1, False, self.row) |
| 194 | |
| 195 | @staticmethod |
| 196 | def create_id_from( |
| 197 | pk_table: pw.Table, |
| 198 | pk_columns: dict[str, api.Value], |
| 199 | instance: api.Value | None = None, |
| 200 | ) -> api.Pointer: |
| 201 | values = list(pk_columns.values()) |
| 202 | if instance is None: |
| 203 | return api.ref_scalar(*values) |
| 204 | else: |
| 205 | return api.ref_scalar_with_instance(*values, instance=instance) |
| 206 | |
| 207 | |
| 208 | # This class is an abstract subclass of OnChangeCallback, which takes a list of entries |
no outgoing calls
no test coverage detected