oguimbal / pg-mem

An in memory postgres DB instance for your unit tests
MIT License
1.99k stars 97 forks source link

feat: allowing bool casting #355

Closed anton-nagornyi closed 1 year ago

anton-nagornyi commented 1 year ago

Title:

Allow Casting from Boolean to other types, specifically to integer in pg-mem

Description:

This pull request addresses the limitation in pg-mem where casting from boolean to integer is not allowed. This feature is important for providing complete emulation of PostgreSQL, which supports such casting.

Changes:

Why is this change necessary?

This change is necessary to ensure that pg-mem can emulate PostgreSQL as accurately as possible. The absence of this feature could lead to discrepancies between the behavior of pg-mem and PostgreSQL, especially when testing applications that depend on this particular casting behavior.

How does it solve the problem?

The modifications to the doCanCast() and doCast() methods in the BoolType class now allow for seamless casting from boolean to integer, emulating the same behavior in PostgreSQL.

Examples

These SQL queries should now work with pg-mem:

  select true::bool;
  select true::int;
  select true::text;
oguimbal commented 1 year ago

released as pg-mem@2.7.0