Comments (4)
I already located the problem near tsql.py:115:
if isinstance(node, tsqlParser.Declare_statementContext):
self.dynamics.extend(result)
from pytsql.
Here is a failing testcase: 58a61a7
from pytsql.
I am trying to reliably detect whether DECLARE
is a top level statement. My current hypothesis is: a DECLARE statement is top level if the chain of parentCtx to the root (BatchContext) only includes Sql_clauseContext or Sql_clausesContext objects.
@staticmethod
def is_top_level_statement(node: ParserRuleContext):
"""Check wether node is a top level SQL statement."""
cur = node.parentCtx
while isinstance(cur, tsqlParser.Sql_clauseContext) or isinstance(cur, tsqlParser.Sql_clausesContext):
cur = cur.parentCtx
return isinstance(cur, tsqlParser.BatchContext)
from pytsql.
Why is the expectation that this SQL code should result in @declare statement to be unconditionally copied?
def test_declaration_in_control_flow():
seed = """
IF 1 = 1
DECLARE @A INT = 5
SELECT * FROM x
If it is, we might have to parse the IF statement outcome:
IF 1 = 0
DECLARE @A INT = 5
GO
SELECT @A
The second with GO
actually does not work in TSQL either. But this does:
DECLARE @A INT = 5
GO
SELECT @A
from pytsql.
Related Issues (20)
- Publish package on conda-forge
- Minimal Python version
- Add keywords in pyproject.toml
- Add sphinx documentation HOT 1
- Use flit-scm for version handling HOT 2
- Deal with freetds driver in CI
- `SET` statements for local variables are unreliable
- Support for `@@ROWCOUNT`
- Extend support for conditionals
- Potentially make running tests easier for Linux
- Spurious error during debugging: 'Namespace' object has no attribute 'backend' HOT 3
- pytsql silently changes the isolation level of my engine HOT 2
- Missing support for user-defined table types
- Test suite: one test disables C++ implementation for all subsequent ones
- Latest `speedy-antlr-tool` is not compatible with our ANTLR version HOT 1
- Hit test-pypi memory limit HOT 1
- Add support for returning result tables
- `sa.text()` needs to escape colons (in text)
- How to remove `#pytsql_prints` lines from logs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytsql.