extragear/multimedia/amarok/src/collection/sqlcollection
Daniel Caleb Jones
danielcjones at gmail.com
Sun Dec 21 00:47:45 CET 2008
SVN commit 899501 by djones:
Treat null entries as 0 when doing sql queries.
This seemed a reasonable and simple fix, but maybe I'm neglecting something.
Will this cause any problems?
BUG: 176976
CCMAIL: amarok-devel at kde.org
M +23 -2 SqlQueryMaker.cpp
--- trunk/extragear/multimedia/amarok/src/collection/sqlcollection/SqlQueryMaker.cpp #899500:899501
@@ -417,7 +417,18 @@
comparison = "<";
break;
}
- d->queryFilter += QString( " %1 %2 %3 %4 " ).arg( andOr(), nameForValue( value ), comparison, QString::number( filter ) );
+
+ if( (filter == 0 && compare == QueryMaker::Equals)
+ || (filter < 0 && compare == QueryMaker::GreaterThan)
+ || (filter > 0 && compare == QueryMaker::LessThan) )
+ {
+ d->queryFilter += QString( " %1 (%2 %3 %4 or %2 is null)" ).arg( andOr(), nameForValue( value ), comparison, QString::number( filter ) );
+ }
+ else
+ {
+ d->queryFilter += QString( " %1 %2 %3 %4 " ).arg( andOr(), nameForValue( value ), comparison, QString::number( filter ) );
+ }
+
return this;
}
@@ -437,7 +448,17 @@
comparison = ">=";
break;
}
- d->queryFilter += QString( " %1 %2 %3 %4 " ).arg( andOr(), nameForValue( value ), comparison, QString::number( filter ) );
+
+ if( (filter == 0 && compare == QueryMaker::Equals)
+ || (filter >= 0 && compare == QueryMaker::GreaterThan)
+ || (filter <= 0 && compare == QueryMaker::LessThan) )
+ {
+ d->queryFilter += QString( " %1 (%2 %3 %4 and %2 is not null)" ).arg( andOr(), nameForValue( value ), comparison, QString::number( filter ) );
+ }
+ else
+ {
+ d->queryFilter += QString( " %1 %2 %3 %4 " ).arg( andOr(), nameForValue( value ), comparison, QString::number( filter ) );
+ }
return this;
}
More information about the Amarok-devel
mailing list