From fc8609723a18349bb63d1f4a2238fc2fb1afcaee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Nieto?= <jose.carlos@menteslibres.net>
Date: Fri, 2 May 2014 19:32:39 -0500
Subject: [PATCH] Cosmetics.

---
 db.go                    |  6 ++++++
 mongo/collection.go      |  2 +-
 mongo/result.go          |  2 +-
 mysql/collection.go      |  2 +-
 mysql/database.go        |  2 +-
 mysql/result.go          | 22 ++++++++--------------
 postgresql/collection.go |  2 +-
 postgresql/database.go   |  2 +-
 postgresql/result.go     |  2 +-
 sqlite/collection.go     |  2 +-
 sqlite/database.go       |  2 +-
 sqlite/database_test.go  |  2 +-
 sqlite/result.go         |  2 +-
 util/main.go             |  2 +-
 util/sqlutil/main.go     |  2 +-
 15 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/db.go b/db.go
index fc7ee6f0..93703d67 100644
--- a/db.go
+++ b/db.go
@@ -113,6 +113,12 @@ type Database interface {
 	// Attempts to stablish a connection with the database server.
 	Open() error
 
+	// Clones the current database session.
+	// Clone() (Database, error)
+
+	// Returns error if the database server cannot be reached.
+	// Ping() error
+
 	// Closes the currently active connection to the database.
 	Close() error
 
diff --git a/mongo/collection.go b/mongo/collection.go
index f84ebcfd..992ce4b9 100644
--- a/mongo/collection.go
+++ b/mongo/collection.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/mongo/result.go b/mongo/result.go
index abc6487c..ce2493d9 100644
--- a/mongo/result.go
+++ b/mongo/result.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/mysql/collection.go b/mysql/collection.go
index 785a8896..cf4baea2 100644
--- a/mysql/collection.go
+++ b/mysql/collection.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/mysql/database.go b/mysql/database.go
index 65a0ada6..77eeef41 100644
--- a/mysql/database.go
+++ b/mysql/database.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/mysql/result.go b/mysql/result.go
index 518b7923..b12fbbff 100644
--- a/mysql/result.go
+++ b/mysql/result.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
@@ -38,8 +38,7 @@ type counter struct {
 type Result struct {
 	table       *Table
 	queryChunks *sqlutil.QueryChunks
-	// This is the main query cursor. It starts as a nil value.
-	cursor *sql.Rows
+	cursor      *sql.Rows // This query cursor keeps results for Next().
 }
 
 // Executes a SELECT statement that can feed Next(), All() or One().
@@ -116,13 +115,11 @@ func (self *Result) All(dst interface{}) error {
 	}
 
 	// Current cursor.
-	err = self.setCursor()
-
-	if err != nil {
+	if err = self.setCursor(); err != nil {
 		return err
 	}
 
-	defer self.Close()
+	defer self.Close() // Make sure the result set closes.
 
 	// Fetching all results within the cursor.
 	err = self.table.T.FetchRows(dst, self.cursor)
@@ -130,7 +127,7 @@ func (self *Result) All(dst interface{}) error {
 	return err
 }
 
-// Fetches only one result from the resultset.
+// Fetches only one result from the result set.
 func (self *Result) One(dst interface{}) error {
 	var err error
 
@@ -151,16 +148,13 @@ func (self *Result) Next(dst interface{}) error {
 	var err error
 
 	// Current cursor.
-	err = self.setCursor()
-
-	if err != nil {
+	if err = self.setCursor(); err != nil {
 		self.Close()
 	}
 
 	// Fetching the next result from the cursor.
-	err = self.table.T.FetchRow(dst, self.cursor)
-
-	if err != nil {
+	if err = self.table.T.FetchRow(dst, self.cursor); err != nil {
+		// Closing result set on error.
 		self.Close()
 	}
 
diff --git a/postgresql/collection.go b/postgresql/collection.go
index 6d9ea81f..e5e42057 100644
--- a/postgresql/collection.go
+++ b/postgresql/collection.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/postgresql/database.go b/postgresql/database.go
index b86a8c48..02577487 100644
--- a/postgresql/database.go
+++ b/postgresql/database.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/postgresql/result.go b/postgresql/result.go
index 3d3913b8..83ddb38d 100644
--- a/postgresql/result.go
+++ b/postgresql/result.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/sqlite/collection.go b/sqlite/collection.go
index 02b26a56..4a633e9f 100644
--- a/sqlite/collection.go
+++ b/sqlite/collection.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/sqlite/database.go b/sqlite/database.go
index b5026b04..24f42c2b 100644
--- a/sqlite/database.go
+++ b/sqlite/database.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/sqlite/database_test.go b/sqlite/database_test.go
index 6baaaafb..b640f832 100644
--- a/sqlite/database_test.go
+++ b/sqlite/database_test.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/sqlite/result.go b/sqlite/result.go
index 883d299b..5354308b 100644
--- a/sqlite/result.go
+++ b/sqlite/result.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/util/main.go b/util/main.go
index 07719452..63ae1ca7 100644
--- a/util/main.go
+++ b/util/main.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
diff --git a/util/sqlutil/main.go b/util/sqlutil/main.go
index 712ebc35..4b5a8047 100644
--- a/util/sqlutil/main.go
+++ b/util/sqlutil/main.go
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2012-2013 José Carlos Nieto, https://menteslibres.net/xiam
+  Copyright (c) 2012-2014 José Carlos Nieto, https://menteslibres.net/xiam
 
   Permission is hereby granted, free of charge, to any person obtaining
   a copy of this software and associated documentation files (the
-- 
GitLab