summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2009-07-12 10:15:19 +0200
committerAndi Albrecht <albrecht.andi@gmail.com>2009-07-12 10:15:19 +0200
commitd8a0300bab3a77fba7fa6014ab7fa7c5ae388aaa (patch)
tree5846796988b5382fbce187032f1ee3c625388fd9 /sqlparse
parentd899c928f8839cb85b06ced865eb65d1684f3ad8 (diff)
downloadsqlparse-d8a0300bab3a77fba7fa6014ab7fa7c5ae388aaa.tar.gz
Add parent relationships.
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/sql.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/sqlparse/sql.py b/sqlparse/sql.py
index 1c99a53..b5ba902 100644
--- a/sqlparse/sql.py
+++ b/sqlparse/sql.py
@@ -15,11 +15,12 @@ class Token(object):
the type of the token.
"""
- __slots__ = ('value', 'ttype',)
+ __slots__ = ('value', 'ttype', 'parent')
def __init__(self, ttype, value):
self.value = value
self.ttype = ttype
+ self.parent = None
def __str__(self):
return unicode(self).encode('latin-1')
@@ -268,6 +269,9 @@ class TokenList(Token):
for t in tokens:
self.tokens.remove(t)
grp = grp_cls(tokens)
+ for token in tokens:
+ token.parent = grp
+ grp.parent = self
self.tokens.insert(idx, grp)
return grp