Skip to content

Commit

Permalink
Synchronization code
Browse files Browse the repository at this point in the history
  • Loading branch information
DotNetNext committed Sep 17, 2023
1 parent a6b89df commit 6cf14e5
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ public virtual List<string> GetFuncList()
{
return new List<string>();
}
public virtual List<string> GetTriggerNames(string tableName)
{
return new List<string>();
}
public virtual List<string> GetDbTypes()
{
return new List<string>();
}
#endregion

#region Check
Expand Down
4 changes: 3 additions & 1 deletion Src/Asp.NetCore2/SqlSugar/Interface/IDbMaintenance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public partial interface IDbMaintenance
List<string> GetProcList(string dbName);
List<string> GetIndexList(string tableName);
List<string> GetFuncList();
List<string> GetTriggerNames(string tableName);
List<string> GetDbTypes();
#endregion

#region Check
Expand All @@ -40,7 +42,7 @@ public partial interface IDbMaintenance
bool DropView(string viewName);
bool DropFunction(string funcName);
bool DropProc(string procName);
; bool DropTable(params string[] tableName);
bool DropTable(params string[] tableName);
bool DropTable(params Type[] tableEntityTypes);
bool DropTable<T>();
bool DropTable<T,T2>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,18 @@ protected override string CreateTableIdentity
#endregion

#region Methods
public override List<string> GetDbTypes()
{
return this.Context.Ado.SqlQuery<string>(@"SELECT DISTINCT DATA_TYPE
FROM DBA_TAB_COLUMNS
WHERE OWNER = user ");
}
public override List<string> GetTriggerNames(string tableName)
{
return this.Context.Ado.SqlQuery<string>(@"SELECT trigger_name
FROM all_triggers
WHERE table_name = '" + tableName + "'");
}
public override List<string> GetFuncList()
{
return this.Context.Ado.SqlQuery<string>(" SELECT object_name\r\nFROM all_objects\r\nWHERE object_type = 'FUNCTION' AND owner = USER ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ protected override string CreateTableIdentity
#endregion

#region Methods
public override List<string> GetDbTypes()
{
return this.Context.Ado.SqlQuery<string>(@"SELECT DISTINCT data_type
FROM information_schema.columns");
}
public override List<string> GetTriggerNames(string tableName)
{
return this.Context.Ado.SqlQuery<string>(@"SELECT tgname
FROM pg_trigger
WHERE tgrelid = '" + tableName + "'::regclass");
}
public override List<string> GetFuncList()
{
return this.Context.Ado.SqlQuery<string>(" SELECT routine_name\r\nFROM information_schema.routines\r\nWHERE lower( routine_schema ) = '" + GetSchema().ToLower() + "' AND routine_type = 'FUNCTION' ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ protected override string IsAnyIndexSql
#endregion

#region Methods
public override List<string> GetDbTypes()
{
return this.Context.Ado.SqlQuery<string>(@"SELECT DISTINCT DATA_TYPE
FROM information_schema.COLUMNS");
}
public override List<string> GetTriggerNames(string tableName)
{
return this.Context.Ado.SqlQuery<string>(@"SELECT TRIGGER_NAME
FROM INFORMATION_SCHEMA.TRIGGERS
WHERE EVENT_OBJECT_TABLE = '" + tableName + "'");
}
public override List<string> GetFuncList()
{
return this.Context.Ado.SqlQuery<string>(" SELECT routine_name\r\nFROM information_schema.ROUTINES\r\nWHERE routine_schema = (SELECT DATABASE()) AND routine_type = 'FUNCTION'; ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ protected override string CreateTableIdentity
#endregion

#region Methods
public override List<string> GetDbTypes()
{
return this.Context.Ado.SqlQuery<string>(@"SELECT DISTINCT DATA_TYPE
FROM DBA_TAB_COLUMNS
WHERE OWNER = user ");
}
public override List<string> GetTriggerNames(string tableName)
{
return this.Context.Ado.SqlQuery<string>(@"SELECT trigger_name
FROM all_triggers
WHERE table_name = '"+tableName+"'");
}
public override List<string> GetFuncList()
{
return this.Context.Ado.SqlQuery<string>(" SELECT object_name\r\nFROM all_objects\r\nWHERE object_type = 'FUNCTION' AND owner = USER ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ protected override string CreateTableIdentity
#endregion

#region Methods
public override List<string> GetDbTypes()
{
return this.Context.Ado.SqlQuery<string>(@"SELECT DISTINCT data_type
FROM information_schema.columns");
}
public override List<string> GetTriggerNames(string tableName)
{
return this.Context.Ado.SqlQuery<string>(@"SELECT tgname
FROM pg_trigger
WHERE tgrelid = '"+tableName+"'::regclass");
}
public override List<string> GetFuncList()
{
return this.Context.Ado.SqlQuery<string>(" SELECT routine_name\r\nFROM information_schema.routines\r\nWHERE lower( routine_schema ) = '" + GetSchema().ToLower() + "' AND routine_type = 'FUNCTION' ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,20 @@ protected override string CreateTableIdentity
#endregion

#region Methods
public override List<string> GetDbTypes()
{
return this.Context.Ado.SqlQuery<string>(@"SELECT name
FROM sys.types
WHERE is_user_defined = 0;");
}
public override List<string> GetTriggerNames(string tableName)
{
return this.Context.Ado.SqlQuery<string>(@"SELECT DISTINCT sysobjects.name AS TriggerName
FROM sysobjects
JOIN syscomments ON sysobjects.id = syscomments.id
WHERE sysobjects.xtype = 'TR'
AND syscomments.text LIKE '%"+tableName+"%'");
}
public override List<string> GetFuncList()
{
return this.Context.Ado.SqlQuery<string>("SELECT name\r\nFROM sys.objects\r\nWHERE type_desc = 'SQL_SCALAR_FUNCTION' ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,23 @@ protected override string IsAnyIndexSql
#endregion

#region Methods
public override List<string> GetDbTypes()
{
return this.Context.Ado.SqlQuery<string>(@"SELECT 'TEXT' AS Data_Type
UNION
SELECT 'INTEGER'
UNION
SELECT 'REAL'
UNION
SELECT 'BLOB';");
}
public override List<string> GetTriggerNames(string tableName)
{
return this.Context.Ado.SqlQuery<string>(@"SELECT name
FROM sqlite_master
WHERE type = 'trigger'
AND sql LIKE '%" + tableName + "%'");
}
public override List<string> GetFuncList()
{
return this.Context.Ado.SqlQuery<string>(" SELECT name\r\nFROM sqlite_master\r\nWHERE type = 'table' AND name NOT LIKE 'sqlite_%' ");
Expand Down

0 comments on commit 6cf14e5

Please sign in to comment.