Skip to content

Commit

Permalink
fix bug on format Schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaque Neves committed Apr 24, 2024
1 parent e0b637f commit 0e2f966
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .pubignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ doc/api/
main.exe
teste_concorrencia.dart
teste_utils.dart
teste_insert_get_id.dart
teste_insert_get_id.dart

example/bin/teste_insert_get_id.dart
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,8 @@ final manager = Manager();

- fix bugs in onOpen callback to configure connection settings
- improvements to README
- implemented connection pool for 'postgres' (v2) driver_implementation
- implemented connection pool for 'postgres' (v2) driver_implementation

## 3.2.1

- fix bug on format Schema
19 changes: 14 additions & 5 deletions lib/src/connectors/postgres_connector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class PostgresConnector extends Connector implements ConnectorInterface {
}

if (config['schema'] != null) {
dsn += ";schema=${config['schema']}";
dsn += ";schema=${formatSchema(config['schema'])}";
}

if (config['timezone'] != null) {
dsn += ";timezone=${config['timezone']}";
}
Expand All @@ -132,11 +132,20 @@ class PostgresConnector extends Connector implements ConnectorInterface {
/// @return string
///
String formatSchema(dynamic schema) {
if (Utils.is_array(schema)) {
return '"' + Utils.implode('", "', schema) + '"';
String result = '';
if (schema is List<String>) {
result = schema.map((e) => '"$e"').join(',');
} else if (schema is String) {
if (schema.contains(',')) {
final parts = schema.split(',');
result = parts.map((e) => '"$e"').join(',');
} else {
result = '"$schema"';
}
} else {
return '"' + schema + '"';
throw Exception('schema is not String or List<String>');
}
return result;
}

///
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: eloquent
version: 3.2.0
version: 3.2.1
description: eloquent query builder port from PHP Laravel
homepage: https://github.com/insinfo/eloquent_dart
#publish_to: none
Expand Down

0 comments on commit 0e2f966

Please sign in to comment.