Fix parsing issue in packages.

This commit is contained in:
Harshal Dhumal 2016-08-22 16:49:32 +01:00 committed by Dave Page
parent cf1be2a320
commit 58a79e4fc6
4 changed files with 42 additions and 17 deletions

View File

@ -8,7 +8,7 @@
##########################################################################
"""Implements Package Node"""
import re
import simplejson as json
from functools import wraps
@ -662,16 +662,18 @@ class PackageView(PGChildNodeView):
def get_inner(sql):
if sql is None:
return None
start = 0
start_position = re.search("\s+[is|as]+\s+", sql, flags=re.I)
sql = sql.lower()
start = sql.find('is')
if start == -1:
start = sql.find('as')
if start_position:
start = start_position.start() + 4
end = max(sql.rfind('end;'), sql.rfind('end'))
try:
end_position = [i for i in re.finditer("end", sql, flags=re.I)][-1]
end = end_position.start()
except IndexError:
return sql[start:].strip("\n")
if start == -1:
return sql[0: end].strip("\n")
return sql[start+2: end].strip("\n")
return sql[start:end].strip("\n")
PackageView.register_node_view(blueprint)

View File

@ -10,6 +10,7 @@
"""Implements Edb Functions/Edb Procedures Node."""
import copy
import re
from functools import wraps
import pgadmin.browser.server_groups.servers.databases.schemas.packages as packages
@ -563,17 +564,19 @@ It may have been removed by another user or moved to another schema.
def get_inner(sql):
if sql is None:
return None
start = 0
start_position = re.search("\s+[is|as]+\s+", sql, flags=re.I)
sql = sql.lower()
start = sql.find('is')
if start == -1:
start = sql.find('as')
if start_position:
start = start_position.start() + 4
end = max(sql.rfind('end;'), sql.rfind('end'))
try:
end_position = [i for i in re.finditer("end", sql, flags=re.I)][-1]
end = end_position.start()
except IndexError:
return sql[start:].strip("\n")
if start == -1:
return sql[0: end].strip("\n")
return sql[start+2: end].strip("\n")
return sql[start:end].strip("\n")
EdbFuncView.register_node_view(blueprint)

View File

@ -10,7 +10,16 @@ CREATE OR REPLACE PACKAGE {{ conn|qtIdent(data.schema,data.name) }}
IS
{{data.pkgheadsrc}}
END {{ conn|qtIdent(data.name) }};
CREATE OR REPLACE PACKAGE BODY {{ conn|qtIdent(data.schema,data.name) }}
IS
{% if data.pkgbodysrc %}
{{data.pkgbodysrc}}
{% else %}
{{o_data.pkgbodysrc}}
{% endif %}
END {{ conn|qtIdent(data.name) }};
{% else %}
{% if data.pkgbodysrc %}
CREATE OR REPLACE PACKAGE BODY {{ conn|qtIdent(data.schema,data.name) }}
@ -18,6 +27,7 @@ IS
{{data.pkgbodysrc}}
END {{ conn|qtIdent(data.name) }};
{% endif %}
{% endif %}
{% if data.pkgacl %}
{% if 'deleted' in data.pkgacl %}
{% for priv in data.pkgacl.deleted %}

View File

@ -10,7 +10,16 @@ CREATE OR REPLACE PACKAGE {{ conn|qtIdent(data.schema,data.name) }}
IS
{{data.pkgheadsrc}}
END {{ conn|qtIdent(data.name) }};
CREATE OR REPLACE PACKAGE BODY {{ conn|qtIdent(data.schema,data.name) }}
IS
{% if data.pkgbodysrc %}
{{data.pkgbodysrc}}
{% else %}
{{o_data.pkgbodysrc}}
{% endif %}
END {{ conn|qtIdent(data.name) }};
{% else %}
{% if data.pkgbodysrc %}
CREATE OR REPLACE PACKAGE BODY {{ conn|qtIdent(data.schema,data.name) }}
@ -18,6 +27,7 @@ IS
{{data.pkgbodysrc}}
END {{ conn|qtIdent(data.name) }};
{% endif %}
{% endif %}
{% if data.pkgacl %}
{% if 'deleted' in data.pkgacl %}
{% for priv in data.pkgacl.deleted %}