googleapis / googleapis/google-cloud-go

spannertest: support for cascading deletes

Open
#2,584 3 comments 0 reactions 1 assignee Assigned to @dsymonds View on GitHub
api: spanner priority: p2 type: feature request
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

**Is your feature request related to a problem? Please describe.**

We have some table definitions which rely on cascading deletes, example definition as follows:

```
CREATE TABLE ParentTable (
ParentID STRING(36) NOT NULL,
ParentRow1 STRING(1024) NOT NULL,
CreatedAt TIMESTAMP NOT NULL OPTIONS(allow_commit_timestamp=true),
) PRIMARY KEY(ParentID),

CREATE TABLE InterleavedTable (
ParentID STRING(36) NOT NULL,
InterleavedRow1 STRING(512) NOT NULL,
CreatedAt TIMESTAMP NOT NULL OPTIONS(allow_commit_timestamp=true),
) PRIMARY KEY(ParentID,InterleavedRow1),
INTERLEAVE IN PARENT ParentTable ON DELETE CASCADE
```

When deleting a row from the ParentTable in the spanner emulator or a live db, this seems to work - the associated child row is deleted from InterleavedTable. But in unit tests attempting to test proper deletion and recreation of some of these tables, `ON DELETE CASCADE` does not seem to be applied as expected.

**Describe the solution you'd like**
I would like `ON DELETE CASCADE` to be supported in `spannertest`. Expected behaviour would be for child rows in interleaved tables with this annotation to be deleted when the relevant row in a parent table is deleted.

**Describe alternatives you've considered**
It would be possible to set up manual removal of these rows from child tables, but this would only be done for the sake of unit tests and misses out on the otherwise supported cascading delete feature of spanner.

**Additional context**
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.