fix: harden table-ID sequence names in SequenceCheck (invalid names, typo auto-fix, save validation)#623
Merged
yamelsenih merged 1 commit intoJul 8, 2026
Conversation
…typo auto-fix, save validation)
## Problem
Running the Sequence Check process fails with a PostgreSQL syntax error for
sequences flagged IsTableID='Y' whose name is not a valid identifier:
CREATE SEQUENCE ATAJO DE COMANDOS PDV_SEQ INCREMENT 1 MINVALUE 0 MAXVALUE 99999999 START 1000000
org.postgresql.util.PSQLException: ERROR: syntax error at or near "DE"
A table-ID sequence name must be a valid SQL identifier because the native
sequence is created/consumed as <Name>_SEQ. Some records are document
sequences mis-flagged as IsTableID='Y', and their names contain spaces. The
failed CREATE SEQUENCE also aborts the transaction, so the corrected
AD_Sequence record is not saved.
## Changes
1. Skip invalid names when creating the native sequence
(createMissingNativeSequence): validate the name is a SQL identifier before
issuing CREATE SEQUENCE; otherwise log a warning (with Name + AD_Sequence_ID)
and skip.
2. Auto-fix typos (fixTableSequenceName): if an invalid name's canonical form
(whitespace -> '_') matches a real table (case-insensitive) that has a
<name>_ID column, correct the stored name to the real AD_Table.TableName
(exact casing). This rescues records that were simple typos so they validate
and get their native sequence.
3. Prevent bad data at the source (MSequence.beforeSave): reject saving a
sequence flagged IsTableID='Y' when its name is not a valid identifier.
Document sequences (IsTableID='N') are unaffected and may keep spaces/accents.
## Notes
- Behavior-preserving for valid table-ID sequence names and for document sequences.
- Touches SequenceCheck.java and MSequence.java.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running the Sequence Check process fails with a PostgreSQL syntax error for sequences flagged
IsTableID='Y'whose name is not a valid identifier:A table-ID sequence name must be a valid SQL identifier because the native sequence is created/consumed as
<Name>_SEQ. Some records are document sequences mis-flagged asIsTableID='Y', and their names contain spaces. The failedCREATE SEQUENCEalso aborts the transaction, so the correctedAD_Sequencerecord is not saved.Changes
This hardens table-ID sequence names in three layers:
Skip invalid names when creating the native sequence (
createMissingNativeSequence): validate the name is a SQL identifier before issuingCREATE SEQUENCE; otherwise log a warning (withName+AD_Sequence_ID) and skip.Auto-fix typos (
fixTableSequenceName): if an invalid name's canonical form (whitespace →_) matches a real table (case-insensitive) that has a<name>_IDcolumn, correct the stored name to the realAD_Table.TableName(exact casing). This rescues records that were simple typos so they validate and get their native sequence.Prevent bad data at the source (
MSequence.beforeSave): reject saving a sequence flaggedIsTableID='Y'when its name is not a valid identifier. Document sequences (IsTableID='N') are unaffected and may keep spaces/accents.How to test
SYSTEM_NATIVE_SEQUENCE=Y, have anAD_SequencewithIsTableID='Y'and a name containing spaces.PSQLException: syntax error, transaction aborted.Sequence name fixed => ...).WARNINGidentifying the misconfigured record; no exception; the process continues.AD_SequencewithIsTableID='Y'and a spaced name → rejected with a validation message.Notes
SequenceCheck.javaandMSequence.java.🤖 Generated with Claude Code