diff options
| author | quest <quest@wonky.windwards.net> | 2012-04-21 20:28:49 +0200 |
|---|---|---|
| committer | quest <quest@wonky.windwards.net> | 2012-04-21 20:28:49 +0200 |
| commit | 61f22063051fa94b0f055a995eed10b576535c29 (patch) | |
| tree | dcc1de1b1ad4b8bd27cd8524cbe8c9cd714e0c90 /sqlparse | |
| parent | 13274ebb0d66b64363145bf23b6aa824845f61be (diff) | |
| download | sqlparse-61f22063051fa94b0f055a995eed10b576535c29.tar.gz | |
Minor clarifications and doc updates
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/__init__.py | 8 | ||||
| -rw-r--r-- | sqlparse/lexer.py | 14 |
2 files changed, 12 insertions, 10 deletions
diff --git a/sqlparse/__init__.py b/sqlparse/__init__.py index bacaa78..e622292 100644 --- a/sqlparse/__init__.py +++ b/sqlparse/__init__.py @@ -54,14 +54,14 @@ def split(sql): stack.split_statements = True return [unicode(stmt) for stmt in stack.run(sql)] -def splitstream(sql): - """Split *sql* into single statements. +def splitstream(stream): + """Split sql statements from file-like object . - Returns a list of strings. + Returns a list of Statement objects. """ stack = engine.FilterStack() stack.split_statements = True - return stack.run(sql) + return stack.run(stream) from sqlparse.engine.filter import StatementFilter def split2(stream): diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index 82a6169..a0ce5d2 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -279,6 +279,7 @@ class Lexer(object): m = rexmatch(text, pos) if m: if hasmore and m.end() == len(text): + # Since this is end, token may be truncated continue # print rex.pattern @@ -315,13 +316,14 @@ class Lexer(object): statetokens = tokendefs[statestack[-1]] break else: + if hasmore: + buf = self._decode(stream.read(self.bufsize)) + hasmore = len(buf) == self.bufsize + text = text[pos:] + buf + pos = 0 + continue + try: - if hasmore: - buf = self._decode(stream.read(self.bufsize)) - hasmore = len(buf) == self.bufsize - text = text[pos:] + buf - pos = 0 - continue if text[pos] == '\n': # at EOL, reset state to "root" pos += 1 |
