-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Improve ORM Compatibility #24194
Comments
I had a quick test with Django 3.2.1 (Python). I created a new project and app and configured the database config. Then I added the models from the tutorial an ran migrations etc. With the 'admin' site I added and removed choices and questions. This seemed to work. So the basic functionality seems to work, but like many other ORMs it would be good to add full support for foreign keys. |
@dveeden Thanks for your reminder! Seems we have compatibility issues with Django as well, I'll add it to the list. BTW, are you interested in contributing to this project? |
Yes. |
for JAVA, it seems integration with libraries like Apache MetaModel, DataNucleus will bring great flexibility and generalizability to the data access layer. |
Running
Looks like the issues are:
|
With sqlalchemy/sqlalchemy#6660 this changes to:
Note that the number of failed tests decreased by 4 and the number of passed tests increased by 737. The number of skipped tests also increased. |
IMHO, we should remove those |
activerecord-tidb-adapter is ready, and this is demo app using activerecord-tidb-adapter https://github.com/hooopo/activerecord-tidb-adapter-demo |
set |
I recently tried using tidb as a backend for https://github.com/dani-garcia/vaultwarden and it almost works, but something is funky about the migrations it runs on startup. It's using diesel and runs through these migrations: https://github.com/dani-garcia/vaultwarden/tree/main/migrations/mysql, but something goes wrong with the migrations that causes it to spit out things like this (this log is from reproducing it with the diesel cli, but it's the same issue running the application):
If I manually run the migration using the mariadb client, e.g. like this:
So there's something that diesel is doing differently from the mariadb client when running the migration, but diesel doesn't seem to have any logging about exactly what it's doing which makes it hard to figure out what's going on here. I assume it has something to do with renaming and then referencing a table within the same transaction or something perhaps? But I really don't know enough about either diesel or TiDB. |
Aha, I think I figured it out. TiDB seems to behave differently than MySQL when dealing with multi-statement queries, which diesel is using for the migrtions - it looks like it makes one call to submit the whole migration as one query, vs the mariadb cli which seems to split each statement out into a separate query. When I run the migration in the mariadb cli after changing the delimiter I'm able to reproduce the problem there. I don't see any thing about multi-statement queries listed in the sections about compatibility though, is this a known difference? |
@Pythoner6 what TiDB version did you try? Older versions of TiDB didn't support ALTER statements with multiple operations. Maybe this is what's causing this? |
I dont remember right now but it should have been the latest version supported by the operator which i installed via helm. But I dont think that's it, unless I'misunderstanding what you mean. The query that fails looks like this:
(Full query here https://github.com/dani-garcia/vaultwarden/blob/main/migrations/mysql/2018-04-27-155151_create_users_ciphers/up.sql) The alter statement is a rename, and the thing that's failing is an insert into from the renamed table. When diesel executes this, it makes a single call to |
That certainly looks like something that should work with TiDB, including older versions. Is there anything in the logs of the TiDB nodes about this? Would it be possible for you to try this with a Is there an easy way for me to reproduce this? I assume I could build vaultwarden from source and then run it against a DB. Do I first need to use an older version to trigger the migration? |
I'm not super familiar with tidb, so maybe I'm missing something but I couldn't find any useful logs (though also the dashboard seemed to be failing to load logs in general so that may have been the issue). To reproduce the issue without running vaultwarden, I just installed the diesel cli, checked out the vaultwarden repo, navigated to the mysql migrations folder I linked, and ran |
I wasn't able to reproduce this with a different delimiter. This is with MySQL Shell 8.0 as client.
|
Ah, it seems this happens only if that multi-statement query is inside a transaction (which is how diesel runs migrations). Here is the minimal reproduction:
Tested against a new instance run by tiup:
|
Thanks. I was able to reproduce the issue. I've created #39664 for this. Note that many DDL statements in MySQL (and MySQL compatible) databases do an implicit commit. https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html But with that this should still work. |
Note that Foreign Keys are now supported since v6.6.0 which makes supporting ORMs a lot easier |
Introduction
ORM, which is short for Object-Relational Mapping, is usually used by applications to connect to databases like TiDB.
In order to bring good experience to application developers and enrich the TiDB ecosystem, let's:
Candidates
You may comment on this issue about the ORMs that you are using.
Goal
Considering TiDB is not 100% compatible with MySQL with:
We aim to go through the different ORMs listed above and provide the built-in implementation for TiDB.
Reference
The text was updated successfully, but these errors were encountered: