| Summary: | Unable to use empty string in smart playlist's match condition | ||
|---|---|---|---|
| Product: | [Applications] amarok | Reporter: | shattered |
| Component: | Playlists/Saved Playlists | Assignee: | Amarok Bugs <amarok-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | 1.4.4 | ||
| Target Milestone: | --- | ||
| Platform: | NetBSD pkgsrc | ||
| OS: | NetBSD | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | smart playlist definition | ||
|
Description
shattered
2006-12-30 14:40:50 UTC
Created attachment 19070 [details]
smart playlist definition
SVN commit 618171 by aoliveira:
filtering for empty string wouldn't work on smart playlists
BUG: 139394
M +27 -30 collectiondb.cpp
--- trunk/extragear/multimedia/amarok/src/collectiondb.cpp #618170:618171
@@ -6999,43 +6999,40 @@
void
QueryBuilder::addFilter( int tables, Q_INT64 value, const QString& filter, int mode, bool exact )
{
- if ( !filter.isEmpty() )
- {
- //true for INTEGER fields (see comment of coalesceField(int, Q_INT64)
- bool useCoalesce = coalesceField( tables, value );
- m_where += ANDslashOR() + " ( ";
+ //true for INTEGER fields (see comment of coalesceField(int, Q_INT64)
+ bool useCoalesce = coalesceField( tables, value );
+ m_where += ANDslashOR() + " ( ";
- QString m, s;
- if (mode == modeLess || mode == modeGreater)
- {
- QString escapedFilter;
+ QString m, s;
+ if (mode == modeLess || mode == modeGreater)
+ {
+ QString escapedFilter;
+ if (useCoalesce && DbConnection::sqlite == CollectionDB::instance()->getDbConnectionType())
+ escapedFilter = CollectionDB::instance()->escapeString( filter );
+ else
+ escapedFilter = "'" + CollectionDB::instance()->escapeString( filter ) + "' ";
+ s = ( mode == modeLess ? "< " : "> " ) + escapedFilter;
+ }
+ else
+ {
+ if (exact)
if (useCoalesce && DbConnection::sqlite == CollectionDB::instance()->getDbConnectionType())
- escapedFilter = CollectionDB::instance()->escapeString( filter );
+ s = " = " +CollectionDB::instance()->escapeString( filter ) + ' ';
else
- escapedFilter = "'" + CollectionDB::instance()->escapeString( filter ) + "' ";
- s = ( mode == modeLess ? "< " : "> " ) + escapedFilter;
- }
+ s = " = '" + CollectionDB::instance()->escapeString( filter ) + "' ";
else
- {
- if (exact)
- if (useCoalesce && DbConnection::sqlite == CollectionDB::instance()->getDbConnectionType())
- s = " = " +CollectionDB::instance()->escapeString( filter ) + ' ';
- else
- s = " = '" + CollectionDB::instance()->escapeString( filter ) + "' ";
- else
- s = CollectionDB::likeCondition( filter, mode != modeBeginMatch, mode != modeEndMatch );
- }
+ s = CollectionDB::likeCondition( filter, mode != modeBeginMatch, mode != modeEndMatch );
+ }
- if( coalesceField( tables, value ) )
- m_where += QString( "COALESCE(%1.%2,0) " ).arg( tableName( tables ) ).arg( valueName( value ) ) + s;
- else
- m_where += QString( "%1.%2 " ).arg( tableName( tables ) ).arg( valueName( value ) ) + s;
+ if( coalesceField( tables, value ) )
+ m_where += QString( "COALESCE(%1.%2,0) " ).arg( tableName( tables ) ).arg( valueName( value ) ) + s;
+ else
+ m_where += QString( "%1.%2 " ).arg( tableName( tables ) ).arg( valueName( value ) ) + s;
- if ( !exact && (value & valName) && mode == modeNormal && i18n( "Unknown").contains( filter, false ) )
- m_where += QString( "OR %1.%2 = '' " ).arg( tableName( tables ) ).arg( valueName( value ) );
+ if ( !exact && (value & valName) && mode == modeNormal && i18n( "Unknown").contains( filter, false ) )
+ m_where += QString( "OR %1.%2 = '' " ).arg( tableName( tables ) ).arg( valueName( value ) );
- m_where += " ) ";
- }
+ m_where += " ) ";
m_linkTables |= tables;
}
SVN commit 618193 by mkossick:
filtering for empty strings works for "is not" too
CCBUG: 139394
M +17 -20 collectiondb.cpp
--- trunk/extragear/multimedia/amarok/src/collectiondb.cpp #618192:618193
@@ -7141,31 +7141,28 @@
void
QueryBuilder::excludeFilter( int tables, Q_INT64 value, const QString& filter, int mode, bool exact )
{
- if ( !filter.isEmpty() )
- {
- m_where += ANDslashOR() + " ( ";
+ m_where += ANDslashOR() + " ( ";
- QString m, s;
- if (mode == modeLess || mode == modeGreater)
- s = ( mode == modeLess ? ">= '" : "<= '" ) + CollectionDB::instance()->escapeString( filter ) + "' ";
+ QString m, s;
+ if (mode == modeLess || mode == modeGreater)
+ s = ( mode == modeLess ? ">= '" : "<= '" ) + CollectionDB::instance()->escapeString( filter ) + "' ";
+ else
+ {
+ if (exact)
+ s = " <> '" + CollectionDB::instance()->escapeString( filter ) + "' ";
else
- {
- if (exact)
- s = " <> '" + CollectionDB::instance()->escapeString( filter ) + "' ";
- else
- s = "NOT " + CollectionDB::instance()->likeCondition( filter, mode != modeBeginMatch, mode != modeEndMatch ) + ' ';
- }
+ s = "NOT " + CollectionDB::instance()->likeCondition( filter, mode != modeBeginMatch, mode != modeEndMatch ) + ' ';
+ }
- if( coalesceField( tables, value ) )
- m_where += QString( "COALESCE(%1.%2,0) " ).arg( tableName( tables ) ).arg( valueName( value ) ) + s;
- else
- m_where += QString( "%1.%2 " ).arg( tableName( tables ) ).arg( valueName( value ) ) + s;
+ if( coalesceField( tables, value ) )
+ m_where += QString( "COALESCE(%1.%2,0) " ).arg( tableName( tables ) ).arg( valueName( value ) ) + s;
+ else
+ m_where += QString( "%1.%2 " ).arg( tableName( tables ) ).arg( valueName( value ) ) + s;
- if ( !exact && (value & valName) && mode == modeNormal && i18n( "Unknown").contains( filter, false ) )
- m_where += QString( "AND %1.%2 <> '' " ).arg( tableName( tables ) ).arg( valueName( value ) );
+ if ( !exact && (value & valName) && mode == modeNormal && i18n( "Unknown").contains( filter, false ) )
+ m_where += QString( "AND %1.%2 <> '' " ).arg( tableName( tables ) ).arg( valueName( value ) );
- m_where += " ) ";
- }
+ m_where += " ) ";
m_linkTables |= tables;
}
|