Problem with creating new user or editing it

Viktor8 years ago

Hi!
have traccar 3.15 server with MySQL database

Trying to add new user and getting this error:
Duplicate entry '' for key 'users_ukey_login' - MySQLIntegrityConstraintViolationException (... < QueryBuilder:477 < DataManager:457 < BaseObjectManager:96 < ...)

However I can register a new user.
But when I'm trying to edit it - I'm getting the same error.

In database I see that in Users table fields id,email,login are unique
but there are no records in login field...

mysql> select id,email,login from users;
+----+----------------------+-------+
| id | email                | login |
+----+----------------------+-------+
|  1 | -----@-----.com |        |
|  7 | -----@-----.com | NULL  |
+----+----------------------+-------+
2 rows in set (0.00 sec)

I'm not sure, but as for me it sounds like a bug?

Thanks,
Viktor

Viktor8 years ago

for now I've fix it y removing users_ukey_login (login) from keys:

mysql> show index from users;
+-------+------------+----------------------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name                   | Seq_in_index | Column_name     | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+----------------------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| users |          0 | PRIMARY                    |            1 | id              | A         |           2 |     NULL | NULL   |      | BTREE      |         |               |
| users |          0 | uk_user_email              |            1 | email           | A         |           2 |     NULL | NULL   |      | BTREE      |         |               |
| users |          0 | users_ukey_login           |            1 | login           | A         |           2 |     NULL | NULL   | YES  | BTREE      |         |               |
| users |          1 | users_fkey_usersettings_id |            1 | userSettings_id | A         |           2 |     NULL | NULL   | YES  | BTREE      |         |               |
+-------+------------+----------------------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
4 rows in set (0.01 sec)

mysql> alter table users drop index users_ukey_login;

But I'm sure it is not a best way here.

Anton Tananaev8 years ago

Login should not be empty. It should be NULL. I'm not sure how you managed to get into this state, but we are running a lot of Traccar 3.15 servers with MySQL database and have no issues. For example, all demo servers use MySQL and latest official release and everything works perfectly fine.

Viktor8 years ago

weird.
so currently login field is not something really valuable and removing it from key should not cause a problems?

Anton Tananaev8 years ago

It should be fine if you are not using LDAP.