Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: add Entity::delete_many #1514

Merged
merged 4 commits into from
Dec 14, 2023
Merged

Conversation

lostman
Copy link
Contributor

@lostman lostman commented Dec 12, 2023

Description

Closes #1511.

This PR adds Entity::delete_many(filter), which removes all entities of type T matching the given filter, and a new trait EntityDelete which provides a t.delete() method on a single non-virtual entity type.

Some types are not stored in tables and hence do not have the delete() method:

examples/fuel-explorer/fuel-explorer/schema/fuel_explorer.schema.graphql
103:type Witness @entity(virtual: true) {
107:type InstructionResult @entity(virtual: true) {
112:type ProgramState @entity(virtual: true) {
117:type DryRun @entity(virtual: true) {
224:type CallReceipt @entity(virtual: true) {
241:type ReturnDataReceipt @entity(virtual: true) {
254:type PanicReceipt @entity(virtual: true) {
264:type RevertReceipt @entity(virtual: true) {
274:type LogReceipt @entity(virtual: true) {
287:type LogDataReceipt @entity(virtual: true) {
302:type ReturnReceipt @entity(virtual: true) {
312:type TransferReceipt @entity(virtual: true) {
326:type TransferOutReceipt @entity(virtual: true) {
340:type ScriptResultReceipt @entity(virtual: true) {
347:type MessageOutReceipt @entity(virtual: true) {
361:type MintReceipt @entity(virtual: true) {
370:type BurnReceipt @entity(virtual: true) {

t.delete() translates to:

DELETE FROM entity_table WHERE id = 'some_id'

Testing steps

CI tests should pass. This PR includes new tests for delete_many()

Changelog

  • Add Entity::delete_many() which deletes all entities matching the given filter from the database.
  • Add t.delete(), which deletes a single entity from the database.
  • Add add tests for Entity::delete_many() and t.delete().

@lostman lostman self-assigned this Dec 13, 2023
@lostman lostman marked this pull request as ready for review December 13, 2023 16:22
@lostman lostman merged commit c2015e2 into develop Dec 14, 2023
20 checks passed
@lostman lostman deleted the maciej/1511-entity-delete branch December 14, 2023 12:34
@lostman lostman removed their assignment Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for .delete() in Entity
3 participants