allow multiple types in DB (only text and integer for...
...now)
... | ... |
@@ -242,7 +242,14 @@ function update_database () { |
242 | 242 |
insert_col='file, variantof, ' |
243 | 243 |
update_values='' |
244 | 244 |
for col in ${!data[@]}; do |
245 |
- test ${datatypes[$col]%% *} == 'text' && single_quote="'" || single_quote="" |
|
245 |
+ if test ${datatypes[$col]%% *} = 'text'; then |
|
246 |
+ single_quote="'" |
|
247 |
+ elif [[ ${datatypes[$col]%% *} = 'integer' && "${data[$col]// }" = +([0-9]) ]]; then |
|
248 |
+ single_quote="" |
|
249 |
+ else |
|
250 |
+ unset datatypes[$col] |
|
251 |
+ continue |
|
252 |
+ fi |
|
246 | 253 |
insert_col+="\`$col\`, " |
247 | 254 |
insert_values+="$single_quote${data[$col]//\'/\'\'}$single_quote, " |
248 | 255 |
if test -n "${data[$col]}"; then |