Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upinfer_schema! reaches the recursion limit easily #1127
Comments
This comment has been minimized.
|
That is sadly a problem we can't easily solve in Diesel. For now, just follow the compiler's advice: Add the Personally, I set this to 1024 at the first error just to not have to deal with this again. Also, IIRC, the default (64 apparently) was recently increased in rustc, so maybe you'll see this error less often in the future. That said, we could solve this in Diesel: We'd need to replace the macro with a procedural macro. That is not an easy feat (the macro is quite complex and has a lot of edge cases), and not currently our focus. We'll absolutely look more deeply into this once the next batch of proc-macro features becomes stable in rustc, though. |
killercup
closed this
Aug 25, 2017
This comment has been minimized.
|
Oh, or do you have a quick fix for this in mind? I've not looked into it more deeply, but if there was an easy change we could make to consume more doc attribute tokens per macro call we'd reduce the table macro's call stack drastically. (Still, not something I really want to spend much time on—there are more pressing matters—but I'd accept a PR for this for sure!) |
This comment has been minimized.
mattdeboard
commented
Oct 21, 2017
•
|
Hi, so the trouble I'm having is that any table with more than 24 columns (these are extant tables) throws this error. I can run I tried doing edit: Ok apparently the answer is this is a limitation of Rust itself. Here is an explanation with pointers to more detailed explanations. |
mattdeboard
referenced this issue
Oct 21, 2017
Closed
Bug at using tables with more than 16 fields #477
This comment has been minimized.
Kazakuri
commented
Oct 21, 2017
|
So basically my understanding of it is that the recursion limit is hit when expanding the Like killercup said, the way the So unless the macro gets re-written which has a lot of problems in itself, the only real solution is increasing the recursion limit of your program. |
This comment has been minimized.
mattdeboard
commented
Oct 21, 2017
•
|
@Kazakuri Ya I have added that to the top of my Also I added the |
Kazakuri commentedAug 25, 2017
Setup
Versions
Problem Description
What are you trying to accomplish?
Having diesel automatically infer the schema for a table with more than ~10 columns.
It looks like the default recursion limit for macros is 64 which can be quite easy to reach with 6 lines of code being generated for each database column.
What is the expected output?
Diesel compiles with no issues.
What is the actual output?
Steps to reproduce
You can use pretty much any schema, just pad it with a bunch of extra blank documentation comments.
Checklist