|
|
@ -108,6 +108,7 @@ def meta(config) :
|
|
|
|
def create (**_args) :
|
|
|
|
def create (**_args) :
|
|
|
|
skip = [] if 'skip' not in _args else _args['skip']
|
|
|
|
skip = [] if 'skip' not in _args else _args['skip']
|
|
|
|
fields = ([_args['key']] if 'key' in _args else []) + _args['fields']
|
|
|
|
fields = ([_args['key']] if 'key' in _args else []) + _args['fields']
|
|
|
|
|
|
|
|
fields = ['_id'] + fields
|
|
|
|
table = _args['table']
|
|
|
|
table = _args['table']
|
|
|
|
sql = ['CREATE TABLE :table ',"(",",\n".join(["\t".join(["\t",name,"VARCHAR(125)"]) for name in fields]),")"]
|
|
|
|
sql = ['CREATE TABLE :table ',"(",",\n".join(["\t".join(["\t",name,"VARCHAR(125)"]) for name in fields]),")"]
|
|
|
|
return " ".join(sql)
|
|
|
|
return " ".join(sql)
|
|
|
@ -145,7 +146,7 @@ def init (**_args) :
|
|
|
|
|
|
|
|
|
|
|
|
_name = "".join(["$",field_name])
|
|
|
|
_name = "".join(["$",field_name])
|
|
|
|
project[field_name] = {"$ifNull":[_name,""]}
|
|
|
|
project[field_name] = {"$ifNull":[_name,""]}
|
|
|
|
project["_id"] = 0
|
|
|
|
project["_id"] = 1
|
|
|
|
project = {"$project":project}
|
|
|
|
project = {"$project":project}
|
|
|
|
|
|
|
|
|
|
|
|
r = [{"table":TABLE_NAME,"mongo":{"aggregate":TABLE_NAME,"pipeline":[project],"cursor":{},"allowDiskUse":True},"sql":create(table=TABLE_NAME,fields=_info['main'])}]
|
|
|
|
r = [{"table":TABLE_NAME,"mongo":{"aggregate":TABLE_NAME,"pipeline":[project],"cursor":{},"allowDiskUse":True},"sql":create(table=TABLE_NAME,fields=_info['main'])}]
|
|
|
@ -154,12 +155,12 @@ def init (**_args) :
|
|
|
|
# NOTE: Adding _index to the fields
|
|
|
|
# NOTE: Adding _index to the fields
|
|
|
|
fields = _info['rel'][table] +["_index"]
|
|
|
|
fields = _info['rel'][table] +["_index"]
|
|
|
|
|
|
|
|
|
|
|
|
project = {"_id":0,"claim_id":1,"_index":1} #dict.fromkeys(["_id","claim_id"]+fields,[ ".".join([table,field_name]) for field_name in fields])
|
|
|
|
project = {"_id":1,"claim_id":1,"_index":1} #dict.fromkeys(["_id","claim_id"]+fields,[ ".".join([table,field_name]) for field_name in fields])
|
|
|
|
for field_name in fields :
|
|
|
|
for field_name in fields :
|
|
|
|
# project[field_name] = "$"+".".join([table,field_name])
|
|
|
|
# project[field_name] = "$"+".".join([table,field_name])
|
|
|
|
_name = "$"+".".join([table,field_name])
|
|
|
|
_name = "$"+".".join([table,field_name])
|
|
|
|
project[field_name] = {"$ifNull":[_name,""]} #{"$cond":[{"$eq":[_name,None]},"",_name]}
|
|
|
|
project[field_name] = {"$ifNull":[_name,""]} #{"$cond":[{"$eq":[_name,None]},"",_name]}
|
|
|
|
project["_id"] = 0
|
|
|
|
project["_id"] = 1
|
|
|
|
pipeline = [{"$unwind":"$"+table},{"$project":project}]
|
|
|
|
pipeline = [{"$unwind":"$"+table},{"$project":project}]
|
|
|
|
r += [{"table":table,"mongo":{"aggregate":TABLE_NAME,"cursor":{},"pipeline":pipeline,"allowDiskUse":True},"sql":create(table=table,key='claim_id',fields=fields)}]
|
|
|
|
r += [{"table":table,"mongo":{"aggregate":TABLE_NAME,"cursor":{},"pipeline":pipeline,"allowDiskUse":True},"sql":create(table=table,key='claim_id',fields=fields)}]
|
|
|
|
|
|
|
|
|
|
|
|