Correction of the lost ";" during formatting SQL.

При форматировании SQL терялся символ ";". Мелкие правки для перевода сообщений.
This commit is contained in:
lsv 2025-12-02 15:21:11 +05:00
parent 20e91cda3c
commit 8df9354b4c
3 changed files with 24 additions and 7 deletions

View file

@ -1381,14 +1381,19 @@ wxString ctlSQLBox::ExternalFormat(int typecmd)
else
SetText(processOutput);
return _("" + msgword + "ing complete.");
if (typecmd == 1) return _("Aligning complete.");
else return _("Formatting complete.");
}
if (typecmd == 0) {
FSQL::FormatterSQL f(processInput);
int rez = f.ParseSql(0);
if (rez >= 0) {
wxRect rr(0, 0, 120, 2000);
bool issemicol=false;
wxString processOutput = f.Formating(rr);
int next=f.GetNextPositionSqlParse();
if (next>0 && processInput[next-1]==';' && f.GetLastItem().type != FSQL::type_item::comment ) issemicol=true;
if (issemicol) processOutput.Append(';');
if (isSelected)
ReplaceSelection(processOutput);
else
@ -1397,7 +1402,7 @@ wxString ctlSQLBox::ExternalFormat(int typecmd)
} else
return wxString::Format("Error parse sql %d",rez);
}
return _("You need to setup a "+msgword+"ing command");
return "";
}
if (process)
@ -1417,8 +1422,8 @@ wxString ctlSQLBox::ExternalFormat(int typecmd)
delete process;
process = NULL;
processID = 0;
msg = _("Couldn't run " + msgword + "ing command: ") + formatCmd;
return msg;
if (typecmd == 1) return _("Couldn't run aligning command: ") + formatCmd;
else return _("Couldn't run formatting command: ") + formatCmd;
}
process->WriteOutputStream(processInput);
process->CloseOutput();
@ -1439,7 +1444,8 @@ wxString ctlSQLBox::ExternalFormat(int typecmd)
if (process)
{
AbortProcess();
return wxString::Format(_("" + msgword + "ing command did not respond in %d ms"), timeoutMs);
if (typecmd == 1) return wxString::Format(_("Aligning command did not respond in %d ms"), timeoutMs);
else return wxString::Format(_("Formatting command did not respond in %d ms"), timeoutMs);
}
if (processExitCode != 0)
@ -1450,14 +1456,17 @@ wxString ctlSQLBox::ExternalFormat(int typecmd)
}
else if (processOutput.Trim().IsEmpty())
{
return _("" + msgword + "ing command error: Output is empty.");
if (typecmd == 1) return _("Aligning command error: Output is empty.");
else return _("Formatting command error: Output is empty.");
}
if (isSelected)
ReplaceSelection(processOutput);
else
SetText(processOutput);
return _("" + msgword + "ing complete.");
if (typecmd == 1) return _("Aligning complete.");
else return _("Formatting complete.");
}
void ctlSQLBox::AbortProcess()

View file

@ -176,6 +176,7 @@ namespace FSQL {
int GetNextPositionSqlParse();
bool GetItem(int index, FSQL::view_item& item);
view_item GetLastItem();
int next_item_no_space(int& index, int direction = 1);
private:
wxString get_list_columns(int startindex, union FSQL::Byte zone);

View file

@ -38,6 +38,13 @@ bool FormatterSQL::GetItem(int index, FSQL::view_item& item) {
}
return false; // Error
};
view_item FormatterSQL::GetLastItem() {
view_item item;
if (items.size()>0) {
item = items[items.size()-1];
}
return item;
};
wxString FormatterSQL::get_list_columns(int startindex, union Byte zone) {
wxString cols;