Skip to content

Commit

Permalink
Fix DataSourceFactory query generation issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedawson committed Sep 12, 2022
1 parent 17f357f commit df4a9f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.github.UstadMobile.door'
version '0.0.62a'
version '0.0.62b'

ext.localProperties = new Properties()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1297,10 +1297,11 @@ fun CodeBlock.Builder.beginPrepareAndUseStatementFlow(
daoFunDecl: KSFunctionDeclaration,
daoClassDecl: KSClassDeclaration,
resolver: Resolver,
statementVarName: String = "_stmt"
statementVarName: String = "_stmt",
querySql: String? = daoFunDecl.getAnnotation(Query::class)?.value,
): CodeBlock.Builder {
add("_db.%M(", AbstractDbProcessor.prepareAndUseStatmentMemberName(daoFunDecl.useSuspendedQuery))
addPreparedStatementConfig(daoFunDecl, daoClassDecl, resolver)
addPreparedStatementConfig(daoFunDecl, daoClassDecl, resolver, querySql)
add(") { $statementVarName -> \n")
indent()

Expand Down Expand Up @@ -1400,10 +1401,10 @@ fun CodeBlock.Builder.addResultSetToEntityCode(
fun CodeBlock.Builder.addPreparedStatementConfig(
daoFunDecl: KSFunctionDeclaration,
daoClassDecl: KSClassDeclaration,
resolver: Resolver
resolver: Resolver,
querySql: String? = daoFunDecl.getAnnotation(Query::class)?.value
): CodeBlock.Builder {
val daoFun = daoFunDecl.asMemberOf(daoClassDecl.asType(emptyList()))
val querySql = daoFunDecl.getAnnotation(Query::class)?.value
val querySqlPostgres = daoFunDecl.getAnnotation(PostgresQuery::class)?.value
val queryVars = daoFunDecl.parameters.mapIndexed { index, ksValueParameter ->
ksValueParameter.name!!.asString() to daoFun.parameterTypes[index]!!
Expand Down Expand Up @@ -1491,7 +1492,7 @@ fun CodeBlock.Builder.addJdbcQueryCode(
querySql: String? = daoFunDecl.getAnnotation(Query::class)?.value,
resultType: KSType? = daoFunDecl.asMemberOf(daoClassDecl.asType(emptyList())).returnType,
): CodeBlock.Builder {
beginPrepareAndUseStatementFlow(daoFunDecl, daoClassDecl, resolver)
beginPrepareAndUseStatementFlow(daoFunDecl, daoClassDecl, resolver, querySql = querySql)
if(querySql != null)
addSetPreparedStatementParams(querySql, queryVarsMap, resolver)
else if(daoFunDecl.hasAnnotation(RawQuery::class)){
Expand Down

0 comments on commit df4a9f5

Please sign in to comment.