Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while parsing #50

Closed
aiphee opened this issue Jul 14, 2020 · 2 comments · Fixed by #51
Closed

Error while parsing #50

aiphee opened this issue Jul 14, 2020 · 2 comments · Fixed by #51
Assignees
Labels
bug Something isn't working

Comments

@aiphee
Copy link

aiphee commented Jul 14, 2020

Create statement:

CREATE TABLE `CheckoutCartItem`
(
    `checkoutCartItemId`        int(10) unsigned        NOT NULL AUTO_INCREMENT,
    `checkoutCartId`            int(10) unsigned        NOT NULL,
    `timeCreated`               timestamp               NOT NULL COMMENT 'time when the item was added to the cart for the first time',
    `itemId`                    int(10) unsigned        NOT NULL,
    `skuid`                     varchar(64)                      DEFAULT NULL COMMENT 'additional identifier for item (e.g. skuid that defines required size of shoe)',
    `quantity`                  int(10) unsigned        NOT NULL COMMENT 'quantity of item in cart',
    `availableQuantity`         int(10) unsigned        NOT NULL COMMENT 'available quantity when user last seen the product - by this is detected change and user is notified about it',
    `discount`                  decimal(12, 3) unsigned NOT NULL DEFAULT 0.000 COMMENT 'applied discount to the product totalAmount',
    `tax`                       tinyint(2) unsigned     NOT NULL DEFAULT 0 COMMENT 'applied VAT to the amount',
    `amountPerItem`             decimal(13, 4)          NOT NULL COMMENT 'amount per item with VAT (by this is detected change and user is notified about it)',
    `amountPerItemExcludingVat` decimal(13, 4)          NOT NULL COMMENT 'amount per item without VAT',
    `totalAmount`               decimal(13, 4)          NOT NULL COMMENT 'amount * quantity +/- special tax, discount, ... with VAT (by this is detected change and user is notified about it)',
    `totalAmountExcludingVat`   decimal(13, 4)          NOT NULL COMMENT 'amount * quantity +/- special tax, discount, ... without VAT',
    PRIMARY KEY (`checkoutCartItemId`),
    UNIQUE KEY `checkoutCartId_itemId` (`checkoutCartId`, `itemId`),
    CONSTRAINT `checkoutCartItem_ibfk_1` FOREIGN KEY (`checkoutCartId`) REFERENCES `CheckoutCart` (`checkoutCartId`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

code:

import glob
import os
from ddlparse.ddlparse import DdlParse

for filename in glob.glob('/home/jirka/Projekty/Glami/klarka/schema/mysql/tables/CheckoutCartItem.sql'): # TODO all
    with open(filename, 'r') as f: # open in readonly mode
        table = DdlParse().parse(f.read(), source_database=DdlParse.DATABASE.mysql)
        for col in table.columns.values():
            print(col.name)

output columns:

checkoutCartItemId
unsigned
NULL
checkoutCartId

@shinichi-takii shinichi-takii added the bug Something isn't working label Jul 17, 2020
@shinichi-takii shinichi-takii self-assigned this Jul 17, 2020
@shinichi-takii
Copy link
Owner

@aiphee
Thank you for reporting.

I fixed this issue.
Please upgrade the package to v1.6.0.

$ pip --no-cache-dir install --upgrade ddlparse

Thanks

@aiphee
Copy link
Author

aiphee commented Jul 27, 2020

Works flawlessly for all our tables, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants