Skip to content

[Fixes #14673]: Upload fails with duplicate key value violates unique constraint when column names start with a digit - #14677

Closed
mwallschlaeger wants to merge 1 commit into
GeoNode:masterfrom
mwallschlaeger:issue_#14673_Upload_fails_with_duplicate_key_value_violates_unique_constraint_when_column_names_start_with_a_digit
Closed

mwallschlaeger wants to merge 1 commit into
GeoNode:masterfrom
mwallschlaeger:issue_#14673_Upload_fails_with_duplicate_key_value_violates_unique_constraint_when_column_names_start_with_a_digit

Conversation

@mwallschlaeger

Copy link
Copy Markdown
Member

Description

Prefixed the name with _ instead of substituting inside it, and do it after slugify so the underscore isn't stripped:

name = slugify.slugify(name[:62], separator="_")

if name[:1].isdigit():
    name = f"_{name}"

3_1a → _3_1a, 6_1a → _6_1a: distinct names, nothing deleted. The function is now also idempotent means under certain cirumstances it is currently possible that this function get called multiple times. Result now stays the same

Behaviour change

fixup_name() is used for layer/table names as well, so a layer named 1layername now normalises to _1layername instead of all appearances of the the first digit in a layername get replaced by _.

closes #14673

Checklist

For all pull requests:

  • Confirm you have read the contribution guidelines
  • You have sent a Contribution Licence Agreement (CLA) as necessary (not required for small changes, e.g., fixing typos in the documentation)
  • Make sure the first PR targets the master branch, eventual backports will be managed later. This can be ignored if the PR is fixing an issue that only happens in a specific branch, but not in newer ones.

The following are required only for core and extension modules (they are welcomed, but not required, for contrib modules):

  • There is a ticket in https://github.com/GeoNode/geonode/issues describing the issue/improvement/feature (a notable exemption is, changes not visible to end-users)
  • The issue connected to the PR must have Labels and Milestone assigned
  • PR for bug fixes and small new features are presented as a single commit
  • PR title must be in the form "[Fixes #<issue_number>] Title of the PR"
  • New unit tests have been added covering the changes, unless there is an explanation on why the tests are not necessary/implemented

Submitting the PR does not require you to check all items, but by the time it gets merged, they should be either satisfied or inapplicable.

@cla-bot cla-bot Bot added the cla-signed CLA Bot: community license agreement signed label Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug cla-signed CLA Bot: community license agreement signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upload fails with "duplicate key value violates unique constraint" when column names start with a digit

1 participant