- Issue created by @irsar
- πΊπΈUnited States agentrickard Georgia (US)
We ran into this as well, and it was a case of case-sensitivity in the data. We had "us" in the database instead of "US".
We fixed it in an update hook:
$database = \Drupal::database(); $tables = ['node__field_address', 'node_revision__field_address']; foreach ($tables as $table) { $query = $database->select($table, 'nfa') ->where('binary field_address_country_code = :code', ['code' => "us"]) ->fields('nfa', ['entity_id']) ->execute(); $result = $query->fetchCol(); foreach ($result as $id) { $query = $database->update($table); $query->fields(['field_address_country_code' => 'US']); $query->condition('entity_id', $id); $query->execute(); } }
Find your address field and run a query like this one to check:
select entity_id, field_address_country_code FROM node__field_address where field_address_country_code= BINARY 'us';
At the module level, it might be nice to UPPERCASE country codes in all lookups.
- Status changed to Fixed
11 months ago 3:34pm 29 December 2023 - π·πΈSerbia bojanz
I would prefer to let the sites be responsible for the validity of their data, because silently returning lowercase country codes could break other modules, REST clients, etc.
Automatically closed - issue fixed for 2 weeks with no activity.