From 41cd6a0f900f5f92412e94104f8cb50ae1371f36 Mon Sep 17 00:00:00 2001 From: Nick <53413353+nickpalladino@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:46:06 -0400 Subject: [PATCH 1/3] Add missing Honey Bee entry --- src/main/resources/brapi/sql/R__species.sql | 8 +-- src/test/resources/sql/brapi/species.sql | 65 ++++++++++++++------- 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/src/main/resources/brapi/sql/R__species.sql b/src/main/resources/brapi/sql/R__species.sql index 993895398..ed7667322 100644 --- a/src/main/resources/brapi/sql/R__species.sql +++ b/src/main/resources/brapi/sql/R__species.sql @@ -52,10 +52,10 @@ BEGIN ('Blueberry'), ('Salmon'), ('Grape'), ('Alfalfa'), ('Sweet Potato'), ('Trout'), ('Soybean'), ('Cranberry'), ('Cucumber'), ('Oat'), ('Citrus'), ('Sugar Cane'), - ('Strawberry'), ('Pecan'), ('Lettuce'), ('Cotton'), - ('Sorghum'), ('Hemp'), ('Hop'), ('Hydrangea'), - ('Red Clover'), ('Potato'), ('Blackberry'), ('Raspberry'), - ('Sugar Beet'), ('Coffee') + ('Strawberry'), ('Honey Bee'), ('Pecan'), ('Lettuce'), + ('Cotton'), ('Sorghum'), ('Hemp'), ('Hop'), + ('Hydrangea'), ('Red Clover'), ('Potato'), ('Blackberry'), + ('Raspberry'), ('Sugar Beet'), ('Coffee') ) AS src(crop_name) ON CONFLICT (id) DO -- want case changes or space changes to overwrite existing diff --git a/src/test/resources/sql/brapi/species.sql b/src/test/resources/sql/brapi/species.sql index f62e69156..69e3cf706 100644 --- a/src/test/resources/sql/brapi/species.sql +++ b/src/test/resources/sql/brapi/species.sql @@ -1,31 +1,50 @@ --- name: CopyrightNotice -/* - * See the NOTICE file distributed with this work for additional information - * regarding copyright ownership. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +-- See the NOTICE file distributed with this work for additional information +-- regarding copyright ownership. +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +-- See the NOTICE file distributed with this work for additional information +-- regarding copyright ownership. +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. --- name: InsertSpecies CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; DO $$ DECLARE v_auth_id CONSTANT uuid := 'AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA'; BEGIN + /* ------------------------------------------------------------------------------------------ + • uuid_generate_v5(namespace, crop_name) → deterministic UUID can be used for idempotency + • Do it this way so no schema changes are required + • Removed the Honey Bee special case because all systems will be starting fresh + ------------------------------------------------------------------------------------------ */ INSERT INTO crop (id, auth_user_id, crop_name) SELECT uuid_generate_v5('9a4deca9-4068-46a3-9efe-db0c181f491a'::uuid, + -- 1) lower‑case + -- 2) trim leading/trailing space + -- 3) REMOVE every space or tab regexp_replace(lower(trim(crop_name)), '\s', '', 'g')), v_auth_id, crop_name @@ -33,12 +52,14 @@ FROM (VALUES ('Blueberry'), ('Salmon'), ('Grape'), ('Alfalfa'), ('Sweet Potato'), ('Trout'), ('Soybean'), ('Cranberry'), ('Cucumber'), ('Oat'), ('Citrus'), ('Sugar Cane'), - ('Strawberry'), ('Pecan'), ('Lettuce'), ('Cotton'), - ('Sorghum'), ('Hemp'), ('Hop'), ('Hydrangea'), - ('Red Clover'), ('Potato'), ('Blackberry'), ('Raspberry'), - ('Sugar Beet'), ('Coffee') + ('Strawberry'), ('Honey Bee'), ('Pecan'), ('Lettuce'), + ('Cotton'), ('Sorghum'), ('Hemp'), ('Hop'), + ('Hydrangea'), ('Red Clover'), ('Potato'), ('Blackberry'), + ('Raspberry'), ('Sugar Beet'), ('Coffee') ) AS src(crop_name) ON CONFLICT (id) DO +-- want case changes or space changes to overwrite existing +-- Only rewrite the row if name changed UPDATE SET crop_name = EXCLUDED.crop_name WHERE crop.crop_name IS DISTINCT FROM EXCLUDED.crop_name; END $$; \ No newline at end of file From a65bafa6e42d38000dd29433bc37549520574587 Mon Sep 17 00:00:00 2001 From: Nick <53413353+nickpalladino@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:50:00 -0400 Subject: [PATCH 2/3] Fix test headers --- src/test/resources/sql/brapi/species.sql | 47 +++++++++--------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/test/resources/sql/brapi/species.sql b/src/test/resources/sql/brapi/species.sql index 69e3cf706..258b5db72 100644 --- a/src/test/resources/sql/brapi/species.sql +++ b/src/test/resources/sql/brapi/species.sql @@ -1,33 +1,22 @@ --- See the NOTICE file distributed with this work for additional information --- regarding copyright ownership. --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- See the NOTICE file distributed with this work for additional information --- regarding copyright ownership. --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- name: CopyrightNotice +/* + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +-- name: InsertSpecies CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; DO $$ From 8ebc08023fa521a20d8f3aeb56df20ef415f6e7f Mon Sep 17 00:00:00 2001 From: Nick <53413353+nickpalladino@users.noreply.github.com> Date: Wed, 11 Jun 2025 14:38:58 -0400 Subject: [PATCH 3/3] Remove comments in test script --- src/test/resources/sql/brapi/species.sql | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/test/resources/sql/brapi/species.sql b/src/test/resources/sql/brapi/species.sql index 258b5db72..2b8fcf26d 100644 --- a/src/test/resources/sql/brapi/species.sql +++ b/src/test/resources/sql/brapi/species.sql @@ -23,17 +23,9 @@ DO $$ DECLARE v_auth_id CONSTANT uuid := 'AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA'; BEGIN - /* ------------------------------------------------------------------------------------------ - • uuid_generate_v5(namespace, crop_name) → deterministic UUID can be used for idempotency - • Do it this way so no schema changes are required - • Removed the Honey Bee special case because all systems will be starting fresh - ------------------------------------------------------------------------------------------ */ INSERT INTO crop (id, auth_user_id, crop_name) SELECT uuid_generate_v5('9a4deca9-4068-46a3-9efe-db0c181f491a'::uuid, - -- 1) lower‑case - -- 2) trim leading/trailing space - -- 3) REMOVE every space or tab regexp_replace(lower(trim(crop_name)), '\s', '', 'g')), v_auth_id, crop_name @@ -47,8 +39,6 @@ FROM (VALUES ('Raspberry'), ('Sugar Beet'), ('Coffee') ) AS src(crop_name) ON CONFLICT (id) DO --- want case changes or space changes to overwrite existing --- Only rewrite the row if name changed UPDATE SET crop_name = EXCLUDED.crop_name WHERE crop.crop_name IS DISTINCT FROM EXCLUDED.crop_name; END $$; \ No newline at end of file