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
Ensure generate_schema EXACTLY the same as SHOW CREATE TABLE in MySQL #237
Comments
That's easy enough to do. Thank you for the very clear requirement |
Wow, how did I miss this for the 0.15.0 release? |
Essentially this? UNIQUE KEY `idx_event_name_c6f89f` (`name`, `prize`) I'm just busy trying to get it to work right for the other DB's as that seems entierly MySQL specific. |
Ok, I confirmed that is right for MySQL. I now also noticed when I do a `token` varchar(100) NOT NULL COMMENT 'Unique token',
UNIQUE KEY `token` (`token`), instead of this: `token` VARCHAR(100) NOT NULL UNIQUE COMMENT 'Unique token' Is this a problem for you? Should I make it look exactly like the |
No, it is not problem, because my script tries to convert it to the default MySQL dialect. Though in my opinion a long (or not so long) term goal should be to make SchemaGenerators to create exactly the same (or very close) as the engines' DDL. Thanks for your work! |
…auto-assigning a potentially non-unique constraint name. (#237)
Ok, the next version should have the fix. I didn't get around to doing the "make generate_schema EXACTLY the same as SHOW CREATE TABLE in MySQL" yet. |
…auto-assigning a potentially non-unique constraint name. (#237)
Release v0.15.2 should have the fix for this. Please test and confirm. |
Thanks, it is solved the original issue. |
Hi, I noticed that on MySQL What do you think? |
Oh, no. The aiomysql driver chokes the moment we go 1 byte over 128k... 😭 |
Right, its 128k for all the parameters added up. So adding more parameters eats into that 128k :-(
😞 |
What about allowing the user to specify it? Most of the time users use simple TEXT fields (64K), it is for storing product descriptions or things like that, for them 64k is more than enough. So I would make this the default. It could be configurable by fields or by connection parameter. May be the latter would better preserve the general fields of Tortoise. If you want to generalize the behavior between engines, LONGTEXT is a good choice. It has 4 bytes overhead per record, which is not a big deal nowdays. Only 4MB per 1M records. It is a way less than storing data on filesystems (e.g. NTFS). I like about Tortoise that it is not overcomplicated and beeing something general across database engines may be better than having a lot of not so important unique database features. And if I need something like that I could easily override tortoise classes (because it is not overcomplicated).
I don't really understand this. Is it a bug in aiomysql? Ir is it an implementation problem of it? |
Yes, The same bug. It only happens with aiobysql that I see so far. The other DB backends happily do a lot more. Well, I was wondering just changing the default so that it works with a good default. I mean if the standard size limit of SQLite is 2GB, and PostgreSQL is 16EB, then MySQL at 64KB seems a bit out of place. I'd rather up it to 4GB and just use 2 extra bytes in the header. Seems very cheap to me, and I don't see the need to ever use plain ol TEXT for this. So options are:
|
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. |
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:
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.
The text was updated successfully, but these errors were encountered: