Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit 7ee81e3

Browse files
committed
Adding an alias to argument names
ついでに古い内容を削除
1 parent c61423d commit 7ee81e3

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,26 @@ Here's a quick look at how to deserialize the content so far.
423423
- Use the `constructor` or `factory methods` to perform the conversion.
424424
- Use `KParameterFlatten` annotation.
425425

426+
### Other Features
427+
#### Adding an alias to argument names
428+
There is a case where the name of the argument and the column name are different as follows.
429+
430+
```kotlin
431+
// The argument "id" is defined in the DB as "foo_id".
432+
data class Foo(val id: Int)
433+
```
434+
435+
In such a case, the `KParameterAlias` annotation is used to make the mapping according to the column name on the DB.
436+
437+
```kotlin
438+
data class Foo(
439+
@param:KParameterAlias("fooId")
440+
val id: Int
441+
)
442+
```
443+
444+
The transformation of the argument name is also applied to the alias set by `KParameterAlias`.
445+
426446
### Use default arguments
427447
`KRowMapper` supports `default arguments`.
428448
`Default arguments` are available in the following situations:
@@ -447,11 +467,3 @@ When `KParameterRequireNonNull` `annotation` is given to a parameter,
447467
```kotlin
448468
data class Dst(val fooId: Int, @param:KParameterRequireNonNull val barValue: String = "default")
449469
```
450-
451-
### Parameter aliasing
452-
In `KRowMapper`, the column name of the acquisition target can be specified by giving the `KParameterAlias` `annotation` to the `parameter`.
453-
The name conversion function is applied to the name specified here.
454-
455-
```kotlin
456-
data class Dst(@param:KParameterAlias("fooId") val barValue: Int)
457-
```

0 commit comments

Comments
 (0)