Xanium1 / GemsEconomy

One of my spigot plugins. Minecraft Economy plugin with multi currency support!
14 stars 30 forks source link

SQL Queries problems #4

Closed FurryKitten closed 3 years ago

FurryKitten commented 3 years ago

Hi. You merged my pull request, but the problem was bigger than I thought. This is how database looks now image A lot of duplicates, but with different IDs.

The problem is here - "ON DUPLICATE KEY UPDATE". It works only with primary keys or unique index. Queries in code with ODKU doesn't contain primary key. And balances table doesn't even have primary key.

I think the solution here is to make CREATE queries with unique indexes (uuid mb). Or, for existing tables, rewrite SELECT queries (https://stackoverflow.com/a/46952400)

Xanium1 commented 3 years ago

In the new update i've pushed on github, I am planning not to use the balances table anymore. But the primary key thing is needed for accounts which is something im gonna do

Xanium1 commented 3 years ago

Would you mind take a look with the version you get from github now? Test it with the 4.9.1 version on spigot and this one you can compile here?

Xanium1 commented 3 years ago

I might have forgotten to add something that removes all duplicates...

FurryKitten commented 3 years ago

Yep. I'll check it soon.

FurryKitten commented 3 years ago

I might have forgotten to add something that removes all duplicates...

Yes, there are exception for already existing db with duplicates: "Duplicate entry '...' for key PRIMARY" I saved my db with duplicates to test this feature.

I tested new version on empty db. Works fine.

Xanium1 commented 3 years ago

Alright, then its just for me to fix the duplicates.

Xanium1 commented 3 years ago

Alright, then its just for me to fix the duplicates.

Could you test again now? I've added something that should remove the duplicate accounts from the table. And it should not affect anything else

FurryKitten commented 3 years ago

No, it isn't working. I restored my bd with duplicates created on version 558a636d4e02701362d05034577bf5af85274cbe, restarted server with latest GemsEco build. After this, rows with new balance format were added, but old duplicates still exist. image

FurryKitten commented 3 years ago

Is it old problem? Because I started using this plugin with 558a636d4e02701362d05034577bf5af85274cbe version.

Xanium1 commented 3 years ago

I've never personally used this plugin so I don't know :/ Maybe i should just clear the entire table since in the old versions it is no valuable information stored there.. and when players login their balances will be transferred from the balances table into their newly created account in the accounts table

Xanium1 commented 3 years ago

I pushed an update now, that should truncate the table, and you should get your balances when you login with your alts or so

Xanium1 commented 3 years ago

Could you please test it once more? if you have the time of course

Xanium1 commented 3 years ago

I tested this carefully and it works perfect for me.