question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ensure generate_schema EXACTLY the same as SHOW CREATE TABLE in MySQL

See original GitHub issue

Describe the bug As you may know, I’m working on a schema sync to MySQL which should work with Tortoise ORM. For this to work good the schema that Tortoise generate should be as close to the result of SHOW CREATE TABLE as possible. Now it works quite well, though I still have a problem with unique_together.

To Reproduce See the example in #215 . The generated SQL is semantically good, though MySQL will give a name to the unique key, which is the name of the 1st field it uses. But if you have another key with that name, it will add a number to it. So it is not deterministic enough.

Expected behavior It should look like this:

UNIQUE KEY `key_user_id_62ed175d` (`key`, `user_id`)

Additional context Also the full command has the KEY keyword, tortoise generates code without it, though I could resolve it with regexp in my schema sync.

I still need a similar custom schema generator described in #215 to solve this.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
wallneradamcommented, Dec 12, 2019

I agree with you, 64KB is small for a lot of tasks. MySQL is the oldest engine of them, and it can work on very low end hw, this is why they leave it configurable this way.

Though I can’t imagine a situation where it is useful to store a whole DVD in a DB column. It would be very slow. These are only theoretical values. It is useful to store pictures, PDF-s and similar things in DB columns which is very common. So I think option 2 is the way to go, which makes tortoise-mysql similar to other engines.

1reaction
grigicommented, Nov 27, 2019

Release v0.15.2 should have the fix for this. Please test and confirm.

Read more comments on GitHub >

github_iconTop Results From Across the Web

13.7.7.10 SHOW CREATE TABLE Statement
Shows the CREATE TABLE statement that creates the named table. To use this statement, you must have some privilege for the table. This...
Read more >
13.1.20 CREATE TABLE Statement - MySQL :: Developer Zone
The SQL standard specifies that all types of constraints (primary key, unique index, foreign key, check) belong to the same namespace.
Read more >
13.1.20.4 CREATE TABLE ... SELECT Statement
CREATE TABLE new_tbl [AS] SELECT * FROM orig_tbl;. MySQL creates new columns for all elements in the SELECT . For example: mysql> CREATE...
Read more >
13.7.5.10 SHOW CREATE TABLE Statement
Shows the CREATE TABLE statement that creates the named table. To use this statement, you must have some privilege for the table. This...
Read more >
13.7.7.13 SHOW CREATE VIEW Statement
For example, you might use the ANSI SQL mode to ensure MySQL correctly interprets the standard ... MySQL always stores it the same...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found