mirror of https://github.com/AMT-Cheif/drift.git
Support collate expression with new type inference (#533)
This commit is contained in:
parent
7bfb2ab6d3
commit
bd250ee9e7
|
@ -28,6 +28,7 @@
|
|||
by default (instead of two methods for `get` and `watch`). Columns defined in moor files will have their
|
||||
sql name as json key (moor used to transform their name to `camelCase`).
|
||||
You can still disable both options to keep the old behavior.
|
||||
- __Breaking__: The last statement in a moor file must now end with a semicolon as well
|
||||
- Batches now run statements in the order they were issued. This required a breaking change for engine
|
||||
implementers.
|
||||
- Experimentally support IndexedDB to store sqlite data on the web
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
## 0.8.1
|
||||
|
||||
- Support collate expressions in the new type inference ([#533](https://github.com/simolus3/moor/issues/533))
|
||||
- Added `visitCollateExpression` to the visitor classes
|
||||
|
||||
## 0.8.0
|
||||
|
||||
- Remove `SqlEngine.withOptions` constructor - the default constructor now takes options
|
||||
|
|
|
@ -197,6 +197,12 @@ class TypeResolver extends RecursiveVisitor<TypeExpectation, void> {
|
|||
visitChildren(e, arg);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitCollateExpression(CollateExpression e, TypeExpectation arg) {
|
||||
session._checkAndResolve(e, _textType, arg);
|
||||
visit(e.inner, _expectString);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitUnaryExpression(UnaryExpression e, TypeExpectation arg) {
|
||||
final operatorType = e.operator.type;
|
||||
|
|
|
@ -29,6 +29,11 @@ class CollateExpression extends UnaryExpression {
|
|||
@required this.collateFunction})
|
||||
: super(operator, inner);
|
||||
|
||||
@override
|
||||
R accept<A, R>(AstVisitor<A, R> visitor, A arg) {
|
||||
return visitor.visitCollateExpression(this, arg);
|
||||
}
|
||||
|
||||
@override
|
||||
bool contentEquals(CollateExpression other) {
|
||||
return super.contentEquals(other) &&
|
||||
|
|
|
@ -44,6 +44,7 @@ abstract class AstVisitor<A, R> {
|
|||
R visitCastExpression(CastExpression e, A arg);
|
||||
R visitBinaryExpression(BinaryExpression e, A arg);
|
||||
R visitStringComparison(StringComparisonExpression e, A arg);
|
||||
R visitCollateExpression(CollateExpression e, A arg);
|
||||
R visitUnaryExpression(UnaryExpression e, A arg);
|
||||
R visitIsExpression(IsExpression e, A arg);
|
||||
R visitIsNullExpression(IsNullExpression e, A arg);
|
||||
|
@ -305,6 +306,11 @@ class RecursiveVisitor<A, R> implements AstVisitor<A, R> {
|
|||
return visitExpression(e, arg);
|
||||
}
|
||||
|
||||
@override
|
||||
R visitCollateExpression(CollateExpression e, A arg) {
|
||||
return visitUnaryExpression(e, arg);
|
||||
}
|
||||
|
||||
@override
|
||||
R visitUnaryExpression(UnaryExpression e, A arg) {
|
||||
return visitExpression(e, arg);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: sqlparser
|
||||
description: Parses sqlite statements and performs static analysis on them
|
||||
version: 0.8.0
|
||||
version: 0.8.1
|
||||
homepage: https://github.com/simolus3/moor/tree/develop/sqlparser
|
||||
#homepage: https://moor.simonbinder.eu/
|
||||
issue_tracker: https://github.com/simolus3/moor/issues
|
||||
|
|
|
@ -33,6 +33,8 @@ const Map<String, ResolvedType> _types = {
|
|||
'SELECT CURRENT_TIMESTAMP = ?': ResolvedType(type: BasicType.text),
|
||||
"SELECT COALESCE(NULL, 'foo') = ?": ResolvedType(type: BasicType.text),
|
||||
'SELECT NULLIF(3, 4) = ?': ResolvedType(type: BasicType.int, nullable: true),
|
||||
"SELECT 'foo' COLLATE NOCASE = ?": ResolvedType(type: BasicType.text),
|
||||
'SELECT ? COLLATE BINARY': ResolvedType(type: BasicType.text),
|
||||
'INSERT INTO demo DEFAULT VALUES ON CONFLICT (id) WHERE ? DO NOTHING':
|
||||
ResolvedType.bool(),
|
||||
'INSERT INTO demo DEFAULT VALUES ON CONFLICT DO UPDATE SET id = id WHERE ?':
|
||||
|
|
Loading…
Reference in New Issue