Skip to content

Commit a18eb25

Browse files
committed
feat: build result_set
1 parent af5e332 commit a18eb25

File tree

7 files changed

+414
-25
lines changed

7 files changed

+414
-25
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
.dart_tool/
33
.vscode/
44

5-
**/pubspec.lock
5+
**/pubspec.lock
6+
7+
**/*_ye_dev.dart

example/lib/example.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ void main(List<String> args) async {
1919
);
2020

2121
var stmt = await conn.createStatement();
22-
await conn.executeQuery('use test');
23-
var rs = await stmt.executeQuery('MATCH (n) RETURN n LIMIT 10;');
22+
var rs = await stmt.executeQuery('SHOW SPACES;');
2423

2524
print(rs);
2625
await conn.close();

lib/nebula_dart_gdbc.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'dart:convert';
44
import 'dart:typed_data';
55

66
import 'package:nebula_dart_gdbc/nebula_dart_gdbc.dart';
7-
import 'package:nebula_graph/nebula_graph.dart';
7+
import 'package:nebula_graph/nebula_graph.dart' as ng;
88

99
// export all dart_gdbc and alias it to gdbc
1010
export 'package:dart_gdbc/dart_gdbc.dart';
@@ -15,3 +15,4 @@ part 'src/ng_statement.dart';
1515
part 'src/ng_prepared_statement.dart';
1616
part 'src/ng_result_set.dart';
1717
part 'src/ng_result_set_meta_data.dart';
18+
part 'src/ng_result_handler.dart';

lib/src/ng_connection.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class NgConnection implements Connection {
2323

2424
NgConnection._();
2525

26-
late TSocketTransport socketTransport;
27-
late TFramedTransport transport;
28-
late THeaderProtocol protocol;
29-
late GraphServiceClient client;
26+
late ng.TSocketTransport socketTransport;
27+
late ng.TFramedTransport transport;
28+
late ng.THeaderProtocol protocol;
29+
late ng.GraphServiceClient client;
3030
late Map<String, dynamic> properties;
3131
int? _sessionId;
3232
int? timezoneOffset;
@@ -41,19 +41,19 @@ class NgConnection implements Connection {
4141
/// 因为连接还没有打开。
4242
NgConnection._create(Uri address, {Map<String, dynamic>? properties}) {
4343
this.properties = properties ?? <String, dynamic>{};
44-
socketTransport = TSocketTransport(
44+
socketTransport = ng.TSocketTransport(
4545
host: address.host,
4646
port: address.port,
4747
connectionTimeout: properties?[timeoutKey] ?? 6000,
4848
);
4949

50-
transport = THeaderTransport(
50+
transport = ng.THeaderTransport(
5151
transport: socketTransport,
52-
clientTypes: [ClientTypes.HEADERS],
52+
clientTypes: [ng.ClientTypes.HEADERS],
5353
supportedClients: [false]);
5454

55-
protocol = THeaderProtocol(transport);
56-
client = GraphServiceClient(protocol);
55+
protocol = ng.THeaderProtocol(transport);
56+
client = ng.GraphServiceClient(protocol);
5757
}
5858

5959
/// Invoked in [DriverManager.getConnection], after the connection created.
@@ -73,10 +73,10 @@ class NgConnection implements Connection {
7373
/// 检查客户端和服务端的版本是否兼容
7474
/// 如果不兼容,抛出异常
7575
Future<void> verifyVersion() async {
76-
VerifyClientVersionResp resp =
77-
await client.verifyClientVersion(VerifyClientVersionReq());
76+
ng.VerifyClientVersionResp resp =
77+
await client.verifyClientVersion(ng.VerifyClientVersionReq());
7878

79-
if (resp.error_code != ErrorCode.SUCCEEDED) {
79+
if (resp.error_code != ng.ErrorCode.SUCCEEDED) {
8080
throw VersionException(
8181
message: String.fromCharCodes(resp.error_msg ?? []));
8282
}
@@ -86,12 +86,12 @@ class NgConnection implements Connection {
8686
///
8787
/// 认证用户
8888
Future<void> authencate() async {
89-
AuthResponse resp = await client.authenticate(
89+
ng.AuthResponse resp = await client.authenticate(
9090
Int8List.fromList(utf8.encode(properties[DriverManager.usrKey] ?? '')),
9191
Int8List.fromList(utf8.encode(properties[DriverManager.pwdKey] ?? '')),
9292
);
9393

94-
if (resp.error_code != ErrorCode.SUCCEEDED) {
94+
if (resp.error_code != ng.ErrorCode.SUCCEEDED) {
9595
if (resp.error_msg != null) {
9696
throw ConnectException(message: String.fromCharCodes(resp.error_msg!));
9797
} else {

0 commit comments

Comments
 (0)