Skip to content

DBAL contract violation: deleteTable() used as cleanup operation but missing in IdiormDbal #387

Description

@armanist

Description

There is an actual and potential bug in QF caused by inconsistent DBAL behavior and an incomplete DBAL contract.

A method named deleteTable() exists in SleekDbal and is widely used in services and module templates as a data cleanup operation (delete all records).

Example:

public function deleteAllPosts()
{
    $this->model->deleteTable();
}

However:

  • deleteTable() is not defined in DbalInterface
  • IdiormDbal does not implement it
  • Switching DBAL adapters causes runtime errors
  • The method name implies schema deletion, but the actual behavior is record cleanup
  • This breaks DBAL interchangeability and violates the existing DBAL contract.

Current Behavior

  • deleteTable():
    • Exists only in SleekDbal
    • Deletes all records (store cleanup)
  • IdiormDbal:
    • Has no equivalent method
    • Errors when code assumes deleteTable() exists
  • Module templates and services assume this operation is DBAL-level and safe
  • Adapter switching is unsafe

Expected Behavior

  • BAL must provide a contract-defined cleanup operation
  • All adapters must implement it consistently
  • Services and modules must not rely on adapter-specific methods
  • Adapter switching must not introduce runtime failures

Proposed Fix (Bug Resolution)

1. Define a DBAL-level cleanup operation

Introduce a contract method that:

Deletes all records from the underlying table or store while keeping it usable.

2. Implement consistently across adapters

SleekDbal => Delete all records in store (current behavior)
IdiormDbal => DELETE FROM <table> (or equivalent)

SleekDbal (adapter-specific method, not in contract)

// SleekDbal adapter
public function deleteTable()
{
    $this->getOrmModel()->deleteStore();
}

Explicit Naming Alignment (Required)

As part of resolving this bug and enforcing DBAL consistency, the existing method need to be renamed from
deleteTable() to truncate()

✅ SleekDbal (maps to existing behavior)

// SleekDbal adapter
public function truncate(): bool
{
    $this->getOrmModel()->deleteStore();
    return true;
}

✅ IdiormDbal (correct semantic equivalent)

// IdiormDbal adapter
public function truncate(): bool
{

    // $sql = "DELETE FROM {$table}";
    
    return true;
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions