-
Notifications
You must be signed in to change notification settings - Fork 377
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
Circular error when deserializing drift modules #3227
Comments
Hi, the error is not critical (and also likely happened in the previous version, we just didn't log it). Thanks for the report though, this is still something we should fix. |
Hi @simolus3, we get the exact same warning in our code for a bunch of different things. Let me give you an example so you have something to go off of:
I've added the table definition below, as a txt file: |
Thanks for the details! I suspect this might be related to the |
Hi @simolus3, Sorry for the late reply. Here is the definition for the table and the dataclass used for it. @UseRowClass(SalesInvoice) @OverRide class SalesInvoice implements Insertable { |
We're also seeing this issue. It's a warning, but it's causing our CI builds to fail. |
@Dumoulin-Lander You have two tables referencing each other ( @andresthinkme and @Fraa-124, could you also check whether your table might have circular references to other tables linking back to the original table? That would explain the error. |
@simolus3 |
e.g. from django.db import models
class Student(models.Model):
name = models.CharField(max_length=100)
group = models.ForeignKey("StudentGroup", on_delete=models.CASCADE)
class StudentGroup(models.Model):
name = models.CharField(max_length=100)
top_student = models.ForeignKey(
Student, on_delete=models.CASCADE, related_name="top_student"
) There is a circular reference here. But here is how django can creates it BEGIN;
--
-- Create model Student
--
CREATE TABLE "hello_student" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(100) NOT NULL);
--
-- Create model StudentGroup
--
CREATE TABLE "hello_studentgroup" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(100) NOT NULL, "top_student_id" bigint NOT NULL REFERENCES "hello_student" ("id") DEFERRABLE INITIALLY DEFERRED);
--
-- Add field group to student
--
CREATE TABLE "new__hello_student" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(100) NOT NULL, "group_id" bigint NOT NULL REFERENCES "hello_studentgroup" ("id") DEFERRABLE INITIALLY DEFERRED);
INSERT INTO "new__hello_student" ("id", "name", "group_id") SELECT "id", "name", NULL FROM "hello_student";
DROP TABLE "hello_student";
ALTER TABLE "new__hello_student" RENAME TO "hello_student";
CREATE INDEX "hello_studentgroup_top_student_id_dfeeb764" ON "hello_studentgroup" ("top_student_id");
CREATE INDEX "hello_student_group_id_3dd4e5e4" ON "hello_student" ("group_id");
COMMIT; This looks really complex. I don't know how feasible it would be to bake this into drift, but it's technically possible. even in sqlite |
With the That's something for the future though, the broken state is that we don't currently support circular references (and there are several places in |
Alright, I've found the root cause but it's not going to be easy to resolve (or at least I don't have an obvious solution). We're running modular analysis to improve build performance, and the tables are defined in different files. So let's say that we had two files, We should probably keep track of transitive attempted dependencies somehow to file the error on both tables, which would fix this issue (or at least give it a better error message). |
I am getting the same error any quick solutions.
|
Note that this error is mostly harmless and doesn't change the generated code. Could you also check whether the table in |
Thank you so much for quickly replaying.
I actually had error of manager and reference need to be added
Then updated drift to latest version and it start showing: Circular error
when deserializing
After seeing this I downgraded back and start seeing @reference required
for manager again.
Then I read the manager documentation and use cases so I actually do not
use it and not need it. So I disabled it from config yml file of drift.
Now my issue is solved.
Can you please tell me about manager is it required to use or does it
helps.
…On Sun, 6 Oct 2024 at 4:12 PM Simon Binder ***@***.***> wrote:
Note that this error is mostly harmless and doesn't change the generated
code. Could you also check whether the table in drug_formulas.dart
references a table that itself then references the drug_formulas.dart
table again?
—
Reply to this email directly, view it on GitHub
<#3227 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIUFLXGNT5SHKT4EQKPDQADZ2EO2XAVCNFSM6AAAAABOPJ7WNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJVGQYDMNRTG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
You don't need to use it but it's just an easier way to write queries. |
@simolus3 This error message should probably be clarified. |
The manager bug was that it required to add @reference at every
relationship I had in latest version.
Going back to older versions fixes that.
…On Sun, 6 Oct 2024 at 8:40 PM Moshe Dicker ***@***.***> wrote:
@simolus3 <https://github.com/simolus3> This error message should
probably be clarified.
—
Reply to this email directly, view it on GitHub
<#3227 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIUFLXDGPPPAQCUCEFRBL2TZ2FOGJAVCNFSM6AAAAABOPJ7WNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJVGQ4TENZSGA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Oh, but that would just print a warning, those can be ignored |
But after those warnings the build was not working. New files ware not
generating. Doing above steps help solve the problem.
Thank you for all you guys being very active and responding.
…On Sun, 6 Oct 2024 at 10:04 PM Moshe Dicker ***@***.***> wrote:
Oh, but that would just print a warning, those can be ignored
—
Reply to this email directly, view it on GitHub
<#3227 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIUFLXDHI6WZWYWCQSHMW7DZ2FYCFAVCNFSM6AAAAABOPJ7WNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJVGUYTSMJYHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Would you mind sharing it? |
After upgrading from Drift 2.19.1 to 2.20.2, I get an error message when trying to build.
The error message is
"Could not deserialize DriftElementId(package:axibis_base/database/sales/sales_invoices_dao.dart, sales_invoices)
Internal error while deserializing DriftElementId(package:axibis_base/database/sales/sales_invoices_dao.dart, sales_invoices): Bad state: Circular error when deserializing drift modules. This is a bug in drift_dev!"
When I changeg back to version 2.19.1 this was solved. Nothing changed in my code after the update.
The text was updated successfully, but these errors were encountered: