quoter les noms des champs
This commit is contained in:
parent
9d88d7a72f
commit
3664312761
10
mysqlloadcsv
10
mysqlloadcsv
|
@ -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 ";"
|
||||
|
|
Loading…
Reference in New Issue