Skip to content
This repository has been archived by the owner on Aug 28, 2020. It is now read-only.

Klasa SQLProvider class does not check for instanceof MemberGateway in klasa-member-gateway #867

Open
1 of 2 tasks
Lovinity opened this issue Nov 3, 2019 · 0 comments
Open
1 of 2 tasks
Labels
Bug: Confirmed Issues that report confirmed bugs. Mod: SettingsGateway Issues and PRs related to SettingsGateway.

Comments

@Lovinity
Copy link

Lovinity commented Nov 3, 2019

Describe the issue

The SQLProvider class of Klasa.js conflicts with klasa-member-gateway MemberGateway class. When executing the parseEntry function, line 102 only checks for instanceof Gateway, which returns false for a MemberGateway via klasa-member-gateway. As a result, the returning data is a TextRow class when expected a Javascript Object. This is a problem for providers such as MySQL because arrays do not get properly parsed from JSON strings in this condition.

Code or steps to reproduce

Line 102 of src/lib/structures/SQLProvider

if (!(gateway instanceof Gateway)) return entry;
  1. Add the klasa-member-gateway plugin to Klasa.js
  2. Use and set up the MySql provider
  3. Add at least one guildMember field to the member-gateway schema which takes an array.
  4. For one member, leave the array empty. For another guildMember, add some values into the array.
  5. Execute !eval message.member.settings

Expected and actual behavior

Expected behavior:
*Values/arrays in guildMember.settings via klasa-member-gateway with the MySQL provider are properly parsed just as other settings (such as guild.settings and user.settings) are.

Actual behavior:
*While non-MemberGateway settings are properly parsed and returned as objects, MemberGateway settings are not properly parsed as objects and instead returned as a TextRow. Furthermore, when using in conjunction with schema-script SQL providers such as MySQL, arrays are not properly parsed... they are either strings when there are more than one entry, or they are "undefined" when there are no entries.

Further details

  • discord.js version: github:discordjs/discord.js#3a9eb5b92928631edc79e09894ba6bbad90516f7
  • node.js version: 12.13.0
  • Klasa version: github:dirigeants/klasa#0e9174cab0df7d28f3a7b8ca78b6344fef2611c9
  • I have modified core files.
  • I have tested the issue on latest master. Commit hash: 0e9174c
@kyranet kyranet added Bug: Confirmed Issues that report confirmed bugs. Mod: SettingsGateway Issues and PRs related to SettingsGateway. labels Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug: Confirmed Issues that report confirmed bugs. Mod: SettingsGateway Issues and PRs related to SettingsGateway.
Projects
None yet
Development

No branches or pull requests

2 participants