branches/stable/extragear/multimedia/amarok/src

Seb Ruiz ruiz at kde.org
Thu Nov 8 07:40:56 UTC 2007


SVN commit 734136 by seb:

New method, boolFromSql( const QString & ). Use this when checking for db return values. This is because psql returns 't' or 'f' but we insert it as 'true' 'false'. Too complicated to simply change the inserted value.
http://mail.kde.org/pipermail/amarok/2007-November/004560.html
CCMAIL: amarok at kde.org
CCMAIL: pndiku at gmail.com
CCMAIL: dholth at fastmail.fm


 M  +9 -9      collectiondb.cpp  
 M  +3 -2      collectiondb.h  


--- branches/stable/extragear/multimedia/amarok/src/collectiondb.cpp #734135:734136
@@ -2648,10 +2648,10 @@
         pcb.setCopyright   ( *++it );
         pcb.setParentId    ( (*++it).toInt() );
         pcb.setSaveLocation( *++it );
-        pcb.setAutoScan    ( *++it == boolT() ? true : false );
+        pcb.setAutoScan    ( boolFromSql( *++it ) );
         pcb.setFetchType   ( (*++it).toInt() );
-        pcb.setAutoTransfer( *++it == boolT() ? true : false  );
-        pcb.setPurge       ( *++it == boolT() ? true : false  );
+        pcb.setAutoTransfer( boolFromSql( *++it ) );
+        pcb.setPurge       ( boolFromSql( *++it ) );
         pcb.setPurgeCount  ( (*++it).toInt() );
 
         bundles.append( pcb );
@@ -2695,7 +2695,7 @@
             peb.setSize        ( 0 );
         else
             peb.setSize        ( (*it).toInt() );
-        peb.setNew         ( (*++it) == boolT() ? true : false  );
+        peb.setNew         ( boolFromSql( *++it ) );
 
         bundles.append( peb );
     }
@@ -2729,7 +2729,7 @@
             peb.setSize    ( 0 );
         else
             peb.setSize    ( (*it).toInt() );
-        peb.setNew         ( (*++it) == boolT() ? true : false  );
+        peb.setNew         ( boolFromSql( *++it ) );
     }
 
     return peb;
@@ -2784,10 +2784,10 @@
         pcb->setCopyright   ( *++it );
         pcb->setParentId    ( (*++it).toInt() );
         pcb->setSaveLocation( *++it );
-        pcb->setAutoScan    ( *++it == boolT() ? true : false );
+        pcb->setAutoScan    ( boolFromSql( *++it ) );
         pcb->setFetchType   ( (*++it).toInt() );
-        pcb->setAutoTransfer( *++it == boolT() ? true : false  );
-        pcb->setPurge       ( *++it == boolT() ? true : false  );
+        pcb->setAutoTransfer( boolFromSql( *++it ) );
+        pcb->setPurge       ( boolFromSql( *++it ) );
         pcb->setPurgeCount  ( (*++it).toInt() );
     }
 
@@ -2800,7 +2800,7 @@
 {
     QString command = QString( "INSERT INTO podcastfolders ( name, parent, isOpen ) VALUES ('" );
     command += escapeString( name )   + "',";
-    command += QString::number( parent_id ) + ',';
+    command += QString::number( parent_id ) + ",";
     command += isOpen ? boolT() + ");" : boolF() + ");";
 
     insert( command, NULL );
--- branches/stable/extragear/multimedia/amarok/src/collectiondb.h #734135:734136
@@ -251,8 +251,9 @@
                   string.replace( '\'', "''" );
         }
 
-        QString boolT() const { if (getDbConnectionType() == DbConnection::postgresql) return "t"; else return "1"; }
-        QString boolF() const { if (getDbConnectionType() == DbConnection::postgresql) return "f"; else return "0"; }
+        QString boolT() const { if (getDbConnectionType() == DbConnection::postgresql) return "true"; else return "1"; }
+        QString boolF() const { if (getDbConnectionType() == DbConnection::postgresql) return "false"; else return "0"; }
+        inline bool boolFromSql( const QString &b ) { return ( b == boolT() || b == "t" ); }
         //textColumnType should be used for normal strings, which need to be compared
         //either case-sensitively or -insensitively
         QString textColumnType( int length=255 ) const { if ( getDbConnectionType() == DbConnection::postgresql ) return "TEXT"; else return QString("VARCHAR(%1)").arg(length); }



More information about the Amarok mailing list