LP1937294: Fix Sample Data Load Predictability Issue
authorJason Stephenson <jason@sigio.com>
Mon, 15 Nov 2021 19:21:17 +0000 (14:21 -0500)
committerMike Rylander <mrylander@gmail.com>
Wed, 23 Mar 2022 22:45:17 +0000 (18:45 -0400)
Add "ORDER BY id" to the main queries in the functions used to create
call numbers and copies when loading the sample data.  This change
allows the call numbers and copies to be created in a predictable
manner.

The necessity of this change was revealed by the failure of the
20-hold-targeter.t Perl live test on PostgreSQL 11+.  After this
change, that test passes on newer PostgreSQL versions and continues to
pass on PostgreSQL 10.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/tests/datasets/sql/env_create.sql

index 9e8d955..fe9dbea 100644 (file)
@@ -55,7 +55,8 @@ RETURNS void AS $$
         FROM biblio.record_entry
         WHERE id > 0 AND 
             CASE WHEN $3 IS NULL THEN TRUE 
-                ELSE last_xact_id = $3 END;
+                ELSE last_xact_id = $3 END
+        ORDER BY id;
 $$ LANGUAGE SQL;
 
 CREATE FUNCTION evergreen.populate_call_number 
@@ -84,7 +85,8 @@ RETURNS void AS $$
     INSERT INTO asset.copy (call_number, circ_lib, creator, editor, loan_duration, fine_level, price, barcode)
         SELECT id, $1, 1, 1, 1, 1, (SELECT evergreen.generate_price()), $3 || id::text
         FROM asset.call_number
-        WHERE record > 0 AND label LIKE $4 || '%' AND owning_lib = $2;
+        WHERE record > 0 AND label LIKE $4 || '%' AND owning_lib = $2
+        ORDER BY id;
 $$ LANGUAGE SQL;
 
 /** Returns the next (by ID) non-deleted asset.copy */