-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2ea26d
commit d0d969a
Showing
4 changed files
with
40 additions
and
5 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
1 change: 1 addition & 0 deletions
1
dialect/bin/main/META-INF/services/app.cash.sqldelight.dialect.api.SqlDelightDialect
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 @@ | ||
com.powersync.sqlite.PowerSyncDialect |
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,25 @@ | ||
package com.powersync.sqlite | ||
|
||
import app.cash.sqldelight.dialect.api.IntermediateType | ||
import app.cash.sqldelight.dialect.api.PrimitiveType | ||
import app.cash.sqldelight.dialect.api.SqlDelightDialect | ||
import app.cash.sqldelight.dialect.api.TypeResolver | ||
import app.cash.sqldelight.dialects.sqlite_3_35.SqliteTypeResolver | ||
import app.cash.sqldelight.dialects.sqlite_3_38.SqliteDialect as Sqlite338Dialect | ||
import com.alecstrong.sql.psi.core.psi.SqlFunctionExpr | ||
|
||
class PowerSyncDialect : SqlDelightDialect by Sqlite338Dialect() { | ||
override fun typeResolver(parentResolver: TypeResolver) = PowerSyncTypeResolver(parentResolver) | ||
} | ||
|
||
class PowerSyncTypeResolver(private val parentResolver: TypeResolver) : | ||
TypeResolver by SqliteTypeResolver(parentResolver) { | ||
override fun functionType(functionExpr: SqlFunctionExpr): IntermediateType? { | ||
when (functionExpr.functionName.text) { | ||
"sqlite_version", "powersync_rs_version", "powersync_replace_schema" -> return IntermediateType( | ||
PrimitiveType.TEXT | ||
) | ||
} | ||
return parentResolver.functionType(functionExpr) | ||
} | ||
} |