Skip to content

MySQL parsed data missing tables #290

@DevashishX

Description

@DevashishX

Describe the bug
When this data is parsed the table "student" is not returned by the parsed output.

DDL =

CREATE TABLE `department` (
  `dept_name` varchar(20) NOT NULL,
  `building` varchar(15) DEFAULT NULL,
  `budget` decimal(12,2) DEFAULT NULL,
  PRIMARY KEY (`dept_name`)
) ;
CREATE TABLE `student` (
  `ID` varchar(5) NOT NULL,
  `name` varchar(20) NOT NULL,
  `dept_name` varchar(20) DEFAULT NULL,
  `tot_cred` decimal(3,0) DEFAULT NULL,
  `timestamp` datetime NOT NULL DEFAULT '2009-04-01 08:00:00',
  PRIMARY KEY (`ID`),
  KEY `dept_name` (`dept_name`),
  CONSTRAINT `student_ibfk_1` FOREIGN KEY (`dept_name`) REFERENCES `department` (`dept_name`) ON DELETE SET NULL
) ;

To Reproduce
Steps to reproduce the behavior:

  1. Run this code
from simple_ddl_parser import DDLParser
results_from_text = DDLParser(DDL).run(output_mode="mysql")
print(results_from_text)
  1. Output on command line
[{'alter': {},
  'checks': [],
  'columns': [{'check': None,
               'default': None,
               'name': '`dept_name`',
               'nullable': False,
               'references': None,
               'size': 20,
               'type': 'varchar',
               'unique': False},
              {'check': None,
               'default': 'NULL',
               'name': '`building`',
               'nullable': True,
               'references': None,
               'size': 15,
               'type': 'varchar',
               'unique': False},
              {'check': None,
               'default': 'NULL',
               'name': '`budget`',
               'nullable': True,
               'references': None,
               'size': (12, 2),
               'type': 'decimal',
               'unique': False}],
  'index': [],
  'partitioned_by': [],
  'primary_key': ['`dept_name`'],
  'schema': None,
  'table_name': '`department`',
  'tablespace': None}]

Expected behavior
List of Dicts returned should contain both student and department tables

Desktop (please complete the following information):

  • OS: Windows 10 22H2 64 bit
  • Python: Python 3.10.15 | packaged by Anaconda, Inc. | (main, Oct 3 2024, 07:22:19) [MSC v.1929 64 bit (AMD64)] on win32

Additional context
just trying to parse a simple mysql DDL

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions