d2 icon indicating copy to clipboard operation
d2 copied to clipboard

when label in sql_table is set to same as key, it doesn't work

Open alixander opened this issue 1 year ago • 2 comments

Screenshot 2024-05-31 at 10 51 54 PM

time: {
  shape: sql_table
  timeID: int {constraint: primary_key}
  date: date
}

alixander avatar Jun 01 '24 05:06 alixander

@alixander, Sorry for my negligence, i am new to contributing to d2, Could you please provide an example that demonstrates when a label is set to the same as a key in sql_table shape? This would help clarify the specific scenario where the rendering breaks.?

Looking at the code and diagram, I don't see any case where a label is set to be the same as a key. In the D2 input:

timeID is a field name/label int is the data type primary_key is a constraint.

There seems to be a disconnect between the issue description and this example, as it doesn't demonstrate the reported problem of a label being the same as a key. Please let me know if i have not clearly understood the issue reported here. :)

code-shivy avatar Nov 28 '24 16:11 code-shivy

Hey @code-shivy

So the bug is that when you have date: date, "date" only shows up once: https://play.d2lang.com/?script=HMkxDoAgDAXQvaf45-js4ilI1SY2AiJ0IYS7G13e8tySMgYB7ZSijPbE4LJFJeDLdWFYdoz9zs2rWHZGqZak9nBpnwQc4sq_NOkNAAD__w%3D%3D&

But if I set to date: x, both "date" and "x" show up: https://play.d2lang.com/?script=FMkxDoAgDAXQvaf45-js4ilI1SY2AiJ0kBDubpyfW1LGIKCdUpTRnhhctqgE_LguDMuOsd-5eRXLzijVktQeLu2TgENcGS9N-gIAAP__&

Does that make sense?

alixander avatar Nov 28 '24 18:11 alixander