@@ -301,13 +301,13 @@ def restore_indexes(self, warning_queue):
301
301
exception_type , exception_class , trcback = sys .exc_info ()
302
302
warning_queue .put ((exception_type , exception_class , traceback .extract_tb (trcback ), self ._source .name ))
303
303
304
- self .query_runner (
305
- "Write hook from: %s.%s" %
306
- ( self . db , self . table ), query . db (
307
- self .db ) .table (
308
- self .table ). get_write_hook ())
309
- try :
310
- if self . write_hook :
304
+ if self .write_hook :
305
+ self . query_runner (
306
+ "Write hook from: %s.%s" %
307
+ ( self .db , self .table ), query . db (
308
+ self .db ). table (
309
+ self . table ). get_write_hook ())
310
+ try :
311
311
self .query_runner (
312
312
"drop hook: %s.%s" % (self .db , self .table ),
313
313
query .db (self .db ).table (self .table ).set_write_hook (None )
@@ -316,9 +316,9 @@ def restore_indexes(self, warning_queue):
316
316
"create hook: %s.%s:%s" % (self .db , self .table , self .write_hook ),
317
317
query .db (self .db ).table (self .table ).set_write_hook (self .write_hook ["function" ])
318
318
)
319
- except RuntimeError :
320
- exception_type , exception_class , trcback = sys .exc_info ()
321
- warning_queue .put ((exception_type , exception_class , traceback .extract_tb (trcback ), self ._source .name ))
319
+ except RuntimeError :
320
+ exception_type , exception_class , trcback = sys .exc_info ()
321
+ warning_queue .put ((exception_type , exception_class , traceback .extract_tb (trcback ), self ._source .name ))
322
322
323
323
def batches (self , batch_size = None , warning_queue = None ):
324
324
@@ -1339,6 +1339,7 @@ def parse_sources(options, files_ignored=None):
1339
1339
def parse_info_file (path ):
1340
1340
primary_key = None
1341
1341
indexes = []
1342
+ write_hook = None
1342
1343
with open (path , 'r' ) as info_file :
1343
1344
metadata = json .load (info_file )
1344
1345
if "primary_key" in metadata :
@@ -1349,6 +1350,8 @@ def parse_info_file(path):
1349
1350
write_hook = metadata ["write_hook" ]
1350
1351
return primary_key , indexes , write_hook
1351
1352
1353
+ has_write_hooks = utils_common .check_minimum_version (options , '2.3.7' , False )
1354
+
1352
1355
sources = set ()
1353
1356
if files_ignored is None :
1354
1357
files_ignored = []
@@ -1382,6 +1385,8 @@ def parse_info_file(path):
1382
1385
indexes = info_indexes
1383
1386
if write_hook is None :
1384
1387
write_hook = info_write_hook
1388
+ if write_hook and not has_write_hooks :
1389
+ raise Exception ('this RDB version doesn\' t support write-hooks' )
1385
1390
1386
1391
sources .add (
1387
1392
table_type (
@@ -1446,6 +1451,8 @@ def parse_info_file(path):
1446
1451
files_ignored .append (os .path .join (root , filename ))
1447
1452
else :
1448
1453
primary_key , indexes , write_hook = parse_info_file (info_path )
1454
+ if write_hook and not has_write_hooks :
1455
+ raise Exception ('RDB versions below doesn\' t support write-hooks' )
1449
1456
1450
1457
table_type = None
1451
1458
if ext == ".json" :
0 commit comments