quoter les noms des champs

This commit is contained in:
Jephté Clain 2014-03-03 17:16:27 +04:00
parent 9d88d7a72f
commit 3664312761
1 changed files with 7 additions and 3 deletions

View File

@ -218,8 +218,12 @@ elif [ "$method" == insert ]; then
[ -n "$truncate" ] && echo "$truncate" >>"$inserts"
awkcsv <"$input" >>"$inserts" -s "$skip_lines" -v table="$table" \
-a "$__AWK_MYSQLFUNCS"'{
fields = array_join(ORIGHEADERS, ", ")
count = length(ORIGHEADERS)
fields = ""
for (i = 1; i <= count; i++) {
if (i > 1) fields = fields ", "
fields = fields "`" ORIGHEADERS[i] "`"
}
values = ""
for (i = 1; i <= count; i++) {
if (i > 1) values = values ", "
@ -255,10 +259,10 @@ elif [ "$method" == update ]; then
field = ORIGHEADERS[i]
value = format_sqlvalue($i)
if (field == update_key) {
cond = field "=" value
cond = "`" field "`=" value
} else {
if (set_values) set_values = set_values ", "
set_values = set_values field "=" value
set_values = set_values "`" field "`=" value
}
}
print "update `" table "` set " set_values " where " cond ";"