1
0
mirror of https://github.com/flarum/core.git synced 2025-08-06 00:17:31 +02:00

Wrap column names; use whereColumn where possible

This commit is contained in:
Toby Zerner
2018-07-21 22:02:54 +09:30
parent 7474290138
commit 05c8e12761
13 changed files with 28 additions and 25 deletions

View File

@@ -19,7 +19,7 @@ return [
$schema->getConnection()
->table('access_tokens')
->whereNotExists(function ($query) {
$query->selectRaw(1)->from('users')->whereRaw('id = user_id');
$query->selectRaw(1)->from('users')->whereColumn('id', 'user_id');
})
->delete();

View File

@@ -21,7 +21,7 @@ return [
$selectId = function ($table, $column) use ($connection) {
return new Expression(
'('.$connection->table($table)->whereRaw("id = $column")->select('id')->toSql().')'
'('.$connection->table($table)->whereColumn('id', $column)->select('id')->toSql().')'
);
};

View File

@@ -19,10 +19,10 @@ return [
$connection = $schema->getConnection();
$connection->table('discussion_user')
->whereNotExists(function ($query) {
$query->selectRaw(1)->from('users')->whereRaw('id = user_id');
$query->selectRaw(1)->from('users')->whereColumn('id', 'user_id');
})
->orWhereNotExists(function ($query) {
$query->selectRaw(1)->from('discussions')->whereRaw('id = discussion_id');
$query->selectRaw(1)->from('discussions')->whereColumn('id', 'discussion_id');
})
->delete();

View File

@@ -19,7 +19,7 @@ return [
$schema->getConnection()
->table('email_tokens')
->whereNotExists(function ($query) {
$query->selectRaw(1)->from('users')->whereRaw('id = user_id');
$query->selectRaw(1)->from('users')->whereColumn('id', 'user_id');
})
->delete();

View File

@@ -19,7 +19,7 @@ return [
$schema->getConnection()
->table('group_permission')
->whereNotExists(function ($query) {
$query->selectRaw(1)->from('groups')->whereRaw('id = group_id');
$query->selectRaw(1)->from('groups')->whereColumn('id', 'group_id');
})
->delete();

View File

@@ -19,10 +19,10 @@ return [
$schema->getConnection()
->table('group_user')
->whereNotExists(function ($query) {
$query->selectRaw(1)->from('users')->whereRaw('id = user_id');
$query->selectRaw(1)->from('users')->whereColumn('id', 'user_id');
})
->orWhereNotExists(function ($query) {
$query->selectRaw(1)->from('groups')->whereRaw('id = group_id');
$query->selectRaw(1)->from('groups')->whereColumn('id', 'group_id');
})
->delete();

View File

@@ -19,14 +19,14 @@ return [
$schema->getConnection()
->table('notifications')
->whereNotExists(function ($query) {
$query->selectRaw(1)->from('users')->whereRaw('id = user_id');
$query->selectRaw(1)->from('users')->whereColumn('id', 'user_id');
})
->delete();
$schema->getConnection()
->table('notifications')
->whereNotExists(function ($query) {
$query->selectRaw(1)->from('users')->whereRaw('id = from_user_id');
$query->selectRaw(1)->from('users')->whereColumn('id', 'from_user_id');
})
->update(['from_user_id' => null]);

View File

@@ -19,7 +19,7 @@ return [
$connection = $schema->getConnection();
$connection->table('password_tokens')
->whereNotExists(function ($query) {
$query->selectRaw(1)->from('users')->whereRaw('id = user_id');
$query->selectRaw(1)->from('users')->whereColumn('id', 'user_id');
})
->delete();

View File

@@ -21,7 +21,7 @@ return [
$selectId = function ($table, $column) use ($connection) {
return new Expression(
'('.$connection->table($table)->whereRaw("id = $column")->select('id')->toSql().')'
'('.$connection->table($table)->whereColumn('id', $column)->select('id')->toSql().')'
);
};