@@ -101,7 +101,6 @@ class SelectableSymbolProcessor(
101
101
val isForeign = parameter.annotations.getAnnotationOrNull(Foreign ::class .java.simpleName) != null
102
102
val jsonPathArguments = parameter.annotations.getAnnotationOrNull(JsonPath ::class .java.simpleName)?.arguments
103
103
val jsonPath = jsonPathArguments?.getParameterValue<ArrayList <String >>(JsonPath .PATH_PARAMETER_NAME )
104
- val jsonKey = jsonPathArguments?.getParameterValue<String >(JsonPath .KEY_PARAMETER_NAME )
105
104
val returnAsText = jsonPathArguments?.getParameterValue<Boolean >(JsonPath .RETURN_AS_TEXT_PARAMETER_NAME ) == true
106
105
val function = parameter.annotations.getAnnotationOrNull(ApplyFunction ::class .java.simpleName)
107
106
?.arguments?.getParameterValue<String >(ApplyFunction .FUNCTION_PARAMETER_NAME )
@@ -112,7 +111,6 @@ class SelectableSymbolProcessor(
112
111
columnName = columnName,
113
112
isForeign = isForeign,
114
113
jsonPath = jsonPath,
115
- jsonKey = jsonKey,
116
114
returnAsText = returnAsText,
117
115
function = function,
118
116
cast = cast,
@@ -145,9 +143,12 @@ class SelectableSymbolProcessor(
145
143
if (options.jsonPath != null && options.function != null ) {
146
144
logger.error(" Parameter $parameterName can't have both @JsonPath and @ApplyFunction annotation" , symbol)
147
145
}
148
- if (options.jsonKey != null && options.columnName == null ) {
146
+ if (options.jsonPath != null && options.columnName == null ) {
149
147
logger.error(" Parameter $parameterName must have a @ColumnName annotation when using @JsonPath" , symbol)
150
148
}
149
+ if (options.jsonPath != null && options.jsonPath.isEmpty()) {
150
+ logger.error(" Parameter $parameterName must have at least one path in @JsonPath annotation" , symbol)
151
+ }
151
152
}
152
153
153
154
private fun buildColumns (
@@ -158,10 +159,10 @@ class SelectableSymbolProcessor(
158
159
): String {
159
160
return buildString {
160
161
if (options.jsonPath != null ) {
161
- if (options.alias != options.jsonKey ) {
162
+ if (options.alias != options.jsonPath.last() ) {
162
163
append(" ${options.alias} :" )
163
164
}
164
- append(buildJsonPath(options.columnName, options.jsonKey, options. jsonPath, options.returnAsText))
165
+ append(buildJsonPath(options.columnName, options.jsonPath, options.returnAsText))
165
166
return @buildString
166
167
}
167
168
@@ -195,20 +196,19 @@ class SelectableSymbolProcessor(
195
196
196
197
private fun buildJsonPath (
197
198
columnName : String? ,
198
- jsonKey : String? ,
199
199
jsonPath : List <String >,
200
200
returnAsText : Boolean
201
201
): String {
202
202
val operator = if (returnAsText) " ->>" else " ->"
203
203
return buildString {
204
204
append(columnName)
205
- if (jsonPath.isNotEmpty() ) {
206
- jsonPath.forEach {
205
+ if (jsonPath.size > 1 ) {
206
+ jsonPath.dropLast( 1 ). forEach {
207
207
append(" ->$it " )
208
208
}
209
209
}
210
210
append(operator )
211
- append(jsonKey )
211
+ append(jsonPath.last() )
212
212
}
213
213
}
214
214
0 commit comments