[BUG] Dump SQL Server encoding error
I think there's an encoding error when dumping the structure and the data, in fact in the inserts for the values & I had & on nvarchar which crashed the insert request, I had to apply a replace following the following regex :
(N'(?:[^']|'')&)(amp;)((?:[^']|'')')
And replace with group 1 and 3 to remove the amp;
The single quote ' is not escaped. What other wrong symbols have you encountered? I will fix it in the next version.
When the value contain & he is exported as & and it not work on insert.
Another problem, when I dump structure and data, in the create table all field names are enclosed in double quotes, but not in insert into, which poses a problem when there are spaces or ' in the field name when inserting into. You'd have to either enclose them in “ or square brackets.
sorry but GitHub changed the value displayed I correct my comment :
When the value contain & he is exported as & and it not work on insert.
Another problem, when I dump structure and data, in the create table all field names are enclosed in double quotes, but not in insert into, which poses a problem when there are spaces or ' in the field name when inserting into. You'd have to either enclose them in “ or square brackets.
Currently, to resolve some problems encountered during dumping, I apply these replacements via regex in the insert section
tools.regex_to_replace_in_file(insert_file, r"([^(N',])'([^,')])", r"\1''\2")
tools.regex_to_replace_in_file(insert_file, r"(N'N)'[^',]", r"\1''")
tools.regex_to_replace_in_file(insert_file, r"(N'(?:[^']|'')*&)(amp;)((?:[^']|'')*')", r"\1\3")