Commit ca8d46e5 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Check whether the current row itself has a non-empty target

parent f13d96a8
...@@ -72,7 +72,7 @@ interface DnsRuleDao { ...@@ -72,7 +72,7 @@ interface DnsRuleDao {
@Query("SELECT COUNT(*) FROM DnsRule WHERE importedFrom IS NOT NULL") @Query("SELECT COUNT(*) FROM DnsRule WHERE importedFrom IS NOT NULL")
fun getNonUserCount(): Long fun getNonUserCount(): Long
@Query("SELECT CASE WHEN :type=28 THEN IFNULL(ipv6Target, target) ELSE target END FROM DnsRule WHERE host=:host AND (type = :type OR type=255) AND (importedFrom is NULL OR IFNULL((SELECT enabled FROM HostSource h WHERE h.id=importedFrom),0) = 1) AND (importedFrom IS NOT NULL OR :useUserRules=1) AND (SELECT COUNT(*) FROM DnsRule WHERE target='' AND host=:host)=0 LIMIT 1") @Query("SELECT CASE WHEN :type=28 THEN IFNULL(ipv6Target, target) ELSE target END FROM DnsRule WHERE host=:host AND target != '' AND (type = :type OR type=255) AND (importedFrom is NULL OR IFNULL((SELECT enabled FROM HostSource h WHERE h.id=importedFrom),0) = 1) AND (importedFrom IS NOT NULL OR :useUserRules=1) AND (SELECT COUNT(*) FROM DnsRule WHERE target='' AND host=:host)=0 LIMIT 1")
fun findRuleTarget(host: String, type: Record.TYPE, useUserRules:Boolean): String? fun findRuleTarget(host: String, type: Record.TYPE, useUserRules:Boolean): String?
@Query("DELETE FROM DnsRule WHERE importedFrom=:sourceId") @Query("DELETE FROM DnsRule WHERE importedFrom=:sourceId")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment