@@ -17,7 +17,7 @@ class PostgresV3PDO extends PDOInterface {
17
17
int port = 5432 ;
18
18
String driver = 'pgsql' ;
19
19
String host = 'localhost' ;
20
- dynamic attributes;
20
+ Map < dynamic , dynamic > ? attributes;
21
21
22
22
/// Creates a PDO instance representing a connection to a database
23
23
/// Example
@@ -56,6 +56,8 @@ class PostgresV3PDO extends PDOInterface {
56
56
Future <PostgresV3PDO > connect () async {
57
57
final dsnParser = DSNParser (dsn, DsnType .pdoPostgreSql);
58
58
59
+ // dsnParser.sslmode?.toString() == 'require'
60
+
59
61
connection = await Connection .open (
60
62
Endpoint (
61
63
host: dsnParser.host,
@@ -66,15 +68,18 @@ class PostgresV3PDO extends PDOInterface {
66
68
),
67
69
settings: ConnectionSettings (
68
70
encoding: _getEncoding (dsnParser.charset ?? 'utf8' ),
69
- sslMode: SslMode .disable,
71
+ sslMode: dsnParser.sslmode? .toString () == 'require'
72
+ ? SslMode .require
73
+ : SslMode .disable,
70
74
));
71
75
72
76
await connection
73
77
.execute ('''SET client_encoding = '${dsnParser .charset }';''' );
74
78
return this ;
75
79
}
76
80
77
- Future <T > runInTransaction <T >(Future <T > operation (PostgresV3PDOTransaction ctx),
81
+ Future <T > runInTransaction <T >(
82
+ Future <T > operation (PostgresV3PDOTransaction ctx),
78
83
[int ? timeoutInSeconds]) async {
79
84
if (timeoutInSeconds == null ) {
80
85
timeoutInSeconds = defaultTimeoutInSeconds;
@@ -85,7 +90,7 @@ class PostgresV3PDO extends PDOInterface {
85
90
return operation (pdoCtx);
86
91
});
87
92
88
- return res ;
93
+ return res;
89
94
}
90
95
91
96
/// Executa uma instrução SQL e retornar o número de linhas afetadas
@@ -116,16 +121,17 @@ class PostgresV3PDO extends PDOInterface {
116
121
final rows = rs.map ((row) => row.toColumnMap ()).toList ();
117
122
final maps = < Map <String , dynamic >> [];
118
123
if (rows.isNotEmpty) {
119
- for (final row in rows) {
124
+ for (final row in rows) {
120
125
final map = < String , dynamic > {};
121
126
for (final col in row.entries) {
122
127
final key = col.key;
123
- final value = col.value is UndecodedBytes ? col.value.asString : col.value;
128
+ final value =
129
+ col.value is UndecodedBytes ? col.value.asString : col.value;
124
130
map.addAll ({key: value});
125
131
}
126
- maps.add (map);
132
+ maps.add (map);
127
133
}
128
- }
134
+ }
129
135
130
136
final pdoResult = PDOResults (maps, rs.affectedRows);
131
137
return pdoResult;
0 commit comments