<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -164,9 +164,7 @@ public final class Connection extends DORubyObject {
                 String jdbcUri;
                 Properties props = driver.getDefaultConnectionProperties();
 
-                if (connectionUri.toString().contains(&quot;@&quot;)) {
-                    // uri.getUserInfo() gave always null, so do it manually
-                    // TODO: See if we can replace with connectionUri.getUserInfo()
+                if (connectionUri.getUserInfo() != null || connectionUri.toString().contains(&quot;@&quot;)) {
                     String userInfo =
                             connectionUri.toString().replaceFirst(&quot;.*://&quot;, &quot;&quot;).replaceFirst(&quot;@.*&quot;, &quot;&quot;);
                     jdbcUri = connectionUri.toString().replaceFirst(userInfo + &quot;@&quot;, &quot;&quot;);</diff>
      <filename>do_jdbc/src/main/java/data_objects/Connection.java</filename>
    </modified>
    <modified>
      <diff>@@ -123,8 +123,9 @@ public abstract class AbstractDriverDefinition implements DriverDefinition {
                 } else {
                     normalizedPath = path;
                 }
-                uri = new URI(this.jdbcScheme, userInfo.toString(), host, port,
-                        normalizedPath, query, fragment);
+                uri = new URI(this.jdbcScheme,
+                        (userInfo.length() &gt; 0 ? userInfo.toString() : null),
+                        host, port, normalizedPath, query, fragment);
             } else {
                 // an embedded / file-based database (e.g. SQLite3, Derby
                 // (embedded mode), HSQLDB - use opaque uri</diff>
      <filename>do_jdbc/src/main/java/data_objects/drivers/AbstractDriverDefinition.java</filename>
    </modified>
    <modified>
      <diff>@@ -79,6 +79,11 @@ public class MySqlDriverDefinition extends AbstractDriverDefinition {
     @Override
     public Properties getDefaultConnectionProperties() {
         Properties props = new Properties();
+
+        // by default we connect with root and a empty password
+        props.put(&quot;user&quot;, &quot;root&quot;);
+        props.put(&quot;password&quot;, &quot;&quot;);
+
         props.put(&quot;useUnicode&quot;, &quot;yes&quot;);
         // removed NO_AUTO_VALUE_ON_ZERO because of MySQL bug http://bugs.mysql.com/bug.php?id=42270
         // added NO_BACKSLASH_ESCAPES so that backslashes should not be escaped as in other databases</diff>
      <filename>do_mysql/ext-java/src/main/java/do_mysql/MySqlDriverDefinition.java</filename>
    </modified>
    <modified>
      <diff>@@ -47,12 +47,17 @@ CONFIG = OpenStruct.new
 CONFIG.scheme   = 'mysql'
 CONFIG.user     = ENV['DO_MYSQL_USER'] || 'root'
 CONFIG.pass     = ENV['DO_MYSQL_PASS'] || ''
+CONFIG.user_info = unless CONFIG.user == 'root' &amp;&amp; CONFIG.pass.empty?
+  &quot;#{CONFIG.user}:#{CONFIG.pass}@&quot;
+else
+  ''
+end
 CONFIG.host     = ENV['DO_MYSQL_HOST'] || 'localhost'
 CONFIG.port     = ENV['DO_MYSQL_PORT'] || '3306'
 CONFIG.database = ENV['DO_MYSQL_DATABASE'] || '/do_test'
 CONFIG.ssl      = SSLHelpers.query(:ca_cert, :client_cert, :client_key)
 
-CONFIG.uri = ENV[&quot;DO_MYSQL_SPEC_URI&quot;] ||&quot;#{CONFIG.scheme}://#{CONFIG.user}:#{CONFIG.pass}@#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}&quot;
+CONFIG.uri = ENV[&quot;DO_MYSQL_SPEC_URI&quot;] ||&quot;#{CONFIG.scheme}://#{CONFIG.user_info}#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}&quot;
 CONFIG.sleep = &quot;SELECT sleep(1)&quot;
 
 module DataObjectsSpecHelpers</diff>
      <filename>do_mysql/spec/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,7 @@ import org.jruby.runtime.builtin.IRubyObject;
 import data_objects.RubyType;
 import data_objects.drivers.AbstractDriverDefinition;
 import data_objects.util.JDBCUtil;
+import java.util.Properties;
 
 public class PostgresDriverDefinition extends AbstractDriverDefinition {
 
@@ -38,6 +39,19 @@ public class PostgresDriverDefinition extends AbstractDriverDefinition {
     }
 
     @Override
+    public Properties getDefaultConnectionProperties() {
+        Properties props = new Properties();
+        // the underlying PostgreSQL JDBC driver, as with libpg, defaults to the
+        // same user as &quot;as the operating system name of the user running the
+        // application&quot;, i.e. System.getProperty(&quot;user.name&quot;).
+        // TODO: Check this is the CORRECT behavior: we override this to use
+        // &quot;postgres&quot; user instead as default. As convention, this is the unix
+        // account that with  PG root/superuser privileges.
+        props.put(&quot;user&quot;, &quot;postgres&quot;);
+        return props;
+    }
+
+    @Override
     public void setPreparedStatementParam(PreparedStatement ps,
             IRubyObject arg, int idx) throws SQLException {
         int jdbcType;</diff>
      <filename>do_postgres/ext-java/src/main/java/do_postgres/PostgresDriverDefinition.java</filename>
    </modified>
    <modified>
      <diff>@@ -43,14 +43,20 @@ Spec::Runner.configure do |config|
 end
 
 CONFIG = OpenStruct.new
-CONFIG.scheme   = 'postgres'
-CONFIG.user     = ENV['DO_POSTGRES_USER'] || 'postgres'
-CONFIG.pass     = ENV['DO_POSTGRES_PASS'] || ''
-CONFIG.host     = ENV['DO_POSTGRES_HOST'] || 'localhost'
-CONFIG.port     = ENV['DO_POSTGRES_PORT'] || '5432'
-CONFIG.database = ENV['DO_POSTGRES_DATABASE'] || '/do_test'
-
-CONFIG.uri = ENV[&quot;DO_POSTGRES_SPEC_URI&quot;] ||&quot;#{CONFIG.scheme}://#{CONFIG.user}:#{CONFIG.pass}@#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}&quot;
+CONFIG.scheme    = 'postgres'
+CONFIG.user      = ENV['DO_POSTGRES_USER'] || 'postgres'
+CONFIG.pass      = ENV['DO_POSTGRES_PASS'] || ''
+CONFIG.user_info = unless CONFIG.user == 'postgres' &amp;&amp; CONFIG.pass.empty?
+  &quot;#{CONFIG.user}:#{CONFIG.pass}@&quot;
+else
+  ''
+end
+CONFIG.host      = ENV['DO_POSTGRES_HOST'] || 'localhost'
+CONFIG.port      = ENV['DO_POSTGRES_PORT'] || '5432'
+CONFIG.database  = ENV['DO_POSTGRES_DATABASE'] || '/do_test'
+
+CONFIG.uri = ENV[&quot;DO_POSTGRES_SPEC_URI&quot;] ||&quot;#{CONFIG.scheme}://#{CONFIG.user_info}#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}&quot;
+puts CONFIG.uri
 CONFIG.sleep = &quot;SELECT pg_sleep(1)&quot;
 
 module DataObjectsSpecHelpers</diff>
      <filename>do_postgres/spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8c10bfe91ee66d7736adc2211ae0ae875f6039b1</id>
    </parent>
  </parents>
  <author>
    <name>Alex Coles</name>
    <email>alex@alexcolesportfolio.com</email>
  </author>
  <url>http://github.com/datamapper/do/commit/ea9109dcb5a7868031fdab18c43d0b288f77914a</url>
  <id>ea9109dcb5a7868031fdab18c43d0b288f77914a</id>
  <committed-date>2009-10-14T04:25:46-07:00</committed-date>
  <authored-date>2009-10-14T02:34:02-07:00</authored-date>
  <message>[do_jdbc][do_mysql][do_postgres] Handle user/password defaults

* Attempt to achieve parity with MRI extensions when dealing with
  default connection users + passwords.
* If no user + password are specified:
  * &quot;root&quot; and &quot;&quot; are assumed for MySQL JDBC-variant driver
  * &quot;postgres&quot; and &quot;&quot; are assumed for PostgreSQL JDBC-variant driver
    (see comments as to whether this is the correct behavior).
* If no username + password is specified for PostgreSQL JDBC-variant
  driver, &quot;postgresql&quot; and &quot;&quot; is assumed.
* Specs updated to not specify user/password unless overriden.
* java.net.URI constructor, used internally by data_objects.Connection,
  should be passed a null userInfo parameter not an empty String.

Signed-off-by: Alex Coles &lt;alex@alexcolesportfolio.com&gt;</message>
  <tree>6c4b162401f590e7d0d82317cca94574c48e68b1</tree>
  <committer>
    <name>Alex Coles</name>
    <email>alex@alexcolesportfolio.com</email>
  </committer>
</commit>
