distal-attribute
distal-attribute
distal-attribute
distal-attribute

Data grid read-only if no primary keys are defined?

User, date Message
Written by ansgar
8 years ago
Category: General
4988 posts since Fri, 07 Apr 06
Hi folks,

just discussing this bug with David:
http://sourceforge.net/tracker/index.php?func=detail&aid=1528267&group_id=164593&atid=832350

We'd like to help you remember to define primary keys on your tables, by turning the grids read-only when a primary key is missing. As an added bonus, this helps in a bunch of situations where HeidiSQL would otherwise corrupt data. What do you think?

Anse
Written by lliberty
8 years ago
2 posts since Sat, 14 Oct 06
Could someone please tell me the steps to actually do this (turn grids to read-only)?

I am trying to set the primary key to "id" so I can use a SQL database with Ruby on Rails, and for the life of me I cannot figure it out.

Any help would be most appreciated.
Written by MitchellT
8 years ago
1 posts since Mon, 23 Oct 06
Liberty,

After playing with it for an afternoon, (I'm new to both SQL and Rails) I did it this way: Create a field with "id" as the name, INT type and default value left blank.
Check the auto increment box. Click Update Field button.

Once you are back at the table view, right click "id" again, select properties, then select the indexes tab. Pull down the Primary index name, and use the second arrow, to move the "id" field in the available column to the column used.

There is probably a much better way to do this, but it got me to the next step in the rails tutorial.
Written by lliberty
8 years ago
2 posts since Sat, 14 Oct 06
Thanks for the info - that works. I could not find another way. I do hope that there is a more elegant way to generate the primary key (and edit DB names) in future versions of HeidiSQL.

I was able to finally get my first Rails app to work.
Written by mstocker
8 years ago
2 posts since Tue, 24 Oct 06

anse wrote: Hi folks,

just discussing this bug with David:
http://sourceforge.net/tracker/index.php?func=detail&aid=1528267&group_id=164593&atid=832350

We'd like to help you remember to define primary keys on your tables, by turning the grids read-only when a primary key is missing. As an added bonus, this helps in a bunch of situations where HeidiSQL would otherwise corrupt data. What do you think?

Anse



I voted not sure. What I would really like is to have it be an option. By default it is locked against editing. But I can allow it if I want.

Normally this would never ever come up for me (as it shouldn't for anyone) but sometimes I am cleaning up bad data and I have tables without keys because of this and in that situation it would be helpful.
Written by koter84
8 years ago
15 posts since Wed, 08 Nov 06
i voted definitely yes, but perhaps it is possible to check how much fields will be updated when you use a table without index.
You could then give a warning if more then one field will be changed/updated.
Written by ansgar
8 years ago
4988 posts since Fri, 07 Apr 06
Yes that's exactly how we fixed that problem. A message is thrown if less or more than exactly 1 record has been affected by the last UPDATE or DELETE action.
Written by koter84
8 years ago
15 posts since Wed, 08 Nov 06

anse wrote: Yes that's exactly how we fixed that problem. A message is thrown if less or more than exactly 1 record has been affected by the last UPDATE or DELETE action.



You say "has been affected" which means that it has already too late if it wasn't intended. Is that the way it's implemented? or is there an extra check in advance?
Written by ansgar
8 years ago
4988 posts since Fri, 07 Apr 06
Sorry, koter84, I mis-read your posting slightly. We implemented a check AFTER the data has been sent to the server. This was the result of a longer discussion in the bugtracker:
http://sourceforge.net/tracker/index.php?func=detail&aid=1539943&group_id=164593&atid=832347
Written by silverain
8 years ago
1 posts since Sun, 17 Dec 06
Hi, Just to go back to the problem with defining the primary key for Ruby on Rails-- I tried the solution offered above, but I get the error message "Incorrect table definition; there can be only one auto column and it must be defined as a key". When I turn off the auto-increment function, make the id field, and then try to add it as an index using the directions above, it won't let me and says "SQL Error: Duplicate entry '0' for key 1. How do I create a primary key with the name "id"?
Written by Pedja
8 years ago
6 posts since Wed, 01 Nov 06
If I make mistake, then it is my problem. I find sowteare that tries to help me not to make mistakes just annoys me since usaly, something that is perfectly valid it recognizes as mistake.

It is ok if you add such control in Heidi, but as an option. Who needsit, he should beable to turn on such control.
Written by F98
8 years ago
4 posts since Mon, 26 Feb 07
I voted "no" (my base intension with HSQL is to edit tables).

I think the better way to solve the problem is to place an edit-checkbox on the top of the gui (e.g. like the limit checkbox). This checkbox must be checked if the user wants to edit a no-primary-keyed table ("he knows the risk"). In addition to this the table background could be colored in a different way (maybe "warning red").

Greetings

F98.
Written by rsterenb
8 years ago
1 posts since Tue, 27 Feb 07
I registered specifically for this poll: I voted No because I need to edit tables in a grid and I really like HeidiSQL to do this job.

I second F98 and Pedja: If you you must make the grid read-only when viewing a table without primary key, please also place a button, checkbox or whatever to make it read-write, and/or make it a configuration option that can be changed as needed.
Written by siMKin
7 years ago
104 posts since Sun, 01 Apr 07
I agree with the last 3 posts.

However, i also know there are a lot of users that are quite inexperienced with databases who won't be able to see the danger that lies in front of them. And I'm sure they'll get quite upset (and blame the program) when too much of their data gets altered.
So what i would propose is that Heidi
- by default disables editing the data
- shows a message upon opening the data-grid of a table without primary key for the first time, warning the user of the consequences and explaining why it has been switched off and giving him/her the option to go to 'advanced mode' (or sth) in which you can edit the data. After that the message should not appear any more and the settings be saved (and of course be accesible through a menu apart from that)
Written by muzza4
7 years ago
51 posts since Mon, 04 Dec 06
Hi Anse,

I asked a question in a different topic about this very issue, and I'll mention here what I said to ensure my views are included when this decision is made...

"...I can't agree with this "it's your problem" approach - if this product is for everyone then it needs to get this bit right.

I have tested this issue in MySQL-Front. The user is not able to update a field unless a primary key is specified.

I would recommend this approach be taken here."

Just my 2 cents worth.

Cheers
Muzza
Written by Pap
7 years ago
1 posts since Mon, 30 Apr 07
MySQL Query Browser gets it right by silently adding the primary key from the table into your query and not displaying it in the result set. Then when you do any editing to the resultset, it DOES know the primary key for each row updated.

IMO, HeidiSQL must default to NOT ALLOW editing of the resultset if it doesn't know for a fact the primary key of the row to be editing. If the devs then want to satisfy one or two "power users" by adding an option that lets you do it anyway then that's their prerogative.

There is absolutely no logic in defaulting such a minimally-useful and potentially disasterous "feature" to ON.
 

Please login to leave a reply, or register at first.