Skip to content

Commit 81c7d64

Browse files
committed
v0.0.1+1
1 parent 5707a4d commit 81c7d64

17 files changed

+225
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 0.0.1
1+
## 0.0.1+1
22

33
- Provided driver manager which can be used to register drivers and get a driver by its legal url
44

example/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://dart.dev/guides/libraries/private-files
2+
# Created by `dart pub`
3+
.dart_tool/

example/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
- Initial version.

example/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
A sample command-line application with an entrypoint in `bin/`, library code
2+
in `lib/`, and example unit test in `test/`.

example/analysis_options.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file configures the static analysis results for your project (errors,
2+
# warnings, and lints).
3+
#
4+
# This enables the 'recommended' set of lints from `package:lints`.
5+
# This set helps identify many issues that may lead to problems when running
6+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7+
# style and format.
8+
#
9+
# If you want a smaller set of lints you can change this to specify
10+
# 'package:lints/core.yaml'. These are just the most critical lints
11+
# (the recommended set includes the core lints).
12+
# The core lints are also what is used by pub.dev for scoring packages.
13+
14+
include: package:lints/recommended.yaml
15+
16+
# Uncomment the following section to specify additional rules.
17+
18+
# linter:
19+
# rules:
20+
# - camel_case_types
21+
22+
# analyzer:
23+
# exclude:
24+
# - path/to/excluded/files/**
25+
26+
# For more information about the core and recommended set of lints, see
27+
# https://dart.dev/go/core-lints
28+
29+
# For additional information about configuring this file, see
30+
# https://dart.dev/guides/language/analysis-options

example/lib/example.dart

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// Copyright (c) 2023- All dart_gdbc authors. All rights reserved.
2+
//
3+
// This source code is licensed under Apache 2.0 License.
4+
import 'package:dart_gdbc/dart_gdbc.dart';
5+
6+
void main() async {
7+
DriverManager.registerDriver(SampleDriver());
8+
var conn = await DriverManager.getConnection('gdbc.dbname://ip:port/dbname');
9+
conn.createStatement();
10+
ResultSet rs = await conn.executeQuery('MATCH (n) RETURN n');
11+
print(rs);
12+
}
13+
14+
class SampleDriver extends Driver {
15+
@override
16+
bool acceptsURL(String url) {
17+
return url.startsWith('gdbc.dbname://');
18+
}
19+
20+
@override
21+
Future<Connection> connect(String url, {Map<String, dynamic>? properties}) {
22+
return Future.value(SampleConnection());
23+
}
24+
}
25+
26+
class SampleStatement extends Statement {
27+
@override
28+
Future<bool> execute([String? gql]) {
29+
// TODO: implement execute
30+
throw UnimplementedError();
31+
}
32+
33+
@override
34+
Future<ResultSet> executeQuery([String? gql]) {
35+
print(gql);
36+
return Future.value(SampleResultSet());
37+
}
38+
39+
@override
40+
Future<int> executeUpdate(String? gql) {
41+
// TODO: implement executeUpdate
42+
throw UnimplementedError();
43+
}
44+
}
45+
46+
class SampleResultSet extends ResultSet {
47+
@override
48+
List<ValueMetaData> get metas => [];
49+
50+
@override
51+
List<List> get rows => [];
52+
}
53+
54+
class SampleConnection extends Connection {
55+
@override
56+
Future<void> close() {
57+
// TODO: implement close
58+
throw UnimplementedError();
59+
}
60+
61+
@override
62+
Future<void> commit() {
63+
// TODO: implement commit
64+
throw UnimplementedError();
65+
}
66+
67+
@override
68+
Future<Statement> createStatement() {
69+
return Future.value(SampleStatement());
70+
}
71+
72+
@override
73+
Future<ResultSet> executeQuery(String gql) {
74+
print(gql);
75+
return Future.value(SampleResultSet());
76+
}
77+
78+
@override
79+
Future<int> executeUpdate(String gql) {
80+
// TODO: implement executeUpdate
81+
throw UnimplementedError();
82+
}
83+
84+
@override
85+
Future<bool> getAutoCommit() {
86+
// TODO: implement getAutoCommit
87+
throw UnimplementedError();
88+
}
89+
90+
@override
91+
Future<ResultSetMetaData> getMetaData() {
92+
// TODO: implement getMetaData
93+
throw UnimplementedError();
94+
}
95+
96+
@override
97+
Future<bool> isClosed() {
98+
// TODO: implement isClosed
99+
throw UnimplementedError();
100+
}
101+
102+
@override
103+
Future<PreparedStatement> prepareStatement(String gql) {
104+
// TODO: implement prepareStatement
105+
throw UnimplementedError();
106+
}
107+
108+
@override
109+
Future<PreparedStatement> prepareStatementWithParameters(
110+
String gql, List<ParameterMetaData> parameters) {
111+
// TODO: implement prepareStatementWithParameters
112+
throw UnimplementedError();
113+
}
114+
115+
@override
116+
Future<void> rollback() {
117+
// TODO: implement rollback
118+
throw UnimplementedError();
119+
}
120+
121+
@override
122+
Future<void> setAutoCommit(bool autoCommit) {
123+
// TODO: implement setAutoCommit
124+
throw UnimplementedError();
125+
}
126+
}

example/pubspec.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: example
2+
description: A sample command-line application.
3+
version: 1.0.0
4+
publish_to: none
5+
# repository: https://github.com/my_org/my_repo
6+
7+
environment:
8+
sdk: '>=2.19.0 <3.0.0'
9+
10+
dependencies:
11+
dart_gdbc:
12+
path: ../
13+
14+
dev_dependencies:
15+
lints: ^2.0.0
16+
test: ^1.21.0

lib/src/connection.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,42 @@
44

55
part of dart_gdbc;
66

7+
/// A connection (session) with a specific database.
78
abstract class Connection {
9+
/// Creates a new [Statement] instance.
810
Future<Statement> createStatement();
911

12+
/// Creates a new [PreparedStatement] instance.
1013
Future<PreparedStatement> prepareStatement(String gql);
1114

15+
/// Creates a new [PreparedStatement] instance with parameters.
1216
Future<PreparedStatement> prepareStatementWithParameters(
1317
String gql, List<ParameterMetaData> parameters);
1418

19+
/// Executes a query.
1520
Future<ResultSet> executeQuery(String gql);
1621

22+
/// Executes an update.
1723
Future<int> executeUpdate(String gql);
1824

25+
/// Connection state if auto commit is enabled.
1926
Future<bool> getAutoCommit();
2027

28+
/// Set connection state if auto commit is enabled.
2129
Future<void> setAutoCommit(bool autoCommit);
2230

31+
/// Commits all changes made since the previous commit/rollback.
2332
Future<void> commit();
2433

34+
/// Undoes all changes made in the current transaction.
2535
Future<void> rollback();
2636

37+
/// Closes the connection.
2738
Future<void> close();
2839

40+
/// Checks if the connection is closed.
2941
Future<bool> isClosed();
3042

43+
/// Gets the metadata of the connection.
3144
Future<ResultSetMetaData> getMetaData();
3245
}

lib/src/exeception/connect_exception.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
part of dart_gdbc;
66

7+
/// Exception thrown when a connection to a database could not be established.
8+
///---
9+
/// 當無法連接到數據庫時拋出的異常。
10+
///---
11+
/// 当无法连接到数据库时抛出的异常。
712
class ConnectException extends GdbcException {
813
ConnectException({String? message, Error? cause})
914
: super(message: message, cause: cause);

lib/src/exeception/gdbc_exception.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
part of dart_gdbc;
66

7+
/// A super class for all exceptions thrown by dart_gdbc.
78
class GdbcException implements Error {
89
final String? message;
910

0 commit comments

Comments
 (0)