From df4a9f57f3b166480505ee936c034bb4425ee252 Mon Sep 17 00:00:00 2001 From: Mike Dawson Date: Mon, 12 Sep 2022 22:06:09 +0400 Subject: [PATCH] Fix DataSourceFactory query generation issue. --- build.gradle | 2 +- .../lib/annotationprocessor/core/DoorJdbcProcessor.kt | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index c3aa0737..f2f51cf7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'com.github.UstadMobile.door' -version '0.0.62a' +version '0.0.62b' ext.localProperties = new Properties() diff --git a/door-compiler/src/main/kotlin/com/ustadmobile/lib/annotationprocessor/core/DoorJdbcProcessor.kt b/door-compiler/src/main/kotlin/com/ustadmobile/lib/annotationprocessor/core/DoorJdbcProcessor.kt index b3cb3255..25e7e8bb 100644 --- a/door-compiler/src/main/kotlin/com/ustadmobile/lib/annotationprocessor/core/DoorJdbcProcessor.kt +++ b/door-compiler/src/main/kotlin/com/ustadmobile/lib/annotationprocessor/core/DoorJdbcProcessor.kt @@ -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() @@ -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]!! @@ -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)){