Cope with sessions which don't exist.
authorTom Hughes <tom@compton.nu>
Tue, 28 Apr 2009 12:08:47 +0000 (12:08 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 28 Apr 2009 12:08:47 +0000 (12:08 +0000)
vendor/plugins/sql_session_store/lib/postgresql_session.rb

index 6004683..53dc04c 100755 (executable)
@@ -46,8 +46,12 @@ class PostgresqlSession
     def find_session(session_id)
       connection = session_connection
       result = connection.query("SELECT id, data FROM sessions WHERE session_id = $1 LIMIT 1", [session_id])
-      my_session = new(session_id, result.getvalue(0, 1))
-      my_session.id = result.getvalue(0, 0)
+      if result.ntuples > 0
+        my_session = new(session_id, result.getvalue(0, 1))
+        my_session.id = result.getvalue(0, 0)
+      else
+        my_session = nil
+      end
       result.clear
       my_session
     end