Skip to content

Missing LEFT JOIN in DELETE #255

Open

Description

@TonnyJe

Version: ^3.0

Bug Description

Wrong SQL generation for joining tables with DELETE.

Steps To Reproduce

This code

$this->database->table('is_document_item')
                ->where('document.code', 202750006)
                ->where('amount', 0)
                ->fetchAll();

generates this query:

SELECT `is_document_item`.`id` 
FROM `is_document_item` 
LEFT JOIN `is_prijemka_vydejka` `document` ON `is_document_item`.`document_id` = `document`.`id` 
WHERE (`document`.`code` = 202750006) AND (`amount` = 0)

which is exactly what is expected.

But if I change ->fetchAll() to ->delete() so its generate this:

DELETE 
FROM `is_document_item` 
WHERE (`document`.`code` = 202750006) AND (`amount` = 0)

which causes this error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'document.code' in 'where clause'

Expected Behavior

I think that is clear.

Activity

  1. changed the title [-]Wrong compatibility with MariaDB and PHP7.4[/-] [+]Missing LEFT JOIN in DELETE[/+] on Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions