-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Description
- Laravel Version: 8.79.0 vs 9.x (beta-1)
- PHP Version: 8.0.13
- Database Driver & Version: MySql 5.7
Description:
The MySql (5.7) Query is different between Laravel 8.79.0 and 9.x (beta-1), by 8.x it will include 'and posts.deleted_at is null' at the end of the query, while it's gone by 9.x.
class User extends Authenticatable
{
//
public function posts()
{
return $this->hasMany(Post::class);
}
}
class Post extends Model
{
use \Illuminate\Database\Eloquent\SoftDeletes;
//
}
class ExampleTest extends TestCase
{
public function test()
{
$user = new \App\Models\User;
// Expected (Laravel 8) : 'select * from `posts` where `posts`.`user_id` is null and `posts`.`user_id` is not null and `posts`.`deleted_at` is null'
// Actual (Laravel 9) : 'select * from `posts` where `posts`.`user_id` is null and `posts`.`user_id` is not null'
$this->assertSame('select * from `posts` where `posts`.`user_id` is null and `posts`.`user_id` is not null and `posts`.`deleted_at` is null', $user->posts()->toSql());
}
}Metadata
Metadata
Assignees
Labels
No labels