IDEMPIERE-5484 Import GL Journal fails with SQL error because of NVL (#1573)

This commit is contained in:
Carlos Ruiz 2022-11-23 09:22:52 +01:00 committed by GitHub
parent bb613037e8
commit 2e0317e54c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 0 deletions

View File

@ -28,3 +28,13 @@ BEGIN
END;
$function$
;
CREATE or REPLACE FUNCTION nvl (text, text ) RETURNS text
LANGUAGE plpgsql
IMMUTABLE
AS $function$
BEGIN
RETURN COALESCE($1, $2);
END;
$function$
;

View File

@ -0,0 +1,4 @@
-- IDEMPIERE-5484 Import GL Journal fails with SQL error because of NVL
-- PostgreSQL only
SELECT register_migration_script('202211201304_IDEMPIERE-5484.sql') FROM dual;

View File

@ -0,0 +1,13 @@
-- IDEMPIERE-5484 Import GL Journal fails with SQL error because of NVL
SELECT register_migration_script('202211201304_IDEMPIERE-5484.sql') FROM dual;
CREATE or REPLACE FUNCTION nvl (text, text ) RETURNS text
LANGUAGE plpgsql
IMMUTABLE
AS $function$
BEGIN
RETURN COALESCE($1, $2);
END;
$function$
;

View File

@ -17,6 +17,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.math.BigDecimal;
import java.sql.Timestamp;
@ -274,4 +275,20 @@ public class DBTest extends AbstractTestCase
}
assertEquals(3, match);
}
@Test
public void test_NVL() throws Exception
{
// multi datatype NVL
// numeric, integer
BigDecimal result = DB.getSQLValueBDEx(null, "SELECT NVL(GrandTotal, 0) FROM C_Order WHERE C_Order_ID=100");
assertTrue(result != null);
// integer, numeric
result = DB.getSQLValueBDEx(null, "SELECT NVL(10, C_Order_ID) FROM C_Order WHERE C_Order_ID=100");
assertTrue(result != null);
// Varchar, Text
String resultStr = DB.getSQLValueStringEx(null, "SELECT NVL(Description, C_Charge_ID||' ') FROM C_Charge WHERE C_Charge_ID=101");
assertTrue(resultStr != null);
}
}