Skip to content

Handling Single-Line Comments in Table DDL#1905

Closed
newtora2pg wants to merge 1 commit intodarold:masterfrom
newtora2pg:handling_singleline_comment_table
Closed

Handling Single-Line Comments in Table DDL#1905
newtora2pg wants to merge 1 commit intodarold:masterfrom
newtora2pg:handling_singleline_comment_table

Conversation

@newtora2pg
Copy link
Copy Markdown
Contributor

Problem:
In Oracle table DDL, when single-line comments (--) are used after columns, Ora2Pg places commas after the comments.
This causes syntax errors in the converted PostgreSQL DDL. This occurs when fetching from source db.

Example:

Oracle Input:
CREATE TABLE employees (
employee_id NUMBER PRIMARY KEY,
first_name VARCHAR2(50) -- fname
,
last_name VARCHAR2(50) -- lname
,
hire_date DATE
);

Incorrect Ora2Pg Output:
CREATE TABLE employees (
employee_id INTEGER PRIMARY KEY,
first_name VARCHAR(50) -- fname,
last_name VARCHAR(50) -- lname,
hire_date DATE
);

Solution:
Updated logic to detect single-line comments during DDL reconstruction. Ensured that commas are placed before comments or moved to the next line if needed. Prevented syntax issues in PostgreSQL due to misplaced commas.

@darold
Copy link
Copy Markdown
Owner

darold commented Mar 24, 2026

Commit 9c1a813 might be more efficient. Thanks.

@darold darold closed this Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants