Skip to content

Commit

Permalink
Merge pull request #74 from jtomlinson/main
Browse files Browse the repository at this point in the history
Remove database from table on delete with join
  • Loading branch information
AdalbertMemSQL authored Jan 2, 2024
2 parents 578ae05 + b45ca7a commit 1bf7d65
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Query/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,23 @@ private function compileOffsetWithLimit($offset, $limit): string

return ' OFFSET '.(int) $offset;
}

/**
* Compile a delete statement with joins into SQL.
*
* @param \Illuminate\Database\Query\Builder $query
* @param string $table
* @param string $where
* @return string
*/
protected function compileDeleteWithJoins(Builder $query, $table, $where): string
{
$joins = $this->compileJoins($query, $query->joins);

// SingleStore does not support "database.table" in a delete statement when the delete statement contains a join
// strip the database name from the table, if it exists
$deleteTable = last(explode('.', $table));

return "delete {$deleteTable} from {$table} {$joins} {$where}";
}
}

0 comments on commit 1bf7d65

Please sign in to comment.