This function will return modified SQL
(sid, did)
| 407 | @pga_login_required |
| 408 | @check_precondition |
| 409 | def msql(sid, did): |
| 410 | """ |
| 411 | This function will return modified SQL |
| 412 | """ |
| 413 | server_prop = server_info |
| 414 | data = get_req_data() |
| 415 | # Form db connection |
| 416 | manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid) |
| 417 | conn = manager.connection(did=did) |
| 418 | |
| 419 | acls = [] |
| 420 | try: |
| 421 | acls = render_template( |
| 422 | "/".join([server_prop['template_path'], '/acl.json']) |
| 423 | ) |
| 424 | acls = json.loads(acls) |
| 425 | except Exception as e: |
| 426 | current_app.logger.exception(e) |
| 427 | |
| 428 | try: |
| 429 | # Parse privileges |
| 430 | data['priv'] = {} |
| 431 | if 'acl' in data: |
| 432 | # Get function acls |
| 433 | data['priv']['function'] = parse_priv_to_db( |
| 434 | data['acl'], |
| 435 | acls['function']['acl']) |
| 436 | |
| 437 | data['priv']['sequence'] = parse_priv_to_db( |
| 438 | data['acl'], |
| 439 | acls['sequence']['acl']) |
| 440 | |
| 441 | data['priv']['table'] = parse_priv_to_db( |
| 442 | data['acl'], |
| 443 | acls['table']['acl']) |
| 444 | |
| 445 | data['priv']['foreign_table'] = parse_priv_to_db( |
| 446 | data['acl'], |
| 447 | acls['foreign_table']['acl']) |
| 448 | |
| 449 | # Logic for setting privileges only for ppas |
| 450 | set_priv_for_package(server_prop, data, acls) |
| 451 | |
| 452 | # Pass database objects and get SQL for privileges |
| 453 | sql_data = '' |
| 454 | data_func = {'objects': data['objects'], |
| 455 | 'priv': data['priv']['function']} |
| 456 | sql = render_template( |
| 457 | "/".join([server_prop['template_path'], |
| 458 | '/sql/grant_function.sql']), |
| 459 | data=data_func, conn=conn) |
| 460 | if sql and sql.strip('\n') != '': |
| 461 | sql_data += sql |
| 462 | |
| 463 | data_seq = {'objects': data['objects'], |
| 464 | 'priv': data['priv']['sequence']} |
| 465 | sql = render_template( |
| 466 | "/".join([server_prop['template_path'], |
nothing calls this directly
no test coverage detected