chartdb / chartdb

Free and open-source database diagrams editor, visualize and design your DB with a single query.
https://chartdb.io
GNU Affero General Public License v3.0
3.29k stars 162 forks source link

SQLite import: Invalid JSON #233

Open leox182 opened 19 hours ago

leox182 commented 19 hours ago

Hi, when I try to import my SQLite database I always get an error “Invalid JSON”.

sqlite-import-original.json

I have found in the JSON result some error (according to me) that looks like this: \"default\":\"\\\\\\\\\\\\\"\\\\\\\\\\\\\"\".

So I have formatted and cleaned the result:

sqlite-import-formatted.json

However I still get the same error.

additionally I have tried to paste the formatted result at different nesting levels but I have not been successful either.

The database is hosted in Turso, but I have also tried with a local database.

johnnyfish commented 7 hours ago

@leox182 Hi, thanks for raising this issue!

I've tested the import on my end, and everything seems to be working fine for me, so it might be an individual issue. I'd love to help you resolve it and make sure you can use the tool smoothly.

Could you share the exact JSON file you’re using so I can dig deeper and find the root of the problem? That way, I can replicate the issue and get it fixed for you.

In the meantime, here's a short video of me importing the SQLite database without any errors, just to show that it's working fine on my side:

sqlite2

Looking forward to your JSON file, and we’ll get this sorted out! :)

leox182 commented 5 hours ago

Thanks @johnnyfish for the reply,

@johnnyfish, I got it to work, looking at your video more closely I see that the JSON was not formatted, so I tried just removing the errors that were there and removing the “\” and it worked.

The problem is then when I paste the formatted JSON is when I get the error. Maybe it could be a bug?

I also attach this files on the original comment. Thank for the help

johnnyfish commented 2 hours ago

@leox182 Thanks for the update!

It seems like the issue might be related to how the default values are being handled during the import process. I tested it on my end and found that the error occurs when default values show up for certain tables.

Could you share the CREATE TABLE statement for the orders table (or any other table where you're seeing this issue) so I can take a closer look?

Thanks again for your help!

leox182 commented 1 hour ago

Sure! This is the original statement

CREATE TABLE orders (
    id INTEGER PRIMARY KEY NOT NULL,
    customer_id TEXT NOT NULL,
    title TEXT NOT NULL,
    description TEXT NOT NULL,
    total_price INTEGER NOT NULL,
    subtotal INTEGER NOT NULL,
    discount_amount INTEGER NOT NULL,
    vat_percentage INTEGER NOT NULL,
    vat_amount INTEGER NOT NULL,
    shipping_cost INTEGER NOT NULL,
    order_state TEXT NOT NULL,
    paid_state TEXT NOT NULL,
    responsible_id TEXT NOT NULL,
    delivery_date DATE,
    cover_url TEXT NOT NULL,
    is_archived BOOLEAN NOT NULL,
    created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (customer_id) REFERENCES customers(id),
    FOREIGN KEY (responsible_id) REFERENCES team_members(id)
);
johnnyfish commented 29 minutes ago

🤔 @leox182 Which client are you using to execute the query?