Skip to content

Commit 0e2f966

Browse files
author
Isaque Neves
committed
fix bug on format Schema
1 parent e0b637f commit 0e2f966

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

.pubignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ doc/api/
2929
main.exe
3030
teste_concorrencia.dart
3131
teste_utils.dart
32-
teste_insert_get_id.dart
32+
teste_insert_get_id.dart
33+
34+
example/bin/teste_insert_get_id.dart

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,8 @@ final manager = Manager();
8686

8787
- fix bugs in onOpen callback to configure connection settings
8888
- improvements to README
89-
- implemented connection pool for 'postgres' (v2) driver_implementation
89+
- implemented connection pool for 'postgres' (v2) driver_implementation
90+
91+
## 3.2.1
92+
93+
- fix bug on format Schema

lib/src/connectors/postgres_connector.dart

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ class PostgresConnector extends Connector implements ConnectorInterface {
115115
}
116116

117117
if (config['schema'] != null) {
118-
dsn += ";schema=${config['schema']}";
118+
dsn += ";schema=${formatSchema(config['schema'])}";
119119
}
120-
120+
121121
if (config['timezone'] != null) {
122122
dsn += ";timezone=${config['timezone']}";
123123
}
@@ -132,11 +132,20 @@ class PostgresConnector extends Connector implements ConnectorInterface {
132132
/// @return string
133133
///
134134
String formatSchema(dynamic schema) {
135-
if (Utils.is_array(schema)) {
136-
return '"' + Utils.implode('", "', schema) + '"';
135+
String result = '';
136+
if (schema is List<String>) {
137+
result = schema.map((e) => '"$e"').join(',');
138+
} else if (schema is String) {
139+
if (schema.contains(',')) {
140+
final parts = schema.split(',');
141+
result = parts.map((e) => '"$e"').join(',');
142+
} else {
143+
result = '"$schema"';
144+
}
137145
} else {
138-
return '"' + schema + '"';
146+
throw Exception('schema is not String or List<String>');
139147
}
148+
return result;
140149
}
141150

142151
///

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: eloquent
2-
version: 3.2.0
2+
version: 3.2.1
33
description: eloquent query builder port from PHP Laravel
44
homepage: https://github.com/insinfo/eloquent_dart
55
#publish_to: none

0 commit comments

Comments
 (0)