2019-06-15 14:01:10 -07:00
|
|
|
# sqlparser
|
|
|
|
|
2019-06-26 14:07:30 -07:00
|
|
|
An sql parser and static analyzer, written in pure Dart. Currently in development.
|
2019-06-22 13:35:34 -07:00
|
|
|
|
|
|
|
## Using this library
|
|
|
|
|
|
|
|
```dart
|
|
|
|
import 'package:sqlparser/sqlparser.dart';
|
|
|
|
|
|
|
|
final engine = SqlEngine();
|
|
|
|
final stmt = engine.parse('''
|
|
|
|
SELECT f.* FROM frameworks f
|
|
|
|
INNER JOIN uses_language ul ON ul.framework = f.id
|
|
|
|
INNER JOIN languages l ON l.id = ul.language
|
|
|
|
WHERE l.name = 'Dart'
|
|
|
|
ORDER BY f.name ASC, f.popularity DESC
|
|
|
|
LIMIT 5 OFFSET 5 * 3
|
|
|
|
''');
|
|
|
|
// ???
|
|
|
|
profit();
|
2019-06-26 14:07:30 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
## Features
|
|
|
|
Not all features are available yet, put parsing select statements (even complex ones!) and
|
|
|
|
performing analysis on them works!
|
|
|
|
|
|
|
|
### AST Parsing
|
|
|
|
Can parse the abstract syntax tree of any sqlite statement with `SqlEngine.parse`.
|
|
|
|
|
|
|
|
### Static analysis
|
|
|
|
|
|
|
|
Given information about all tables and a sql statement, this library can:
|
|
|
|
|
|
|
|
1. determine which result rows a query is going to have
|
|
|
|
2. Determine the static type of variables included in the query
|
|
|
|
3. issue some basic warnings on queries that are syntactically valid but won't run
|