run dotnet format

This commit is contained in:
spiral
2021-08-27 11:03:47 -04:00
parent 05989242f9
commit ac2671452d
278 changed files with 1913 additions and 1808 deletions

View File

@@ -1,18 +1,19 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Data.Common;
using Dapper;
namespace PluralKit.Core {
namespace PluralKit.Core
{
public static class ConnectionUtils
{
public static async IAsyncEnumerable<T> QueryStreamAsync<T>(this IPKConnection conn, string sql, object param)
{
await using var reader = (DbDataReader) await conn.ExecuteReaderAsync(sql, param);
await using var reader = (DbDataReader)await conn.ExecuteReaderAsync(sql, param);
var parser = reader.GetRowParser<T>();
while (await reader.ReadAsync())
yield return parser(reader);
yield return parser(reader);
}
}
}

View File

@@ -62,7 +62,7 @@ namespace PluralKit.Core
// If the above creates new enum/composite types, we must tell Npgsql to reload the internal type caches
// This will propagate to every other connection as well, since it marks the global type mapper collection dirty.
((PKConnection) conn).ReloadTypes();
((PKConnection)conn).ReloadTypes();
}
private async Task<int> GetCurrentDatabaseVersion(IPKConnection conn)
@@ -82,4 +82,4 @@ namespace PluralKit.Core
return -1;
}
}
}
}

View File

@@ -1,4 +1,4 @@
using System.Threading;
using System.Threading;
namespace PluralKit.Core
{

View File

@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System;
using System.Text;
@@ -23,32 +23,32 @@ namespace PluralKit.Core
_conflictField = conflictField;
_condition = condition;
}
public static QueryBuilder Insert(string table) => new QueryBuilder(QueryType.Insert, table, null, null);
public static QueryBuilder Insert(string table) => new QueryBuilder(QueryType.Insert, table, null, null);
public static QueryBuilder Update(string table, string condition) => new QueryBuilder(QueryType.Update, table, null, condition);
public static QueryBuilder Upsert(string table, string conflictField) => new QueryBuilder(QueryType.Upsert, table, conflictField, null);
public QueryBuilder Constant(string fieldName, string paramName)
{
if (_firstInsert) _firstInsert = false;
else
else
{
_insertFragment.Append(", ");
_valuesFragment.Append(", ");
}
_insertFragment.Append(fieldName);
_valuesFragment.Append(paramName);
return this;
}
public QueryBuilder Variable(string fieldName, string paramName)
{
Constant(fieldName, paramName);
if (_firstUpdate) _firstUpdate = false;
else _updateFragment.Append(", ");
_updateFragment.Append(fieldName);
_updateFragment.Append(" = ");
_updateFragment.Append(paramName);
@@ -59,7 +59,7 @@ namespace PluralKit.Core
{
if (_firstInsert)
throw new ArgumentException("No fields have been added to the query.");
StringBuilder query = new StringBuilder(Type switch
{
QueryType.Insert => $"insert into {Table} ({_insertFragment}) values ({_valuesFragment})",
@@ -70,7 +70,7 @@ namespace PluralKit.Core
if (Type == QueryType.Update && _condition != null)
query.Append($" where {_condition}");
if (!string.IsNullOrEmpty(suffix))
query.Append($" {suffix}");
query.Append(";");

View File

@@ -1,4 +1,4 @@
using System.Text;
using System.Text;
using Dapper;
@@ -13,7 +13,7 @@ namespace PluralKit.Core
{
_qb = qb;
}
public static UpdateQueryBuilder Insert(string table) => new UpdateQueryBuilder(QueryBuilder.Insert(table));
public static UpdateQueryBuilder Update(string table, string condition) => new UpdateQueryBuilder(QueryBuilder.Update(table, condition));
public static UpdateQueryBuilder Upsert(string table, string conflictField) => new UpdateQueryBuilder(QueryBuilder.Upsert(table, conflictField));