fix SQL quoting

This commit is contained in:
Vincent Riquer 2013-03-04 13:37:19 +01:00
parent bed67cc8f6
commit 6d5424a8b4

10
atom
View File

@ -299,7 +299,7 @@ Select() {
while read key operator value
do
(( ${#where_statement} )) && where_statement+=( "AND" )
where_statement+=( "$key $operator "'"'"${value//\"/\\\"}"'"' )
where_statement+=( "$key $operator "'"'"${value//\"/\"\"}"'"' )
done
echo "SELECT IFNULL(" \
"(SELECT $columns FROM $table" \
@ -333,7 +333,7 @@ Insert() {
then
insert_values+="NULL"
else
insert_values+='"'"${value//\"/\\\"}"'"'
insert_values+='"'"${value//\"/\"\"}"'"'
fi
done
echo "INSERT INTO $table" \
@ -372,7 +372,7 @@ Update(){
what=value
;;
value)
set_statement="${set_statement}="'"'"${argument//\"/\\\"}"'"'
set_statement="${set_statement}="'"'"${argument//\"/\"\"}"'"'
what=key
;;
esac
@ -384,7 +384,7 @@ Update(){
then
where_statement+=( "$key is NULL" )
else
where_statement+=( "$key $operator "'"'"${value//\"/\\\"}"'"' )
where_statement+=( "$key $operator "'"'"${value//\"/\"\"}"'"' )
fi
done
echo "UPDATE '$table' SET" \
@ -519,7 +519,7 @@ Delete() {
then
where_statement+=( "$key is NULL" )
else
where_statement+=( "$key $operator "'"'"${value//\"/\\\"}"'"' )
where_statement+=( "$key $operator "'"'"${value//\"/\"\"}"'"' )
fi
done
echo "DELETE from $table WHERE ${where_statement[@]};" >&3