From 47ce4e4958ba893ee4123022a666776564278619 Mon Sep 17 00:00:00 2001
From: Alexandre Morignot <erdnaxeli@cervoi.se>
Date: Thu, 28 May 2015 23:32:43 +0200
Subject: [PATCH] Fixes #24: !get id doesn't warn the user when repeated, it
 just repeat.

---
 lib/utils/db/get.pm | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/utils/db/get.pm b/lib/utils/db/get.pm
index 40dd8f3..d7bf971 100644
--- a/lib/utils/db/get.pm
+++ b/lib/utils/db/get.pm
@@ -43,6 +43,9 @@ sub get {
         $result = $self->_get_next($query);
     }
 
+    # if id was precised, we (and so the user) know there is no more results
+    $self->_clean($chan) if ($query->id >= 0);
+
     return $result;
 }
 
@@ -66,11 +69,18 @@ sub get_rows {
 sub _get_next {
     my ($self, $query) = @_;
     my $chan = $query->chan;
-    
+
     my $result = $self->_sth->{$chan}->fetch();
     return $result if ($result);
 
     # we come here only if there is no more data to fetch
+    $self->_clean($chan);
+    return undef;
+}
+
+sub _clean
+{
+    my ($self, $chan) = @_;
 
     # we take care of the db
     delete $self->_sth->{$chan};
@@ -78,8 +88,6 @@ sub _get_next {
 
     # we remove the query
     delete $self->_queries->{$chan};
-
-    return undef;
 }
 
 sub _init {
-- 
GitLab