Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 57 additions & 56 deletions lib/rethinkdb_dart.dart

Large diffs are not rendered by default.

766 changes: 466 additions & 300 deletions lib/src/ast.dart

Large diffs are not rendered by default.

53 changes: 34 additions & 19 deletions lib/src/cursor.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
part of rethinkdb;

class Cursor extends Stream {
Connection _conn;
Query _query;
Map _opts;
final Connection _conn;
final Query _query;
final Map _opts;
int _outstandingRequests = 0;
bool _endFlag = false;
StreamController _s = StreamController();
final StreamController _s = StreamController();

Cursor(this._conn, this._query, this._opts);

Expand All @@ -16,7 +16,7 @@ class Cursor extends Stream {
if (response._type != p.Response_ResponseType.SUCCESS_PARTIAL.value &&
response._type != p.Response_ResponseType.SUCCESS_SEQUENCE.value) {
_s.addError(
RqlDriverError("Unexpected response type received for cursor"), null);
RqlDriverError('Unexpected response type received for cursor'), null);
}

try {
Expand All @@ -30,8 +30,8 @@ class Cursor extends Stream {
_s.addStream(Stream.fromIterable(convertedData)).then((f) {
if (!_endFlag) {
_outstandingRequests++;
Query query =
Query(p.Query_QueryType.CONTINUE, this._query._token, null, null);
var query =
Query(p.Query_QueryType.CONTINUE, _query._token, null, null);
query._cursor = this;
_conn._sendQueue.addLast(query);
_conn._sendQuery();
Expand All @@ -43,41 +43,56 @@ class Cursor extends Stream {

Future close() => _s.close();

StreamSubscription listen(Function onData,
{Function onError, Function onDone, bool cancelOnError}) {
return _s.stream.listen(onData,
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
@override
StreamSubscription listen(Function? onData,
{Function? onError, Function? onDone, bool? cancelOnError}) {
return _s.stream.listen(onData as void Function(dynamic)?,
onError: onError,
onDone: onDone as void Function()?,
cancelOnError: cancelOnError);
}
}

class Feed extends Cursor {
Feed(conn, opts, query) : super(conn, opts, query);

toSet() => throw RqlDriverError("`toSet` is not available for feeds.");
toList() => throw RqlDriverError("`toList` is not available for feeds.");
@override
toSet() => throw RqlDriverError('`toSet` is not available for feeds.');
@override
toList() => throw RqlDriverError('`toList` is not available for feeds.');
@override
toString() => "Instance of 'Feed'";
}

class UnionedFeed extends Cursor {
UnionedFeed(conn, opts, query) : super(conn, opts, query);

toSet() => throw RqlDriverError("`toSet` is not available for feeds.");
toList() => throw RqlDriverError("`toList` is not available for feeds.");
@override
toSet() => throw RqlDriverError('`toSet` is not available for feeds.');
@override
toList() => throw RqlDriverError('`toList` is not available for feeds.');
@override
toString() => "Instance of 'UnionedFeed'";
}

class AtomFeed extends Cursor {
AtomFeed(conn, opts, query) : super(conn, opts, query);

toSet() => throw RqlDriverError("`toSet` is not available for feeds.");
toList() => throw RqlDriverError("`toList` is not available for feeds.");
@override
toSet() => throw RqlDriverError('`toSet` is not available for feeds.');
@override
toList() => throw RqlDriverError('`toList` is not available for feeds.');
@override
toString() => "Instance of 'AtomFeed'";
}

class OrderByLimitFeed extends Cursor {
OrderByLimitFeed(conn, opts, query) : super(conn, opts, query);

toSet() => throw RqlDriverError("`toSet` is not available for feeds.");
toList() => throw RqlDriverError("`toList` is not available for feeds.");
@override
toSet() => throw RqlDriverError('`toSet` is not available for feeds.');
@override
toList() => throw RqlDriverError('`toList` is not available for feeds.');
@override
toString() => "Instance of 'OrderByLimitFeed'";
}
28 changes: 15 additions & 13 deletions lib/src/errors.dart
Original file line number Diff line number Diff line change
@@ -1,69 +1,71 @@
part of rethinkdb;

class RqlError implements Exception {
String message;
String? message;
var term;
var frames;

RqlError(this.message, this.term, this.frames);

toString() => "${this.runtimeType}!\n\n$message\n\n$term\n\n$frames";
@override
toString() => '$runtimeType!\n\n$message\n\n$term\n\n$frames';
}

class RqlClientError extends RqlError {
RqlClientError(String message, term, frames) : super(message, term, frames);
RqlClientError(String? message, term, frames) : super(message, term, frames);
}

class RqlCompileError extends RqlError {
RqlCompileError(String message, term, frames) : super(message, term, frames);
RqlCompileError(String? message, term, frames) : super(message, term, frames);
}

class RqlRuntimeError extends RqlError {
RqlRuntimeError(String message, term, frames) : super(message, term, frames);
RqlRuntimeError(String? message, term, frames) : super(message, term, frames);
}

class RqlDriverError implements Exception {
String message;
RqlDriverError(this.message);

@override
toString() => message;
}

class ReqlInternalError extends RqlRuntimeError {
ReqlInternalError(String message, term, frames)
ReqlInternalError(String? message, term, frames)
: super(message, term, frames);
}

class ReqlResourceLimitError extends RqlRuntimeError {
ReqlResourceLimitError(String message, term, frames)
ReqlResourceLimitError(String? message, term, frames)
: super(message, term, frames);
}

class ReqlQueryLogicError extends RqlRuntimeError {
ReqlQueryLogicError(String message, term, frames)
ReqlQueryLogicError(String? message, term, frames)
: super(message, term, frames);
}

class ReqlNonExistenceError extends RqlRuntimeError {
ReqlNonExistenceError(String message, term, frames)
ReqlNonExistenceError(String? message, term, frames)
: super(message, term, frames);
}

class ReqlOpFailedError extends RqlRuntimeError {
ReqlOpFailedError(String message, term, frames)
ReqlOpFailedError(String? message, term, frames)
: super(message, term, frames);
}

class ReqlOpIndeterminateError extends RqlRuntimeError {
ReqlOpIndeterminateError(String message, term, frames)
ReqlOpIndeterminateError(String? message, term, frames)
: super(message, term, frames);
}

class ReqlUserError extends RqlRuntimeError {
ReqlUserError(String message, term, frames) : super(message, term, frames);
ReqlUserError(String? message, term, frames) : super(message, term, frames);
}

class ReqlPermissionError extends RqlRuntimeError {
ReqlPermissionError(String message, term, frames)
ReqlPermissionError(String? message, term, frames)
: super(message, term, frames);
}
Loading