Skip to content

Commit

Permalink
Add the description about the nullLiteral function
Browse files Browse the repository at this point in the history
  • Loading branch information
nakamura-to committed Jan 20, 2024
1 parent e649f6d commit 747e147
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
15 changes: 14 additions & 1 deletion content/en/docs/Reference/Query/QueryDsl/expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ select t0_.department_name, (select count(*) from employee as t1_ where t0_.depa

## Literals {#literal}

To embed a value directly into SQL as a literal without binding variable, call the `literal` function.
To embed a value directly into SQL as a literal without binding variable, call the `literal` function or `nullLiteral` function.

These functions are defined in `org.komapper.core.dsl.operator`.

Expand All @@ -919,6 +919,19 @@ insert into ADDRESS (ADDRESS_ID, STREET, VERSION) values (?, 'STREET 100', 100)
*/
```

To use a null literal, call the `nullLiteral` function:

```kotlin
QueryDsl.insert(a).values {
a.addressId eq 100
a.street eq nullLiteral(String::class)
a.version eq nullLiteral(Long::class)
}
/*
insert into ADDRESS (ADDRESS_ID, STREET, VERSION) values (?, null, null)
*/
```

## User-defined expressions {#user-defined-expression}

### Custom comparison operators {#user-defined-expression-comparison-operator}
Expand Down
17 changes: 15 additions & 2 deletions content/ja/docs/Reference/Query/QueryDsl/expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -891,9 +891,9 @@ select t0_.department_name, (select count(*) from employee as t1_ where t0_.depa

## リテラル {#literal}

バインド変数を介さず直接値をリテラルとしてSQLに埋め込みたい場合は`literal`を呼び出します。
バインド変数を介さず直接値をリテラルとしてSQLに埋め込みたい場合は`literal`または`nullLiteral`を呼び出します。

`literal`関数は`org.komapper.core.dsl.operator`に定義されています。
`literal`関数と`nullLiteral`関数は`org.komapper.core.dsl.operator`に定義されています。

`literal`関数がサポートする引数の型は以下のものです。

Expand All @@ -915,6 +915,19 @@ insert into ADDRESS (ADDRESS_ID, STREET, VERSION) values (?, 'STREET 100', 100)
*/
```

nullリテラルを使うには`nullLiteral`関数を呼び出します。

```kotlin
QueryDsl.insert(a).values {
a.addressId eq 100
a.street eq nullLiteral(String::class)
a.version eq nullLiteral(Long::class)
}
/*
insert into ADDRESS (ADDRESS_ID, STREET, VERSION) values (?, null, null)
*/
```

## ユーザー定義の式 {#user-defined-expression}

### 独自の比較演算子 {#user-defined-expression-comparison-operator}
Expand Down

0 comments on commit 747e147

Please sign in to comment.