Skip to content

Commit

Permalink
Move legacy files into src/v2/ directory. (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Oct 15, 2023
1 parent 9fb9eab commit b174a90
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 44 deletions.
7 changes: 4 additions & 3 deletions lib/postgres.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ library postgres;

import 'src/types.dart';

export 'src/connection.dart';
export 'src/execution_context.dart';
export 'src/exceptions.dart';
export 'src/replication.dart' show ReplicationMode;
export 'src/substituter.dart';
export 'src/types.dart';
export 'src/v2/connection.dart';
export 'src/v2/execution_context.dart';
export 'src/v2/substituter.dart';

typedef PostgreSQLDataType = PgDataType<Object>;
typedef PostgreSQLSeverity = PgSeverity;
2 changes: 1 addition & 1 deletion lib/src/auth/sasl_authenticator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'dart:typed_data';

import 'package:sasl_scram/sasl_scram.dart';

import '../../postgres.dart';
import '../buffer.dart';
import '../client_messages.dart';
import '../exceptions.dart';
import '../server_messages.dart';
import 'auth.dart';

Expand Down
3 changes: 1 addition & 2 deletions lib/src/client_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import 'package:postgres/src/time_converters.dart';

import 'buffer.dart';
import 'constants.dart';
import 'query.dart';
import 'replication.dart';

import 'shared_messages.dart';
import 'types.dart';
import 'v2/query.dart';

abstract class ClientMessage extends BaseMessage {
static const int FormatText = 0;
Expand Down
5 changes: 4 additions & 1 deletion lib/src/exceptions.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
part of postgres.connection;
import 'package:meta/meta.dart';

import 'server_messages.dart';
import 'types.dart';

/// Exception thrown by [PostgreSQLConnection] instances.
class PostgreSQLException implements Exception {
Expand Down
7 changes: 4 additions & 3 deletions lib/src/server_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import 'dart:convert';
import 'dart:typed_data';

import 'package:meta/meta.dart';
import 'package:postgres/messages.dart';
import 'package:postgres/src/buffer.dart';

import 'query.dart';
import 'buffer.dart';
import 'logical_replication_messages.dart';
import 'shared_messages.dart';
import 'time_converters.dart';
import 'types.dart';
import 'v2/query.dart';

abstract class ServerMessage extends BaseMessage {}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/text_codec.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:convert';
import 'dart:typed_data';

import 'connection.dart' show PostgreSQLException;
import 'exceptions.dart';
import 'types.dart';

class PostgresTextEncoder extends Converter<Object, String> {
Expand Down
16 changes: 8 additions & 8 deletions lib/src/connection.dart → lib/src/v2/connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import 'dart:typed_data';

import 'package:buffer/buffer.dart';
import 'package:meta/meta.dart';
import 'auth/auth.dart';
import '../auth/auth.dart';

import '../client_messages.dart';
import '../exceptions.dart';
import '../message_window.dart';
import '../replication.dart';
import '../server_messages.dart';
import '../types.dart' show PgSeverity;

import 'client_messages.dart';
import 'execution_context.dart';
import 'message_window.dart';
import 'query.dart';
import 'query_cache.dart';
import 'query_queue.dart';
import 'replication.dart';
import 'server_messages.dart';
import 'types.dart' show PgSeverity;

part 'connection_fsm.dart';

part 'transaction_proxy.dart';

part 'exceptions.dart';

/// Instances of this class connect to and communicate with a PostgreSQL database.
///
/// The primary type of this library, a connection is responsible for connecting to databases and executing queries.
Expand Down
10 changes: 5 additions & 5 deletions lib/src/connection_fsm.dart → lib/src/v2/connection_fsm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class _PostgreSQLConnectionState {
}

_PostgreSQLConnectionState onErrorResponse(ErrorResponseMessage message) {
final exception = PostgreSQLException._(message.fields);
final exception = PostgreSQLException.fromFields(message.fields);

if (exception.severity == PgSeverity.fatal ||
exception.severity == PgSeverity.panic) {
Expand Down Expand Up @@ -60,7 +60,7 @@ class _PostgreSQLConnectionStateSocketConnected

@override
_PostgreSQLConnectionState onErrorResponse(ErrorResponseMessage message) {
final exception = PostgreSQLException._(message.fields);
final exception = PostgreSQLException.fromFields(message.fields);

completer.completeError(exception);

Expand Down Expand Up @@ -94,7 +94,7 @@ class _PostgreSQLConnectionStateAuthenticating

@override
_PostgreSQLConnectionState onErrorResponse(ErrorResponseMessage message) {
final exception = PostgreSQLException._(message.fields);
final exception = PostgreSQLException.fromFields(message.fields);

completer.completeError(exception);

Expand Down Expand Up @@ -195,7 +195,7 @@ class _PostgreSQLConnectionStateAuthenticated

@override
_PostgreSQLConnectionState onErrorResponse(ErrorResponseMessage message) {
final exception = PostgreSQLException._(message.fields);
final exception = PostgreSQLException.fromFields(message.fields);

completer.completeError(exception);

Expand Down Expand Up @@ -288,7 +288,7 @@ class _PostgreSQLConnectionStateBusy extends _PostgreSQLConnectionState {
// If we get an error here, then we should eat the rest of the messages
// and we are always confirmed to get a _ReadyForQueryMessage to finish up.
// We should only report the error once that is done.
final exception = PostgreSQLException._(message.fields);
final exception = PostgreSQLException.fromFields(message.fields);
returningException ??= exception;

if (exception.severity == PgSeverity.fatal ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'dart:async';

import '../types.dart';

import 'connection.dart';
import 'query.dart';
import 'substituter.dart';

import 'types.dart';

abstract class PostgreSQLExecutionContext {
/// Returns this context queue size
int get queueSize;
Expand Down
9 changes: 5 additions & 4 deletions lib/src/query.dart → lib/src/v2/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import 'dart:typed_data';

import 'package:buffer/buffer.dart';

import 'binary_codec.dart';
import 'client_messages.dart';
import '../binary_codec.dart';
import '../client_messages.dart';
import '../exceptions.dart';
import '../text_codec.dart';
import '../types.dart';
import 'connection.dart';
import 'execution_context.dart';
import 'substituter.dart';
import 'text_codec.dart';
import 'types.dart';

class Query<T> {
Query(
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions lib/src/query_queue.dart → lib/src/v2/query_queue.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'dart:async';
import 'dart:collection';

import '../postgres.dart';

import '../exceptions.dart';
import 'query.dart';

class QueryQueue extends ListBase<Query<dynamic>>
Expand Down
4 changes: 2 additions & 2 deletions lib/src/substituter.dart → lib/src/v2/substituter.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../text_codec.dart';
import '../types.dart';
import 'query.dart';
import 'text_codec.dart';
import 'types.dart';

class PostgreSQLFormat {
static final int _atSignCodeUnit = '@'.codeUnitAt(0);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import 'dart:io';

import 'package:postgres/postgres_v3_experimental.dart';
import 'package:postgres/src/client_messages.dart';
import 'package:postgres/src/connection.dart';
import 'package:postgres/src/execution_context.dart';
import 'package:postgres/src/exceptions.dart';
import 'package:postgres/src/replication.dart';
import 'package:postgres/src/server_messages.dart';
import 'package:postgres/src/v2/connection.dart';
import 'package:postgres/src/v2/execution_context.dart';

mixin _DelegatingContext implements PostgreSQLExecutionContext {
PgSession? get _session;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/v3/connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import 'package:stream_channel/stream_channel.dart';

import '../auth/auth.dart';
import '../binary_codec.dart';
import '../connection.dart' show PostgreSQLException;
import '../query.dart';
import '../exceptions.dart';
import '../replication.dart';
import '../text_codec.dart';
import '../v2/query.dart';
import 'protocol.dart';
import 'query_description.dart';

Expand Down
4 changes: 2 additions & 2 deletions test/docker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import 'package:meta/meta.dart';
import 'package:path/path.dart' as p;
import 'package:postgres/messages.dart';
import 'package:postgres/postgres_v3_experimental.dart';
import 'package:postgres/src/connection.dart';
import 'package:postgres/src/replication.dart';
import 'package:postgres/src/v2_v3_delegate.dart';
import 'package:postgres/src/v2/connection.dart';
import 'package:postgres/src/v2/v2_v3_delegate.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:test/test.dart';

Expand Down
2 changes: 1 addition & 1 deletion test/interpolation_test.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:convert';

import 'package:postgres/postgres.dart';
import 'package:postgres/src/query.dart';
import 'package:postgres/src/v2/query.dart';
import 'package:test/test.dart';

void main() {
Expand Down
2 changes: 1 addition & 1 deletion test/query_reuse_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';
import 'dart:mirrors';

import 'package:postgres/postgres.dart';
import 'package:postgres/src/query_cache.dart';
import 'package:postgres/src/v2/query_cache.dart';
import 'package:test/test.dart';

import 'docker.dart';
Expand Down
2 changes: 1 addition & 1 deletion test/v3_close_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:postgres/postgres.dart' show PostgreSQLException;
import 'package:postgres/postgres.dart';
import 'package:postgres/postgres_v3_experimental.dart';
import 'package:test/test.dart';

Expand Down
2 changes: 1 addition & 1 deletion test/v3_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';

import 'package:async/async.dart';
import 'package:postgres/messages.dart';
import 'package:postgres/postgres.dart' show PostgreSQLException;
import 'package:postgres/postgres.dart';
import 'package:postgres/postgres_v3_experimental.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:test/test.dart';
Expand Down

0 comments on commit b174a90

Please sign in to comment.