Skip to content

Fixed import sql ignoring multiple tables in a ddl file#1201

Open
joe-albert wants to merge 10 commits into
datacontract:mainfrom
joe-albert:fix/import-sql
Open

Fixed import sql ignoring multiple tables in a ddl file#1201
joe-albert wants to merge 10 commits into
datacontract:mainfrom
joe-albert:fix/import-sql

Conversation

@joe-albert
Copy link
Copy Markdown

@joe-albert joe-albert commented Apr 29, 2026

There was an issue I noticed where when a sql ddl file had multiple tables defined the import functionality would only convert the first one to ODCS and ignore the rest.

Also, a few mysql types were not handled so I added handling for those.

Edit: sorry made a few other changes to accommodate primary keys defined at the table level.

  • Tests pass (uv run pytest) [I ran relevant tests and they passed-- I do not have docker setup locally so did not run the full suite, also did not see any documentation on this part of the testing?]
  • Code formatted (uv run ruff check --fix && uv run ruff format)
  • README.md updated (if relevant)
  • CHANGELOG.md entry added

This is a test sql ddl I used where only the first table was processed:

CREATE TABLE customers (
  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Primary key, unique customer identifier',
  first_name VARCHAR(50) NOT NULL COMMENT 'Customer first name',
  last_name VARCHAR(50) NOT NULL COMMENT 'Customer last name',
  email VARCHAR(255) NOT NULL COMMENT 'Customer email address, used for login',
  phone VARCHAR(20) COMMENT 'Optional contact phone number',
  date_of_birth DATE COMMENT 'Customer date of birth',
  is_active TINYINT(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Whether the customer account is active',
  created_at DATETIME NOT NULL COMMENT 'Timestamp when the record was created',
  updated_at DATETIME COMMENT 'Timestamp when the record was last updated',
  PRIMARY KEY (id),
  UNIQUE KEY customers_email_uk (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE orders (
  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Primary key, unique order identifier',
  customer_id INT(10) UNSIGNED NOT NULL COMMENT 'Foreign key referencing the customer who placed the order',
  status VARCHAR(20) NOT NULL DEFAULT 'pending' COMMENT 'Order status: pending, processing, shipped, delivered, cancelled',
  total_amount DECIMAL(10,2) NOT NULL COMMENT 'Total monetary value of the order',
  item_count SMALLINT UNSIGNED NOT NULL COMMENT 'Number of items in the order',
  notes VARCHAR(1000) COMMENT 'Optional free-text notes about the order',
  shipped_at DATETIME COMMENT 'Timestamp when the order was shipped',
  created_at DATETIME NOT NULL COMMENT 'Timestamp when the order was placed',
  updated_at DATETIME COMMENT 'Timestamp when the record was last updated',
  PRIMARY KEY (id),
  KEY orders_customer_id_idx (customer_id),
  CONSTRAINT orders_customer_fk FOREIGN KEY (customer_id) REFERENCES customers (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

@jschoedl
Copy link
Copy Markdown
Collaborator

jschoedl commented May 7, 2026

The changes LGTM! Can you add tests or extend an existing test to cover the bugs you described (multiple tables & composite keys)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants