Skip to content

proposing a closeable prepare #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions lib/internal/connection/impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MySqlConnectionImpl implements MySqlConnection {
Future<Prepared> prepare(String sql) async {
PreparedQuery query =
await _socket.execHandler(PrepareHandler(sql), _timeout);
return PreparedImpl._(this, query);
return PreparedImpl._(_socket, _timeout, this, query);
}

Future<Transaction> begin() => Transaction.begin(this);
Expand Down Expand Up @@ -120,8 +120,10 @@ class MySqlConnectionImpl implements MySqlConnection {
class PreparedImpl implements Prepared {
final MySqlConnectionImpl _conn;
final PreparedQuery _query;
final Comm _socket;
final Duration _timeout;

PreparedImpl._(this._conn, this._query);
PreparedImpl._(this._socket, this._timeout, this._conn, this._query);

@override
Future<StreamedResults> execute(Iterable values) =>
Expand All @@ -144,5 +146,8 @@ class PreparedImpl implements Prepared {
}

@override
Future<void> deallocate() => throw UnimplementedError();
Future<void> deallocate() async {
await _socket.execHandlerNoResponse(
CloseStatementHandler(_query.statementHandlerId), _timeout);
}
}