Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: Query.between isn't parsed in the right format #6006

Closed
2 tasks done
gepd opened this issue Aug 17, 2023 · 3 comments
Closed
2 tasks done

🐛 Bug Report: Query.between isn't parsed in the right format #6006

gepd opened this issue Aug 17, 2023 · 3 comments
Assignees
Labels
bug Something isn't working product / databases Fixes and upgrades for the Appwrite Database.

Comments

@gepd
Copy link
Contributor

gepd commented Aug 17, 2023

👟 Reproduction steps

  1. create a query using between for example
const query = [Query.between("date", "2023-08-15T04:00:13.989Z", "2023-08-16T04:00:13.989Z")];
  1. You'll see the output: [between("date", ["2023-08-15T04:00:13.989Z","2023-08-15T07:00:21.100Z"])]

Looking the SDK generator repo, it looks like it's the same for all SDK's https://github.com/appwrite/sdk-generator/blob/master/templates/node/lib/query.js.twig#L27

👍 Expected behavior

It should be: [between("date", "2023-08-15T04:00:13.989Z","2023-08-15T07:00:21.100Z")]

As workaround it's possible to manually write the query and you can work with it

👎 Actual Behavior

The output is: [between("date", ["2023-08-15T04:00:13.989Z","2023-08-15T07:00:21.100Z"])]

🎲 Appwrite version

Version 1.3.x

💻 Operating system

Linux

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@gepd gepd added the bug Something isn't working label Aug 17, 2023
@gepd gepd changed the title 🐛 Bug Report: Query.between doesn't have the right format 🐛 Bug Report: Query.between isn't parsed in the right format Aug 17, 2023
@gepd
Copy link
Contributor Author

gepd commented Aug 17, 2023

My first though was to change the addQuery method in the SDK generator

https://github.com/appwrite/sdk-generator/blob/master/templates/node/lib/query.js.twig#L59-L64

but seems like the solution isn't here as that query is valid for other cases when you send an array as value

@gepd
Copy link
Contributor Author

gepd commented Aug 17, 2023

I don't know if a change like this would be the best solution:

static addQuery = (attribute: string, method: string, ...values: any[]) => {
    if (method === "between") {
        return `${method}("${attribute}", ${values.map((v) => Query.parseValues(v)).join(",")})`;
    }
    
    return value instanceof Array
        ? `${method}("${attribute}", [${value
          .map((v) => Query.parseValues(v))
            .join(",")}])`
        : `${method}("${attribute}", [${Query.parseValues(value)}])`;
  };

@stnguyen90 stnguyen90 added the product / databases Fixes and upgrades for the Appwrite Database. label Aug 18, 2023
@stnguyen90 stnguyen90 self-assigned this Aug 18, 2023
@stnguyen90
Copy link
Contributor

@gepd, thanks for creating this issue! 🙏🏼 Is this the same as #5650? If so, maybe you can 👍🏼 that issue and close this one as a duplicate?

@gepd gepd closed this as completed Aug 18, 2023
@stnguyen90 stnguyen90 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / databases Fixes and upgrades for the Appwrite Database.
Projects
None yet
Development

No branches or pull requests

2 participants