nuclearsilo583 / zephyrus-store-preview-new-syntax

My rewritten zephyrus store
61 stars 40 forks source link

Fix SQL Queries #160

Closed strteamservidores closed 1 year ago

strteamservidores commented 1 year ago

on map load, the plugin was giving a sql error, like this (ON THE LAST VERSION OF PLUGIN):

Sourcemod version: 1.11.6932

[store.smx] SQL error happened.
Query: DELETE FROM store_items, store_equipment WHERE (store_items.unique_id = store_equipment.unique_id) AND store_items.date_of_expiration != 0 AND store_items.date_of_expiration < 1681787415

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (store_items.unique_id = store_equipment.unique_id) AND store_items.date_o' at line 1

i changed the code and made a quick test, seems to work good!

strteamservidores commented 1 year ago

This patch doesn't work on SQLite and reverts the changes I've done in #147

SQLite I didn't get to test it, but the old fix didn't fix it in MySQL, it continued with the error.

azalty commented 1 year ago

I believe this bug was actually fixed on the latest version (master) of the plugin, and you reintroduced it with this PR. You might have downloaded the latest release instead, which could've been bugged.

What indicates this is the fact that the error message prints the old query from prior #147 (instead of mine).

Furthermore, I don't believe the syntax DELETE X,X FROM X,X exists, in either SQLite or MySQL. It doesn't seem to be in either of the documentations.

I think you've accidentally downloaded the wrong versions as what you're saying doesn't seem to match the reality, I'll however check further to ensure that this is true.

strteamservidores commented 1 year ago

this https://github.com/nuclearsilo583/zephyrus-store-preview-new-syntax/pull/147 pull request did not fix the error, I installed the plugin today and the error continues, it only fixed after the changes I made, this in MySQL, I did not test it in SQLite.

but any changes can be made, it was just a quick fix I tested and it seemed to be fixed.

strteamservidores commented 1 year ago

i was getting this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (store_items.unique_id = store_equipment.unique_id) AND store_items.date_o' at line 1

With this querie:

DELETE FROM store_items, store_equipment WHERE (store_items.unique_id = store_equipment.unique_id) AND store_items.date_of_expiration != 0 AND store_items.date_of_expiration < 1681787415

Using this version of plugin: https://github.com/nuclearsilo583/zephyrus-store-preview-new-syntax/blob/master/addons/sourcemod/scripting/store/db.sp#L42

tested on phpmyadmin too: image

azalty commented 1 year ago

Thanks for your reply.

Can you try the current one without the parenthesis of the first WHERE clause?

Edit: nevermind, SQL syntax is weird and the previous syntax is indeed working for MySQL. We could try to find a query that works for both drivers or make a driver-dependent query

azalty commented 1 year ago

I created a new PR #161 that adds driver-dependent queries to fix this problem.

Could you please take a look at it to check if it works? I've implemented the exact same query that you for MySQL, so it should work; but hey, we never know when that's @azalty that's coding!

Thanks a lot for reporting and my sincere apologies for breaking the entire plugin for MySQL users for like 2 ENTIRE MONTHS. You behaved great, was fast to answer and gave me lots of useful infos, thanks ❤️!

nuclearsilo583 commented 1 year ago

161