Update(in edit mode) a field from a list without a primary key

Discussion of open issues, suggestions and bugs regarding database management and administration tools for MySQL
Post Reply
christian.kaps
Posts: 3
Joined: Tue 25 Jun 2013 09:10

Update(in edit mode) a field from a list without a primary key

Post by christian.kaps » Tue 25 Jun 2013 09:31

Hi,

I don't know if it's a bug or a feature. Let us assume that I have the following table structure.

Code: Select all

userID | email | password | active
Now if I select all users without its ID.

Code: Select all

SELECT `email`, `password`, `active` FROM `users`
Then I get the list:

Code: Select all

email             | password | active
[email protected]  | ******   | 1
[email protected]  | ******   | 1
[email protected]  | ******   | 0
[email protected]  | ******   | 0
[email protected]  | ******   | 1
Now If I change(in edit mode) the active status for user with email [email protected] to 0 then all other users in the database gets the active status 0.

If it's a bug then this should be fixed, and if it's future then the application should show an info message that all entries in the database will be updated after confirmation.

Cheers,
Christian

alexa

Re: Update(in edit mode) a field from a list without a primary key

Post by alexa » Tue 25 Jun 2013 12:25

We were not able to reproduce this issue.

Could you please check that you are using the latest build 6.0.265 of dbForge Studio for MySQL: http://www.devart.com/dbforge/mysql/stu ... nload.html

Please also provide us the CREATE TABLE statement of the table (right-click the table in Database Explorer and select 'Generate Script As -> CREATE' from the popup menu) and let us know whether there is a trigger for this table?

christian.kaps
Posts: 3
Joined: Tue 25 Jun 2013 09:10

Re: Update(in edit mode) a field from a list without a primary key

Post by christian.kaps » Tue 25 Jun 2013 13:54

Hi,

my explanation was referred to a fictional table and I haven't tested it with the given query. Sorry this was my fault.

But I was able to reproduce it also with this table structure and a similar query.

The table structure.

Code: Select all

USE test;
CREATE TABLE test.test (
  userID int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  email varchar(50) DEFAULT NULL,
  password varchar(255) DEFAULT NULL,
  active tinyint(4) DEFAULT NULL,
  PRIMARY KEY (userID)
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_unicode_ci;
The data:

Code: Select all

INSERT INTO test.test (`email`, `password`, `active`) VALUES ('[email protected]', '***', 1);
INSERT INTO test.test (`email`, `password`, `active`) VALUES ('[email protected]', '***', 1);
INSERT INTO test.test (`email`, `password`, `active`) VALUES ('[email protected]', '***', 0);
INSERT INTO test.test (`email`, `password`, `active`) VALUES ('[email protected]', '***', 1);
INSERT INTO test.test (`email`, `password`, `active`) VALUES ('[email protected]', '***', 0);
The query:

Code: Select all

SELECT
  `password`,
  `active`
FROM test
Steps to reproduce:
1. Create the table
2. Insert the data
3. Execute the query
4. Edit the active status for the second row to 0
5. Click the refresh button

It seems that if a unique value is available in the result, then the error doesn't occur. Then if I select additionally the email address, then the application changes only the edited field.

alexa

Re: Update(in edit mode) a field from a list without a primary key

Post by alexa » Wed 26 Jun 2013 08:39

Thank you for the reply.

We were able to reproduce this issue and will fix it in one of the next builds of dbForge Studio for MySQL. We will notify you once it's available for downloading.

alexa

Re: Update(in edit mode) a field from a list without a primary key

Post by alexa » Tue 14 Jan 2014 17:44

A more detailed investigation revealed that this issue appears to be by design.

dbForge changes a record using an UPDATE statement which means that if a selection doesn't contain the values that uniquely identify a record, it appears to be not possible to generate a query to modify a concrete record.

christian.kaps
Posts: 3
Joined: Tue 25 Jun 2013 09:10

Re: Update(in edit mode) a field from a list without a primary key

Post by christian.kaps » Wed 15 Jan 2014 08:47

Thanks for your reply.

Is it now planed to show the user an information that all entries will be updated?

alexa

Re: Update(in edit mode) a field from a list without a primary key

Post by alexa » Wed 15 Jan 2014 11:23

Unfortunately, we are not planning to implement such functionality.

Post Reply