-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into renovate/androidx.test-runner-1.x
- Loading branch information
Showing
14 changed files
with
347 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...qlite-3-25/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/SqliteTypeResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package app.cash.sqldelight.dialects.sqlite_3_25 | ||
|
||
import app.cash.sqldelight.dialect.api.IntermediateType | ||
import app.cash.sqldelight.dialect.api.PrimitiveType.INTEGER | ||
import app.cash.sqldelight.dialect.api.PrimitiveType.REAL | ||
import app.cash.sqldelight.dialect.api.PrimitiveType.TEXT | ||
import app.cash.sqldelight.dialect.api.TypeResolver | ||
import app.cash.sqldelight.dialect.api.encapsulatingTypePreferringKotlin | ||
import app.cash.sqldelight.dialects.sqlite_3_24.SqliteTypeResolver as Sqlite324TypeResolver | ||
import app.cash.sqldelight.dialects.sqlite_3_25.grammar.psi.SqliteExtensionExpr | ||
import com.alecstrong.sql.psi.core.psi.SqlExpr | ||
import com.alecstrong.sql.psi.core.psi.SqlFunctionExpr | ||
|
||
open class SqliteTypeResolver(private val parentResolver: TypeResolver) : Sqlite324TypeResolver(parentResolver) { | ||
|
||
override fun resolvedType(expr: SqlExpr): IntermediateType = when (expr) { | ||
is SqliteExtensionExpr -> { | ||
functionType(expr.windowFunctionExpr)!! // currently this is the only sqlite extension expr in 3_25 | ||
} | ||
else -> super.resolvedType(expr) | ||
} | ||
|
||
override fun functionType(functionExpr: SqlFunctionExpr): IntermediateType? { | ||
return functionExpr.sqliteFunctionType() ?: parentResolver.functionType(functionExpr) | ||
} | ||
|
||
private fun SqlFunctionExpr.sqliteFunctionType() = when (functionName.text.lowercase()) { | ||
"dense_rank", "ntile", "rank", "row_number" -> IntermediateType(INTEGER) | ||
"cume_dist", "percent_rank" -> IntermediateType(REAL) | ||
"lag", "lead", "first_value", "last_value", "nth_value", "group_concat" -> encapsulatingTypePreferringKotlin(exprList, INTEGER, REAL, TEXT).asNullable() | ||
else -> null | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
.../main/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/grammar/mixins/ResultColumnMixin.kt
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...tlin/app/cash/sqldelight/dialects/sqlite_3_25/grammar/mixins/SqliteWindowFunctionMixin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package app.cash.sqldelight.dialects.sqlite_3_25.grammar.mixins | ||
|
||
import app.cash.sqldelight.dialects.sqlite_3_25.grammar.psi.SqliteWindowFunctionExpr | ||
import com.alecstrong.sql.psi.core.psi.SqlCompositeElementImpl | ||
import com.alecstrong.sql.psi.core.psi.SqlExpr | ||
import com.alecstrong.sql.psi.core.psi.SqlFunctionExpr | ||
import com.alecstrong.sql.psi.core.psi.SqlFunctionName | ||
import com.intellij.lang.ASTNode | ||
|
||
internal abstract class SqliteWindowFunctionMixin( | ||
node: ASTNode, | ||
) : SqlCompositeElementImpl(node), | ||
SqliteWindowFunctionExpr, | ||
SqlFunctionExpr { | ||
override fun getExprList(): List<SqlExpr> { | ||
return children.filterIsInstance<SqlFunctionExpr>() | ||
} | ||
|
||
override fun getFunctionName(): SqlFunctionName { | ||
return exprList.first().children.filterIsInstance<SqlFunctionName>().single() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
dialects/sqlite-3-25/src/testFixtures/resources/fixtures_sqlite_3_25/window_functions/t3.s
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CREATE TABLE numbers( | ||
value INTEGER NOT NULL | ||
); | ||
|
||
SELECT value | ||
FROM ( | ||
SELECT | ||
value, | ||
CASE | ||
WHEN ((row_number() OVER(ORDER BY value ASC) - 1) % :limit) = 0 THEN 1 | ||
WHEN value = :anchor THEN 1 | ||
ELSE 0 | ||
END page_boundary | ||
FROM numbers | ||
ORDER BY value ASC | ||
) | ||
WHERE page_boundary = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.