diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-19 14:32:54 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-19 14:32:54 +0100 |
| commit | 4bec6ebb34f8a811483f732fba93aa66839495b3 (patch) | |
| tree | 062db841ab2d439efdfc05b71a4ea39b164b32a9 | |
| parent | ba0299466de6fda5390d69e0e588403994500667 (diff) | |
| download | stock-4bec6ebb34f8a811483f732fba93aa66839495b3.tar.gz stock-4bec6ebb34f8a811483f732fba93aa66839495b3.tar.bz2 stock-4bec6ebb34f8a811483f732fba93aa66839495b3.zip | |
Guard all CAST(xkey AS DOUBLE PRECISION) in list_stock.php against empty strings
Firebird throws -413 on CAST of empty string to DOUBLE PRECISION. The main
xkey SUM was already guarded by SIMILAR TO on the JOIN, but bom_qty and both
part_size subqueries (BOM view and general list) were not. Added SIMILAR TO
guards to all three.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | list_stock.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/list_stock.php b/list_stock.php index 6ad176e..3de65e4 100644 --- a/list_stock.php +++ b/list_stock.php @@ -46,7 +46,7 @@ if( $assemblyContentId ) { $query = "SELECT lc.`content_id`, lc.`title`, lc.`data`, bom.`item` AS qty_type, - CAST(bom.`xkey` AS DOUBLE PRECISION) AS bom_qty, + CASE WHEN bom.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?' THEN CAST(bom.`xkey` AS DOUBLE PRECISION) ELSE NULL END AS bom_qty, bom.`xorder` AS bom_xorder, (SELECT FIRST 1 sup.`xkey` FROM `{$X}liberty_xref` sup @@ -54,7 +54,8 @@ if( $assemblyContentId ) { ORDER BY sup.`xorder`) AS part_number, (SELECT FIRST 1 CAST(pk.`xkey` AS DOUBLE PRECISION) FROM `{$X}liberty_xref` pk - WHERE pk.`content_id` = lc.`content_id` AND pk.`item` = 'PRT') AS part_size, + WHERE pk.`content_id` = lc.`content_id` AND pk.`item` = 'PRT' + AND pk.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?') AS part_size, (SELECT SUM( CASE WHEN EXISTS ( SELECT 1 FROM `{$X}liberty_xref` r WHERE r.`content_id` = mx.`content_id` AND r.`item` IN ('TRANS','ORDER') @@ -98,7 +99,8 @@ if( $assemblyContentId ) { ORDER BY sup.`xorder`) AS part_number, (SELECT FIRST 1 CAST(pk.`xkey` AS DOUBLE PRECISION) FROM `{$X}liberty_xref` pk - WHERE pk.`content_id` = lc.`content_id` AND pk.`item` = 'PRT') AS part_size, + WHERE pk.`content_id` = lc.`content_id` AND pk.`item` = 'PRT' + AND pk.`xkey` SIMILAR TO '[0-9]+(\.[0-9]+)?') AS part_size, SUM( CASE WHEN EXISTS ( SELECT 1 FROM `{$X}liberty_xref` r WHERE r.`content_id` = x.`content_id` AND r.`item` IN ('TRANS','ORDER') |
