PlsqlParser 0.1.0-preview.1
See the version list below for details.
dotnet add package PlsqlParser --version 0.1.0-preview.1
NuGet\Install-Package PlsqlParser -Version 0.1.0-preview.1
<PackageReference Include="PlsqlParser" Version="0.1.0-preview.1" />
<PackageVersion Include="PlsqlParser" Version="0.1.0-preview.1" />
<PackageReference Include="PlsqlParser" />
paket add PlsqlParser --version 0.1.0-preview.1
#r "nuget: PlsqlParser, 0.1.0-preview.1"
#:package PlsqlParser@0.1.0-preview.1
#addin nuget:?package=PlsqlParser&version=0.1.0-preview.1&prerelease
#tool nuget:?package=PlsqlParser&version=0.1.0-preview.1&prerelease
OracleSqlParser
A hand-written lexer and recursive-descent parser for Oracle SQL that builds an abstract syntax tree
(similar in spirit to Microsoft's TSqlParser/ScriptDom). .NET 10, no dependencies.
Installing
dotnet add package PlsqlParser --prerelease
The NuGet package is PlsqlParser, while the C# namespace (and assembly) is OracleSqlParser.
Targets net8.0 and net10.0. Versions are published as pre-releases (0.1.0-preview.N) until the API stabilises.
Releasing
Publishing uses nuget.org Trusted Publishing (GitHub OIDC) bound to .github/workflows/build.yml; no API key
secret is required.
- Bump
<Version>insrc/OracleSqlParser/OracleSqlParser.csproj(e.g.0.1.0-preview.2) and commit. - Tag the commit with the matching
v-prefixed version:git tag vX.Y.Z-preview.N(e.g.v0.1.0-preview.2). - Push the tag:
git push origin vX.Y.Z-preview.N.
The Build workflow runs on every push and pull request; its publish job runs only on v* tags. It checks that
the tag matches the csproj <Version>, then exchanges the GitHub OIDC token for a short-lived key and pushes the
package built by the build job to nuget.org.
Library
var result = SqlParser.Parse("SELECT e.name FROM emp e WHERE e.sal > :min");
if (!result.Success) foreach (var err in result.Errors) Console.WriteLine(err); // (line:col) message
foreach (var table in result.Script.Descendants().OfType<NamedTable>()) ...
string json = AstJson.Serialize(result.Script, includePositions: true);
SqlParser.Parsehandles multi-statement scripts (;or/), collects errors and resyncs at the next;.SqlParser.ParseStatement/ParseExpressionthrowParseExceptioninstead.- Every
SqlNodehasStart/End/Line/Column,Children()andDescendants(); subclassSqlVisitorto walk. - Unquoted identifiers are upper-cased in
Identifier.Value; quoted ones keep case (Quoted = true).
CLI
dotnet run --project src/OracleSqlParser.Cli -- [--positions] [--compact] [-f file | -e "sql"] # or stdin
Prints the AST as JSON; syntax errors go to stderr with exit code 1.
Coverage
See COVERAGE.md: every statement in Oracle's statement index, the node that represents it, whether
it is fully typed or a typed header with a token-tree body, and the known gaps. dotnet run --project src/OracleSqlParser.Cli -- --shape -e "..."
prints the compact tree used by the shape tests.
Tests
tests/OracleSqlParser.Tests: hand-written expected trees (*ShapeTests.cs, compared via AstPrinter) plus a smoke
corpus (SmokeCorpusTests.cs) that only checks inputs parse.
Validating and restricting user-supplied queries
var policy = new QueryPolicy
{
AllowedTables = new HashSet<string>(["ORDERS", "CUSTOMERS"], StringComparer.OrdinalIgnoreCase),
AllowedFunctions = new HashSet<string>(["UPPER", "LOWER", "TRUNC", "NVL"], StringComparer.OrdinalIgnoreCase), // safest
RequiredColumns = ["ID"],
};
var filter = new AccessFilter
{
KeyColumn = "ID",
AccessSql = "SELECT order_id FROM user_orders WHERE user_id = :accessUserId",
};
GuardedSql g = QueryGuard.RestrictToIds(userSql, policy, filter); // throws QueryRejectedException with all violations
var rows = connection.Query(g.Sql, new { accessUserId = 42, /* the user's own binds */ });
g.Sql is SELECT Q.* FROM (<user query>) Q WHERE Q.ID IN (<access query>): the restriction is applied outside the
user's query, so OR, UNION and GROUP BY inside it cannot bypass it. QueryGuard.Validate checks without wrapping.
SqlWriter.ToSql(node) prints any SELECT AST back to Oracle SQL (precedence-aware parentheses, so trees you edit
print correctly); non-query statements throw NotSupportedException.
Limits: output is Oracle SQL only (T-SQL needs ScriptDom); the generated SQL is verified by re-parsing and, in the integration tests, by running it against a live Oracle 23 Free
against a database; the user's top-level ORDER BY is moved outside the wrapper only when expressible on output columns.
Integration tests
tests/OracleSqlParser.IntegrationTests runs against a real Oracle database (the free gvenzl/oracle-free:23-slim-faststart
image, started with Testcontainers; Docker is required):
dotnet test tests/OracleSqlParser.IntegrationTests
One container is started per test run (first run pulls the image; allow a few minutes). They check that (a) the SQL printed
by SqlWriter is accepted by Oracle and returns the same columns and rows as the original query, (b) QueryGuard.RestrictToIds
output executes and only returns permitted ids for both AccessJoinStyle values, and (c) every statement of the smoke
corpus passes Oracle's own syntax check inside a scratch schema (PL/SQL-only forms such as SELECT ... INTO are asserted to be rejected). Container startup is capped at 8 minutes (override with ORACLE_TEST_STARTUP_TIMEOUT_SECONDS); on timeout the tests are skipped with a clear message. If Docker is not available the tests are skipped, not failed.
The default unit tests (dotnet test tests/OracleSqlParser.Tests) do not need Docker.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on PlsqlParser:
| Package | Downloads |
|---|---|
|
PlsqlParser.Guard
EXPERIMENTAL: policy validation and access-restriction rewriting for user-supplied Oracle SELECT queries, built on PlsqlParser. Not a security boundary; see README. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.4.0-preview.1 | 64 | 11/14/2026 |
| 0.3.0-preview.1 | 61 | 11/14/2026 |
| 0.2.0-preview.1 | 69 | 11/13/2026 |
| 0.1.0-preview.2 | 64 | 11/13/2026 |
| 0.1.0-preview.1 | 54 | 11/12/2026 |