本件解決いたしました。
結論から書くと、LinuxのPostgreSQLのis_two_factor_authentication_enabledがtext型、WindowsのPostgreSQLのis_two_factor_authentication_enabledがboolean型にしてしまっていました。
どうしてこうなったのかというと人為ミスです。
WindowsのPostgreSQLの定義をダンプして、Docker環境のPostgreSQLに流し込む…ということをしているのですが、Docker環境のPostgreSQLに一世代前のWindowsのPostgreSQLの定義を流し込んでおり、不一致が発生していました。
TypeORMでPostgreSQLのboolean型の列からデータを取得する場合、WindowsのPostgreSQLから取得した場合とLinuxのPostgreSQLで型が違いました。
擬似コードは以下のとおりです。
[Usersテーブルの定義抜粋]
接続先がWindowsで動かしているのPostgreSQLの場合
結論から書くと、LinuxのPostgreSQLのis_two_factor_authentication_enabledがtext型、WindowsのPostgreSQLのis_two_factor_authentication_enabledがboolean型にしてしまっていました。
どうしてこうなったのかというと人為ミスです。
WindowsのPostgreSQLの定義をダンプして、Docker環境のPostgreSQLに流し込む…ということをしているのですが、Docker環境のPostgreSQLに一世代前のWindowsのPostgreSQLの定義を流し込んでおり、不一致が発生していました。
TypeORMでPostgreSQLのboolean型の列からデータを取得する場合、WindowsのPostgreSQLから取得した場合とLinuxのPostgreSQLで型が違いました。
擬似コードは以下のとおりです。
[Usersテーブルの定義抜粋]
@Entity()
export class Users {
@Column({ type: "boolean", default: false })
@Exclude()
is_two_factor_authentication_enabled: boolean;
[確認コード抜粋]
let usersRepository: Repository[出力]; usersRepository = getRepository(Users); const userDataFromDB = await usersRepository.findOne({ where: { id: testUserId, }, }); console.log(typeof userDataFromDB.is_two_factor_authentication_enabled);
接続先がWindowsで動かしているのPostgreSQLの場合
● Console
console.log
boolean
接続先がLinuxで動かしているのPostgreSQLの場合
● Console
console.log
string
なぜ違うのでしょうか…booleanで返ってきて欲しい…