tomyeh / postgresql

Dart Postgresql database library.
https://quire.io
BSD 2-Clause "Simplified" License
15 stars 7 forks source link

FormatException from the uri #7

Closed beautybird closed 4 years ago

beautybird commented 4 years ago

Hello, I'm getting a FormatException , this is the uri :

      var url = 'postgres://admin:SomePass!#4@10.0.2.2:5432/the_database';

The intelliJ AVD host address is 10.0.2.2 ;

changing the 'SomePass...' to 'somePass..' gave same exception

what could be the reason and solution ?

I/flutter ( 4076): connectionPool is inital I/flutter ( 4076): pooledConnectionsCount is : 0 E/flutter ( 4076): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: FormatException: Invalid port (at character 18) postgres://admin:SomePass!#4@10.0.2.2:5432/the_database E/flutter ( 4076): ^ E/flutter ( 4076): E/flutter ( 4076): #0 new _Uri.notSimple. (dart:core/uri.dart:1484:11) E/flutter ( 4076): #1 int._throwFormatException (dart:core-patch/integers_patch.dart:126:40) E/flutter ( 4076): #2 int._parseRadix (dart:core-patch/integers_patch.dart:144:16) E/flutter ( 4076): #3 int._parse (dart:core-patch/integers_patch.dart:102:12) E/flutter ( 4076): #4 int.parse (dart:core-patch/integers_patch.dart:65:12) E/flutter ( 4076): #5 new _Uri.notSimple (dart:core/uri.dart:1483:20) E/flutter ( 4076): #6 Uri.parse (dart:core/uri.dart:1024:17) E/flutter ( 4076): #7 new SettingsImpl.fromUri (package:postgresql2/src/postgresql_impl/settings.dart:30:17) E/flutter ( 4076): #8 ConnectionImpl.connect (package:postgresql2/src/postgresql_impl/connection.dart:76:24) E/flutter (

tomyeh commented 4 years ago

I think # is not considered as valid by Uri.parse. You can validate it by calling Uri.parse directly.

beautybird commented 4 years ago

@tomyeh ... 1- For sure 2 characters gives this exception , the '#' and '@' , avoid them. 2- using parsing in this form :

            String.fromEnvironment(String name, {String defaultValue}) 

default value is the password that has the characters ...haven't test with '#' or '@' ...

beautybird commented 4 years ago

CORRECTION...actually the default value is not just the password....rather than the entire uri which part of it the password that has the characters.