IDEMPIERE-5484 Import GL Journal fails with SQL error because of NVL (#1573)
This commit is contained in:
parent
bb613037e8
commit
2e0317e54c
|
@ -28,3 +28,13 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
$function$
|
$function$
|
||||||
;
|
;
|
||||||
|
|
||||||
|
CREATE or REPLACE FUNCTION nvl (text, text ) RETURNS text
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
IMMUTABLE
|
||||||
|
AS $function$
|
||||||
|
BEGIN
|
||||||
|
RETURN COALESCE($1, $2);
|
||||||
|
END;
|
||||||
|
$function$
|
||||||
|
;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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$
|
||||||
|
;
|
||||||
|
|
|
@ -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.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
@ -274,4 +275,20 @@ public class DBTest extends AbstractTestCase
|
||||||
}
|
}
|
||||||
assertEquals(3, match);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue