1- @file:Suppress(" NOTHING_TO_INLINE" )
1+ @file:Suppress(" NOTHING_TO_INLINE" , " SpellCheckingInspection " )
22
33package dev.olog.contentresolversql
44
@@ -50,6 +50,7 @@ internal val keywords = setOf(
5050 " offset"
5151)
5252
53+ @Suppress(" unused" )
5354class Query (
5455 val uri : Uri ,
5556 val projection : Array <String >? ,
@@ -93,6 +94,7 @@ fun ContentResolver.querySql(
9394 }
9495}
9596
97+ @Suppress(" unused" )
9698fun ContentResolver.querySql2 (
9799 query : String ,
98100 selectionArgs : Array <String >? = null
@@ -168,10 +170,10 @@ internal inline fun makeProjection(query: String, indexOfKeywords: List<Pair<Str
168170internal inline fun makeUri (query : String , indexOfKeywords : List <Pair <String , Int >>): Uri {
169171 val indexOfFrom = indexOfKeywords.first { it.first == " from" }.second
170172 val keywordAfterFrom = indexOfKeywords.find { it.second > indexOfFrom }
171- if (keywordAfterFrom == null ) {
172- return Uri .parse(query.substring(indexOfFrom + 4 ).trim())
173+ return if (keywordAfterFrom == null ) {
174+ Uri .parse(query.substring(indexOfFrom + 4 ).trim())
173175 } else {
174- return Uri .parse(query.substring(indexOfFrom + 4 , keywordAfterFrom.second).trim())
176+ Uri .parse(query.substring(indexOfFrom + 4 , keywordAfterFrom.second).trim())
175177 }
176178}
177179
@@ -189,10 +191,6 @@ internal fun makeSelection(query: String, keywordsIndex: List<Pair<String, Int>>
189191 nextKeyword.second // before order by
190192 ).trim()
191193 }
192- if (nextKeyword.second == - 1 ) {
193- // where clause only
194-
195- }
196194 // next keyword is group by
197195 val groupByKeyword = nextKeyword
198196 val whereCondition = query.substring(whereClauseKeyword.second + 5 , groupByKeyword.second).trim()
@@ -228,8 +226,7 @@ internal fun makeSelection(query: String, keywordsIndex: List<Pair<String, Int>>
228226 append(" ) GROUP BY " )
229227 append(groupBy.joinToString())
230228 append(" HAVING (" )
231- val a = havingConditions.split(" AND" , ignoreCase = true ).map { it.trim() }.joinToString(separator = " AND " )
232- append(havingConditions.split(" AND" , ignoreCase = true ).map { it.trim() }.joinToString(separator = " AND " ))
229+ append(havingConditions.split(" AND" , ignoreCase = true ).joinToString(separator = " AND " ) { it.trim() })
233230 }.trim()
234231}
235232
0 commit comments