DoobDev / Doob

🤖 - discord.js (Typescript) bot
https://doobbot.com
GNU General Public License v3.0
26 stars 5 forks source link

Async db #300

Closed timmypidashev closed 3 years ago

timmypidashev commented 3 years ago

An asynchronous rewrite to db

Pre-Merge checklist

At its current stages this is by no means a working build, and there are missing features, one in particular being the scheduler in the db, db.autosave. The reason for small little errors like this is because this is a lot of breaking changes, and as such it might not be worth doing if this pr is not useful. If this pr proves to be successful, i will make sure to test all code changes and add the missing features i was too lazy to add lol.

timmypidashev commented 3 years ago

Alright here's the problem: the current status of this pr is "working", but 75% of most commands fail because of how i put the async wrappers while trying to find all refs to db objects. My mistake, but I dont have time this week to fix this, as I am currently busy with work, but here is the gist of the problem:

level, exp = await db.record(f"SELECT level, exp FROM users WHERE UserID = {user.id}")

the above query breaks because of tuples and the like, the fix is:

level, exp = (await db.record(f"SELECT level, exp FROM users WHERE UserID = {user.id}")[0])

There are some other exceptions, like [0][0], which will also need proper formatting. Any query that takes data and puts it into more than 2 variables should be put into an extra set of () just to be safe. I am not completely sure if my implementation is correct, but I suspect there are a lot of easy fixes to this problem. Anyway, use this pr at your will, I have allowed edits by maintainers in case somebody wants to go ahead and use this.

mmattbtw commented 3 years ago

closing due to the upcoming v3 rewrite, all v2 issues and pull requests have been closed.