mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
First attempt to manipulate the CREATE table code in SQL exports when source is a MySQL server and target is MariaDB. This just removes the incompatible "COLLATE xyz" clause from virtual varchar columns.
This commit is contained in:
@ -138,6 +138,10 @@ type
|
||||
procedure LogFromThread(Msg: String; Category: TDBLogCategory);
|
||||
end;
|
||||
|
||||
TSqlTranspiler = class(TObject)
|
||||
class function CreateTable(SQL: String; SourceDb, TargetDb: TDBConnection): String;
|
||||
end;
|
||||
|
||||
TAppSettingDataType = (adInt, adBool, adString);
|
||||
TAppSettingIndex = (asHiddenColumns, asFilter, asSort, asDisplayedColumnsSorted, asLastSessions,
|
||||
asLastActiveSession, asAutoReconnect, asRestoreLastUsedDB, asLastUsedDB, asTreeBackground, asIgnoreDatabasePattern, asLogFileDdl, asLogFileDml, asLogFilePath,
|
||||
@ -3307,6 +3311,21 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{ TSqlTranspiler }
|
||||
|
||||
class function TSqlTranspiler.CreateTable(SQL: String; SourceDb, TargetDb: TDBConnection): String;
|
||||
begin
|
||||
Result := SQL;
|
||||
|
||||
if SourceDb.Parameters.IsMySQL(False) and TargetDb.Parameters.IsMariaDB then begin
|
||||
// Remove COLLATE clause from virtual column definition:
|
||||
// `tax_status` varchar(255) COLLATE utf8mb4_unicode_ci GENERATED ALWAYS AS (json_unquote(json_extract(`price`,'$.taxStatus'))) VIRTUAL
|
||||
Result := ReplaceRegExpr('\sCOLLATE\s\w+(\s+GENERATED\s)', Result, '$1', [rroModifierI, rroUseSubstitution]);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ TAppSettings }
|
||||
|
||||
|
@ -1607,6 +1607,8 @@ begin
|
||||
Insert('IF NOT EXISTS ', Struc, Pos('TABLE', Struc) + 6);
|
||||
if ToDb then
|
||||
Insert(Quoter.QuoteIdent(FinalDbName)+'.', Struc, Pos('EXISTS', Struc) + 7 );
|
||||
if ToServer then
|
||||
Struc := TSqlTranspiler.CreateTable(Struc, DBObj.Connection, FTargetConnection);
|
||||
end;
|
||||
|
||||
lntView: begin
|
||||
|
Reference in New Issue
Block a user