Possible Bug/Quirk with postgresSQL

I was playing with some sample data from @Walt ref: Templates for CSV uploads? - #14 by Farmer-Ed

And it appears he uses some brackets () in his location names. But my database didn’t like it, land assets saved ok but any log saved referencing them crashed.

example name: HortasDoVale-West (HDVW) - bed 12

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Farm Asset Reference[farm_asset_reference]: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type bigint: "HDVW" LINE 4: WHERE "asset_field_data"."id" IN ('HDVW') ^: SELECT "asset_field_data"."name" AS "asset_field_data_name", "asset_field_data"."id" AS "id" FROM "asset_field_data" "asset_field_data" WHERE "asset_field_data"."id" IN (:db_condition_placeholder_0) ORDER BY "asset_field_data_name" ASC NULLS FIRST; Array ( [:db_condition_placeholder_0] => HDVW ) in main() (line 19 of /opt/drupal/web/index.php).

Removing the brackets solved the issue

points to note, this is a development VM image which was thrown together with out any love just to run a few tests so there could well be issues on my end. The issue dose not really effect me as I don’t intend on using brackets in my names. Just thought it worth noting incase it pops up anywhere else.

1 Like

I’ve noticed this too - and can replicate it via the UI - although I haven’t had a chance to debug.

A similar bug (same error, different cause) is reported here: Can't auto-create terms with parentheses in them · Issue #503 · farmOS/farmOS · GitHub

@Farmer-Ed can you share a little more detail about how it happened?

Yes indeed, @Farmer-Ed : bracketing the abbreviated name of location in all my plant asset names is the convention we have used on all such records -which also involves all related log files- which records now number well into the thousands!

This is good to know -although it’s kinda too late for me to change our crop naming convention now!

The fact that is a known bug, which- judging by the way issue is named: Can’t auto-create terms with parentheses in them · Issue #503 · farmOS/farmOS · GitHub -has got me kinda worried, so…

@paul121 : can you advise as to whether this could impact on ability of our “Crop importer” API script to spawn new terms, in case an imported asset does not match any existing term?

ps @Farmer-Ed : thanks a heap for raising the red flag, as soon as you hit this little land-mine!

1 Like

It was an image I use for testing with very little data in the database.
The Land Assets were added through the UI with no Issue, but the names all had brackets in them.
I was then adding a transplanting log through the UI, which referenced one of the land assets, when I clicked save the error occurred. I was just creating one log manually to use as a template for the API. I must try the same log via the API at some stage over the weekend.

White screen with “The website encountered an unexpected error. Please try again later.”

@walt, have you experienced this issue yourself? if not perhaps it does not effect logs created via the API (If that is the only way you generate these logs)
On the other hand if it does effect you surely you can rename land assets without too much issue as they are linked to the previous logs via their UUID. Although I’d get confirmation on that from @mstenta or @paul121 before trying it and that’s “IF” you need to do anything at all. I was just highlighting an observation I made, there is probably no need for panic.

1 Like

Just to confirm creating logs which reference the land assets with brackets work fine through the API.

2 Likes

Thanks for the details @Farmer-Ed - I think this is only an issue with autocomplete fields, it seems. I assume you ran into it while using the “Location” asset reference field on a log (which uses the autocomplete widget).

1 Like