@@ -268,6 +268,12 @@ def validate_query(query, request, user):
268
268
# mapping for each column
269
269
column_mapping = {}
270
270
if tool_format .get ("allow_user_mapping" , False ):
271
+ magic_mappings = {
272
+ "id" : {"__4cat_auto_sequence" : "[generate sequential IDs]" },
273
+ "thread_id" : {"__4cat_auto_sequence" : "[generate sequential IDs]" },
274
+ "empty" : {"__4cat_empty_value" : "[empty]" },
275
+ "timestamp" : {"__4cat_now" : "[current date and time]" }
276
+ }
271
277
if incomplete_mapping :
272
278
raise QueryNeedsFurtherInputException ({
273
279
"mapping-info" : {
@@ -279,8 +285,7 @@ def validate_query(query, request, user):
279
285
"type" : UserInput .OPTION_CHOICE ,
280
286
"options" : {
281
287
"" : "" ,
282
- ** ({"__4cat_auto_sequence" : "[generate sequential IDs]" } if mappable_column in (
283
- "id" , "thread_id" ) else {}),
288
+ ** magic_mappings .get (mappable_column , magic_mappings ["empty" ]),
284
289
** {column : column for column in fields }
285
290
},
286
291
"default" : mappable_column if mappable_column in fields else "" ,
@@ -294,7 +299,7 @@ def validate_query(query, request, user):
294
299
for field in tool_format ["columns" ]:
295
300
mapping_field = "option-mapping-%s" % field
296
301
provided_field = request .form .get (mapping_field )
297
- if (provided_field not in fields and provided_field != "__4cat_auto_sequence" ) or not provided_field :
302
+ if (provided_field not in fields and not provided_field . startswith ( "__4cat" ) ) or not provided_field :
298
303
missing_mapping .append (field )
299
304
else :
300
305
column_mapping ["mapping-" + field ] = request .form .get (mapping_field )
0 commit comments