mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 增加 DuckDB 数据库支持;
This commit is contained in:
@ -36,15 +36,6 @@ namespace FreeSql.Sqlite
|
||||
|
||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||
{
|
||||
#if MicrosoftData
|
||||
if (exception != null && exception is SqliteException)
|
||||
#else
|
||||
if (exception != null && exception is SQLiteException)
|
||||
#endif
|
||||
{
|
||||
if (obj.Value.Ping() == false)
|
||||
base.SetUnavailable(exception, obj.LastGetTimeCopy);
|
||||
}
|
||||
base.Return(obj, isRecreate);
|
||||
}
|
||||
|
||||
@ -164,25 +155,10 @@ namespace FreeSql.Sqlite
|
||||
if (_pool.IsAvailable)
|
||||
{
|
||||
if (obj.Value == null)
|
||||
{
|
||||
_pool.SetUnavailable(new Exception(CoreStrings.S_ConnectionStringError_CheckProject), obj.LastGetTimeCopy);
|
||||
throw new Exception(CoreStrings.S_ConnectionStringError_CheckProjectConnection(this.Name));
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
obj.Value.OpenAndAttach(Attaches);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
|
||||
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
if (obj.Value.State != ConnectionState.Open)
|
||||
obj.Value.OpenAndAttach(Attaches);
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,25 +170,10 @@ namespace FreeSql.Sqlite
|
||||
if (_pool.IsAvailable)
|
||||
{
|
||||
if (obj.Value == null)
|
||||
{
|
||||
_pool.SetUnavailable(new Exception(CoreStrings.S_ConnectionStringError), obj.LastGetTimeCopy);
|
||||
throw new Exception(CoreStrings.S_ConnectionStringError_Check(this.Name));
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
await obj.Value.OpenAndAttachAsync(Attaches);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_pool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
|
||||
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
if (obj.Value.State != ConnectionState.Open)
|
||||
await obj.Value.OpenAndAttachAsync(Attaches);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -217,7 +217,7 @@ namespace FreeSql.Sqlite
|
||||
switch (exp.Member.Name)
|
||||
{
|
||||
case "Date": return $"date({left})";
|
||||
case "TimeOfDay": return $"strftime('%H:%M:%f',{left})";
|
||||
case "TimeOfDay": return $"strftime('%H:%M:%S',{left})";
|
||||
case "DayOfWeek": return $"CAST(strftime('%w',{left}) AS INTEGER) ";
|
||||
case "Day": return $"CAST(strftime('%d',{left}) AS INTEGER) ";
|
||||
case "DayOfYear": return $"CAST(strftime('%j',{left}) AS INTEGER) ";
|
||||
@ -441,7 +441,7 @@ namespace FreeSql.Sqlite
|
||||
case "Equals": return $"({left} = {args1})";
|
||||
case "CompareTo": return $"(strftime('%s',{left})-strftime('%s',{args1}))";
|
||||
case "ToString":
|
||||
if (exp.Arguments.Count == 0) return $"strftime('%Y-%m-%d %H:%M:%f',{left})";
|
||||
if (exp.Arguments.Count == 0) return $"strftime('%Y-%m-%d %H:%M:%S',{left})";
|
||||
switch (args1)
|
||||
{
|
||||
case "'yyyy-MM-dd HH:mm:ss'": return $"strftime('%Y-%m-%d %H:%M:%S',{left})";
|
||||
|
Reference in New Issue
Block a user