prahladyeri / VisualAlchemist

Open source database diagramming and automation tool
GNU General Public License v3.0
728 stars 57 forks source link

Self referenceing tables. #26

Closed Euphorbium closed 5 years ago

Euphorbium commented 8 years ago

Am I mistaken, or is there no way to create a self reference in a table?

prahladyeri commented 8 years ago

You are not mistaken, I was not aware that such a feature is even used anywhere. Do all databases like mysql and postgresql support this?

Euphorbium commented 8 years ago

Yes, it is a basic feature all databases support.

On Sunday, 8 May 2016, Prahlad Yeri notifications@github.com wrote:

No you are not mistaken, I was not aware that such a feature is even used anywhere. Do all databases like mysql and postgresql support this?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/prahladyeri/VisualAlchemist/issues/26#issuecomment-217706578

prahladyeri commented 8 years ago

Gr8, this will be a nice addition to VA! I've added this bug to the 1.1 milestone.

prahladyeri commented 8 years ago

@calebmauer How exactly did you add self-referencing feature? You cannot drag a primary key field to another field of itself. If you try to do it, you are shown the below error:

Source and Target table cannot be the same

calebmauer commented 8 years ago

That doesn't happen when I run it. Are you sure you're running the latest version?

On my copy, you can make a field reference other fields on the same table, it just can't reference itself, and that gives you an error that says: "A field cannot have a reference to itself.". But I got rid of the error you're referencing.

Here's the latest copy of that function, and it doesn't have that error: /* jsPlumb events */ jsPlumb.bind("beforeDrop", function(info) { //check if a connection already exists between these two points var con=jsPlumb.getConnections({source:info.sourceId, target:info.targetId }); if (con.length>0) { console.log("This Connection already exists, detaching old one."); jsPlumb.detach(con[0]); } var pkey = $(info.connection.source).attr('fpname').split("."); var fkey = $(info.connection.target).attr('ffname').split("."); console.log('BEFORE_DROP', pkey, fkey); if (pkey[0] == fkey[0] && pkey[1] == fkey[1]) { bspopup("A field cannot have a reference to itself."); return false; } tables[fkey[0]].fields[fkey[1]].ref = pkey[0] + '.' + pkey[1]; bsalert({text: pkey[1] + '->' + fkey[1], title:"Connection established: "}); saveCanvasState(); return true; //return false or just quit to drop the new connection. });

On Tue, Aug 2, 2016 at 11:59 PM, Prahlad Yeri notifications@github.com wrote:

@calebmauer https://github.com/calebmauer How exactly did you add self-referencing feature? You cannot drag a primary key field to another field of itself. If you try to do it, you are shown the below error:

Source and Target table cannot be the same

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/prahladyeri/VisualAlchemist/issues/26#issuecomment-237130390, or mute the thread https://github.com/notifications/unsubscribe-auth/ABc2-zJ-S8mETvckCDSw_AbNjQ78G34Fks5qcBIHgaJpZM4IYMYx .

prahladyeri commented 5 years ago

Closing as there has been no activity.