0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OutSystemsとNULLについて改めて考えてみる

Posted at

はじめに

OutSystemsで開発を3年ほどやっています。
「NULL」の概念がないと言われるOutSystemsですが、理解があいまいなままで実際のところどうなんだろうと思い調べてみることにしました。
今回の内容は「内部DB」「Integer/LongInteger型」「Text型」に絞っています。

NullIdentifier()とNullTextIdentifier()

OutSystemsでNULLを表現する方法ではありますが、Create ActionやCreateOrUpdate Actionで指定してもNullIdentifier()は0に、NullTextIdentifier()は""に置き換えられてDBに登録されてしまいます。

image.png
image.png
様々なActionの中で使用する上では、

  • NullIdentifier() = 0
  • NullTextIdentifier() = ""

という認識で問題なさそうです。
ただし、Aggregateで使用する場合は、NullIdentifier()もNullTextIdentifier()もいずれもNULLとして扱われます。
image.png
image.png
image.png

上記のパターンで NullIdentifier() = 0 で登録されたデータは、
Filterで例えば、Employee.AgeAtJoining <> NullIdentifier()のように入力した場合、Employee.AgeAtJoiningは0で登録されてしまっているためデータを適切に抽出することはできません。

じゃあ内部DBにNULLは入らない?

入らないのかと思っていたのですが、こちらの記事にあるように意図的にNULLを入れることは可能です。

SQLでUpdate、Insertの登録・更新値としてNULLを指定します。
ただし、Service Studio上ではNULLが入っているかどうかは確認することができません。

  • AggregateのView
  • EntityのView
  • SQLのTest Output

もし、内部DBの実テーブルにアクセスできる環境があれば、そちらから確認するか「SQL Sandbox」というForgeでDBの中身を見ることができます。

image.png

実装時に気をつけること

前述したとおり、意図的に入れない限り、内部DBにNULLが入ることはないと考えていいという認識ですが、Aggregateで扱う場合のみNullIdentifier()と0、とNullTextIdentifier()と""を区別して考える必要があります。
※SQLではNullIdentifier()、NullTextIdentifier()は使用しないためAggregateに限定しました

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?